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

/* Hide scrollbar but keep scroll functional (for iframe embed) */
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }

:root {
  --bg-primary: #010308;
  --bg-card: #0d1117;
  --bg-card-hover: #161b22;
  --bg-card-active: #1c2028;
  --text-primary: #ffffff;
  --text-secondary: #8b949e;
  --accent: #FFB460;
  --accent-glow: rgba(255, 180, 96, 0.35);
  --radius-card: 0.75rem;
  --radius-pill: 1.25rem;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 2rem;
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 1rem;
}
.header h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
  color: #ffffff;
}
.header h1 span {
  color: #ffffff;
}
.header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: -0.005em;
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.45;
}
/* Info tooltip (bottom-left of preview frame) */
.info-tooltip-wrap {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: none;
  z-index: 5;
}
.upload-zone.has-image .info-tooltip-wrap { display: block; }
.info-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.82rem;
  height: 1.82rem;
  border-radius: 50%;
  background: var(--accent);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--accent);
  color: var(--bg-primary);
  font-size: 0.91rem;
  font-weight: 600;
  cursor: help;
  transition: all var(--transition);
}
.info-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-secondary);
}
.info-tooltip {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0;
  width: 360px;
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-card);
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.info-tooltip-wrap:hover .info-tooltip {
  opacity: 1;
  visibility: visible;
}

/* --- Upload Zone --- */
.upload-zone {
  position: relative;
  max-width: 80%;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  overflow: hidden;
  background: var(--bg-card);
  margin: 0 auto 1.5rem;
}
.upload-zone:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: var(--bg-card-hover);
}
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(200, 61, 0, 0.05);
}
.upload-zone.has-image {
  border: none;
  cursor: default;
  background: #000;
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  pointer-events: none;
}
.upload-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--text-secondary);
}
.upload-placeholder .upload-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}
.upload-placeholder .upload-text strong {
  color: var(--text-primary);
}
.upload-placeholder .upload-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.6;
}
.upload-zone.has-image .upload-placeholder { display: none; }

.upload-zone input[type="file"] {
  display: none;
}

#preview-canvas {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.upload-zone.has-image #preview-canvas { display: block; }

@keyframes subtle-pulse {
  0%, 100% { opacity: 0.95; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}
.change-image-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--accent);
  backdrop-filter: blur(8px);
  border: none;
  color: var(--bg-primary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.52rem 1.04rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: none;
  animation: subtle-pulse 3s ease-in-out infinite;
  transition: transform var(--transition), box-shadow var(--transition);
}
.change-image-btn:hover {
  animation: none;
  transform: scale(1.05);
  box-shadow: 0 0 16px var(--accent-glow);
}
.upload-zone.has-image .change-image-btn { display: block; }

/* --- Loading overlay --- */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(1, 3, 8, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-card);
}
.loading-overlay.visible { display: flex; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Controls --- */
.controls {
  display: none;
}
.controls.visible { display: block; }

/* --- Mode Toggle --- */
.mode-toggle {
  display: flex;
  justify-content: flex-start;
  gap: 0.35rem;
  margin-top: 1rem;
}
.mode-btn {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.mode-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #010307;
}

/* --- Look Grid --- */
.look-grid-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.look-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}
.look-card {
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.4rem 0.25rem;
  border-radius: var(--radius-card);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.look-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.look-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  color: var(--text-primary);
  background: var(--bg-card-active);
}
.look-card.loading {
  opacity: 0.6;
  pointer-events: none;
}
.look-card.original {
  border-style: dashed;
}

/* --- Controls Bottom Row (3 columns) --- */
.controls-bottom {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 0 1.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  align-items: start;
}
.looks-column {
  min-width: 280px;
  max-width: 340px;
}

/* --- Adjustments Section --- */
.adjustments {
  display: flex;
  flex-direction: column;
}
.adjustments .slider-group {
  flex: 1;
}
.adjustments-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.slider-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 90px;
  flex-shrink: 0;
}
.slider-track {
  flex: 1;
  position: relative;
}
.slider-track input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-card-hover);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.slider-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.slider-track input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.slider-track input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
  cursor: pointer;
}
.slider-track input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--bg-card-hover);
  border-radius: 2px;
  border: none;
}
.slider-value {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.slider-reset {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.slider-reset:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* --- Effects Section (right column) --- */
.effects-section {
  display: flex;
  flex-direction: column;
}
.effects-section .slider-group {
  flex: 1;
}
.effects-upsell {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0.5rem 0 0 0;
  opacity: 0.7;
}
.effects-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.grain-pills {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  justify-content: flex-start;
}
.grain-btn {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.grain-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.grain-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .controls-bottom {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .looks-column {
    min-width: unset;
    max-width: unset;
  }
  .look-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  .upload-zone {
    max-width: 100%;
  }
}
@media (max-width: 600px) {
  #app { padding: 0; }

  .header {
    padding: 1rem 1rem 0.75rem;
    margin-bottom: 0;
  }
  .header h1 { font-size: 1.2rem; }
  .header p { font-size: 0.78rem; }

  /* Sticky preview on mobile */
  .upload-zone {
    position: sticky;
    top: 0;
    z-index: 50;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 0;
    margin-bottom: 0;
  }

  /* Scale overlay elements for mobile */
  .change-image-btn {
    font-size: 0.7rem;
    padding: 0.35rem 0.7rem;
    top: 0.5rem;
    right: 0.5rem;
  }
  .info-pill {
    width: 1.1rem;
    height: 1.1rem;
    font-size: 0.55rem;
  }
  .info-tooltip-wrap {
    bottom: 0.4rem;
    left: 0.4rem;
  }
  .info-tooltip {
    width: 260px;
    font-size: 0.6rem;
    padding: 0.5rem 0.65rem;
  }

  /* Controls below sticky preview */
  .controls {
    padding: 0.75rem 1rem 2rem;
  }

  .look-card { font-size: 0.65rem; padding: 0.4rem 0.2rem; }
  .slider-label { font-size: 0.68rem; min-width: 80px; }
  .slider-value { font-size: 0.65rem; min-width: 28px; }
  .grain-btn { font-size: 0.65rem; padding: 0.25rem 0.55rem; }
  .mode-btn { font-size: 0.62rem; padding: 0.3rem 0.6rem; }
}
