:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-hover: rgba(26, 37, 60, 0.85);
  --border-glow: rgba(99, 102, 241, 0.35);
  --border-card: rgba(255, 255, 255, 0.08);
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4;
  --accent-cyan: #22d3ee;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(99, 102, 241, 0.1);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}

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

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.badge-server {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  color: var(--accent-emerald);
  font-size: 0.82rem;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 15px var(--accent-emerald); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--glass-shadow);
  transition: border-color 0.3s ease;
}

.glass-panel:hover {
  border-color: var(--border-glow);
}

.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.4);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.dropzone.drag-active {
  border-color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.08);
  transform: scale(1.01);
}

.dropzone-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.2);
}

.dropzone-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.dropzone-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sample-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.sample-btn {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.dashboard-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

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

.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-card);
}

.controls-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.presets-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.preset-chip {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.preset-chip:hover {
  border-color: var(--accent-primary);
  color: #fff;
}

.preset-chip.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.25));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 15px rgba(34, 211, 238, 0.2);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.slider-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.btn-compress {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.2s ease;
}

.btn-compress:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(99, 102, 241, 0.6);
}

.viewer-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comparison-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
}

.mode-pills {
  display: flex;
  gap: 4px;
}

.mode-pill {
  padding: 6px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.mode-pill.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.media-stage {
  position: relative;
  min-height: 420px;
  background: radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-card);
  padding: 0;
}

.split-viewer {
  position: relative;
  width: 100%;
  height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  overflow: hidden;
}

.split-image-left,
.split-image-right {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.split-image-right-container {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  cursor: ew-resize;
  z-index: 10;
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: var(--bg-dark);
  border: 2px solid var(--accent-cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(34, 211, 238, 0.5);
  font-weight: bold;
}

.side-by-side-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  height: 100%;
  padding: 16px;
}

.side-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-card);
}

.side-card img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 8px;
}

.side-label {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.metrics-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.metric-value.saved {
  color: var(--accent-emerald);
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.btn-download {
  width: 100%;
  height: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.btn-download:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-download:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

@media (max-width: 640px) {
  .app-container {
    padding: 16px 12px 40px;
    gap: 16px;
  }

  .app-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
  }

  .brand-title {
    font-size: 1.25rem;
  }

  .brand-subtitle {
    font-size: 0.72rem;
  }

  .badge-server {
    font-size: 0.75rem;
    padding: 5px 10px;
  }

  .glass-panel {
    padding: 16px;
  }

  .dropzone {
    padding: 32px 16px;
  }

  .dashboard-grid {
    gap: 16px;
  }

  .comparison-mode-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .split-viewer {
    height: 320px;
  }

  .side-by-side-grid {
    grid-template-columns: 1fr;
  }

  .side-card img {
    max-height: 260px;
  }

  .metrics-banner {
    grid-template-columns: repeat(2, 1fr);
  }
}
