:root {
  --bg: #08080f;
  --surface: #0e0e1a;
  --surface-2: #14142a;
  --border: rgba(255, 255, 255, 0.07);
  --text: #e8e8f2;
  --text-muted: #6868a0;
  --accent: #7c5cfc;
  --accent-dim: rgba(124, 92, 252, 0.14);
  --accent-glow: rgba(124, 92, 252, 0.30);
  --card-bg: #0e0e1a;
  --font-h: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --nav-h: 56px;
  --max-w: 1200px;
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t: 0.35s var(--ease);
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f2ff;
  --surface: #ffffff;
  --surface-2: #ebe9ff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #0a0a18;
  --text-muted: #5858a0;
  --card-bg: #ffffff;
  --accent-dim: rgba(124, 92, 252, 0.10);
  --accent-glow: rgba(124, 92, 252, 0.20);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body.workspace-body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--t), color var(--t);
}

.workspace-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.workspace-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
}

.workspace-header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.workspace-logo {
  font-family: var(--font-h);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.workspace-badge {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.theme-toggle-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

[data-theme="dark"] .theme-toggle__sun {
  display: none;
}

[data-theme="light"] .theme-toggle__moon {
  display: none;
}

/* Main */
.workspace-main {
  flex: 1;
  padding: 2rem 0 3rem;
}

.workspace-main__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: color-mix(in srgb, var(--surface) 50%, transparent);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.drop-zone__icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
  opacity: 0.6;
}

.drop-zone__title {
  font-family: var(--font-h);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.drop-zone__sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.drop-zone__formats {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.6;
  letter-spacing: 0.04em;
}

/* Settings Panel */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.settings-panel__inner {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  align-items: flex-end;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 140px;
}

.settings-group--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.settings-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.settings-select,
.settings-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.65rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.settings-select:focus,
.settings-input:focus {
  border-color: var(--accent);
}

.settings-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  outline: none;
}

.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.settings-range-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
}

.settings-group--checkbox label {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.settings-group--checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Image Cards */
.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.image-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.image-card__preview {
  position: relative;
  aspect-ratio: 16/10;
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
}

.image-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease;
}

.image-card__preview:hover img {
  transform: scale(1.03);
}

.image-card__preview-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(124, 92, 252, 0.3);
}

.image-card__compare-toggle {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.image-card__compare-toggle:hover {
  background: rgba(0,0,0,0.7);
}

.image-card__body {
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.image-card__name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.image-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.image-card__stat {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.image-card__stat strong {
  display: block;
  font-family: var(--font-h);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.image-card__saved {
  color: #22c55e;
  font-weight: 700;
}

.image-card__saved--negative {
  color: #ef4444;
}

.image-card__actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.image-card__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.image-card__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.image-card__btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.image-card__btn--primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000);
  color: #fff;
}

.image-card__warning {
  font-size: 0.72rem;
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Summary Footer */
.summary-footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.summary-footer__stats {
  font-family: var(--font-h);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.summary-footer__stats span {
  color: #22c55e;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-family: var(--font-h);
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  box-shadow: 0 6px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn--sm {
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
}

/* Footer */
.workspace-footer {
  text-align: center;
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border);
}

.workspace-footer__link {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
  letter-spacing: 0.02em;
}

.workspace-footer__link:hover {
  opacity: 0.8;
  color: var(--accent);
}

/* Loading state */
.image-card--processing .image-card__preview {
  opacity: 0.5;
}

.image-card--processing .image-card__preview::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 1000;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state__icon {
  opacity: 0.4;
  margin-bottom: 1rem;
}

.empty-state__text {
  font-size: 0.9rem;
}