:root {
  --bg-dark: #090d16;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: rgba(255, 255, 255, 0.09);
  --border-hover: rgba(99, 102, 241, 0.5);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* Ambient Background Glows */
.bg-glow {
  position: fixed;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.18;
  pointer-events: none;
  z-index: -1;
}

.glow-1 {
  top: -150px;
  left: -100px;
  background: var(--primary);
}

.glow-2 {
  bottom: -150px;
  right: -100px;
  background: var(--accent);
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.hidden {
  display: none !important;
}

/* Navbar */
.navbar {
  border-bottom: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.75);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-name {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.35rem;
}

.nav-badges {
  display: flex;
  gap: 0.6rem;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
  max-width: 740px;
  margin: 0 auto;
}

.hero-pill {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.3rem 0.9rem;
  border-radius: 99px;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}

.gradient-text {
  background: linear-gradient(135deg, #818cf8, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Dropzone */
.drop-zone {
  background: rgba(17, 24, 39, 0.75);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 3.5rem 2rem;
  text-align: center;
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  transform: scale(1.01);
}

.drop-icon-ring {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
  display: grid;
  place-items: center;
  margin: 0 auto 1.25rem;
}

.drop-zone h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}

.upload-btn-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.supported-formats {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.75rem 1.35rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.11);
}

.btn-sm {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-sm:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin: 2.5rem 0 4rem;
}

.feature-card {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.feature-icon {
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
}

.feature-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.feature-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Studio Workspace */
.studio-workspace {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 3rem;
}

.studio-viewport-panel,
.studio-controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
}

.viewport-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.view-modes {
  display: flex;
  background: var(--bg-dark);
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

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

/* Comparison Stage */
.comparison-stage {
  position: relative;
  height: 430px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  user-select: none;
  touch-action: pan-y;
  cursor: ew-resize;
  /* Transparency Checkerboard */
  background-color: #182030;
  background-image:
    linear-gradient(45deg, #232d42 25%, transparent 25%),
    linear-gradient(-45deg, #232d42 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #232d42 75%),
    linear-gradient(-45deg, transparent 75%, #232d42 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.comparison-stage.no-split {
  cursor: default;
}

.stage-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.original-overlay {
  position: absolute;
  inset: 0;
  clip-path: inset(0 50% 0 0);
}

.stage-badge {
  position: absolute;
  top: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(9, 13, 22, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  pointer-events: none;
}

.badge-left { left: 12px; color: #cbd5e1; }
.badge-right { right: 12px; color: #818cf8; }

.split-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 36px;
  transform: translateX(-50%);
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.handle-line {
  width: 2px;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}

.handle-circle {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

/* Metrics Bar */
.metrics-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.1rem;
  padding: 0.9rem 1.1rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.metric-box {
  display: flex;
  flex-direction: column;
}

.metric-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.metric-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.1rem;
}

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

.metric-divider {
  color: var(--text-muted);
  font-weight: 700;
}

.savings-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  margin-top: 0.2rem;
}

/* Controls Panel */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.panel-header h3 {
  font-size: 1.15rem;
}

.detect-tag {
  font-size: 0.72rem;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-weight: 600;
}

.control-block {
  margin-bottom: 1.35rem;
}

.block-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.format-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.format-card {
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.format-card.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
}

.fmt-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.fmt-ext {
  font-size: 1.05rem;
  font-weight: 800;
}

.fmt-check {
  color: transparent;
}

.format-card.active .fmt-check {
  color: var(--primary);
}

.fmt-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.label-with-val {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.mono-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  color: #a5b4fc;
}

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

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.helper-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.swatch-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
}

.swatch-transparent {
  background-color: #182030;
  background-image:
    linear-gradient(45deg, #475569 25%, transparent 25%),
    linear-gradient(-45deg, #475569 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #475569 75%),
    linear-gradient(-45deg, transparent 75%, #475569 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.swatch.active {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.custom-color-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  font-weight: 700;
  color: #000;
}

.custom-color-btn input {
  opacity: 0;
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.info-callout {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.9rem;
  border-radius: 10px;
  margin-bottom: 1.35rem;
  font-size: 0.82rem;
}

.info-callout p {
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.scale-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.scale-btn {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.scale-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.filename-box {
  display: flex;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.filename-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  outline: none;
}

.ext-tag {
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 0.65rem 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-download {
  width: 100%;
  padding: 0.95rem;
  font-size: 0.98rem;
}

/* Session History */
.history-section {
  margin-bottom: 4rem;
}

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

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.history-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-dark);
}

.history-meta {
  flex: 1;
  min-width: 0;
}

.history-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

@media (max-width: 920px) {
  .studio-workspace,
  .features-grid {
    grid-template-columns: 1fr;
  }
  .nav-badges {
    display: none;
  }
}