:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-muted: #f1f3f9;
  --text: #17182b;
  --text-muted: #676b82;
  --border: #dfe3ee;
  --primary: #6d5dfc;
  --primary-hover: #5848ea;
  --primary-soft: #eeeaff;
  --shadow: 0 22px 70px rgba(32, 37, 72, 0.12);
  --radius: 22px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f18;
  --surface: rgba(25, 28, 43, 0.92);
  --surface-solid: #191c2b;
  --surface-muted: #23273a;
  --text: #f7f7fb;
  --text-muted: #aeb3c8;
  --border: #34394f;
  --primary: #8c7cff;
  --primary-hover: #a294ff;
  --primary-soft: #292344;
  --shadow: 0 25px 80px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(109, 93, 252, .14), transparent 30rem),
    radial-gradient(circle at 88% 8%, rgba(80, 178, 255, .12), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }

button, select, input[type="range"] { accent-color: var(--primary); }

button { cursor: pointer; }

img { max-width: 100%; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(18px, 5vw, 72px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.08rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #47b5ff);
  color: #fff;
  font-size: 1.15rem;
}

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

.engine-badge {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 700;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.hero {
  max-width: 780px;
  margin: 20px auto 42px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--primary);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .14em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -.055em;
}

.hero-copy {
  max-width: 690px;
  margin: 22px auto 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.7;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.workspace { padding: clamp(18px, 3vw, 30px); }

.workspace-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.workspace-heading h2,
.disclosure h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.workspace-heading p,
.disclosure p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 430px;
  padding: 36px;
  border: 2px dashed var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 50%, transparent), transparent);
  text-align: center;
  transition: .2s ease;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 24px;
  margin-bottom: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 2rem;
  font-weight: 300;
}

.drop-zone h3 { margin: 0; font-size: 1.35rem; }
.drop-zone p { margin: 8px 0 20px; color: var(--text-muted); }
.drop-zone small { margin-top: 14px; color: var(--text-muted); }

.button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: .18s ease;
}

.button:disabled { opacity: .48; cursor: not-allowed; }

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

.button-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }

.button-secondary {
  border-color: var(--border);
  background: var(--surface-solid);
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.button-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.button-wide { width: 100%; }

.editor {
  display: grid;
  grid-template-columns: 275px minmax(0, 1fr);
  gap: 24px;
}

.controls-panel {
  padding: 20px;
  border-radius: 17px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.control-group { margin-bottom: 18px; }

.control-group label {
  display: block;
  margin-bottom: 8px;
  font-size: .86rem;
  font-weight: 800;
}

.label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.label-row output {
  color: var(--primary);
  font-size: .82rem;
  font-weight: 800;
}

select {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-solid);
  color: var(--text);
}

input[type="range"] { width: 100%; }

.stats {
  display: grid;
  gap: 8px;
  margin: 22px 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
}

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.stats span { color: var(--text-muted); font-size: .78rem; }
.stats strong { font-size: .8rem; text-align: right; }

.controls-panel .button + .button { margin-top: 10px; }

.fine-print {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: .75rem;
  line-height: 1.55;
}

.preview-panel { min-width: 0; }

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  margin-bottom: 10px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.segment {
  padding: 7px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 800;
}

.segment.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 3px 12px rgba(0,0,0,.08);
}

#zoomReadout { color: var(--text-muted); font-size: .8rem; }

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 17px;
  background:
    linear-gradient(45deg, var(--surface-muted) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(-45deg, var(--surface-muted) 25%, transparent 25%) 0 11px / 22px 22px,
    linear-gradient(45deg, transparent 75%, var(--surface-muted) 75%) 11px -11px / 22px 22px,
    linear-gradient(-45deg, transparent 75%, var(--surface-muted) 75%) -11px 0 / 22px 22px,
    var(--surface-solid);
}

.empty-preview { color: var(--text-muted); }

.comparison {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 540px;
  user-select: none;
}

.comparison > img,
.after-layer img,
.single-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.comparison > img {
  position: absolute;
  inset: 0;
}

.after-layer {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
}

.after-layer img {
  position: absolute;
  inset: 0;
  max-width: none;
  width: var(--comparison-width, 100%);
}

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  pointer-events: none;
}

.compare-handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  color: #222;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
}

.compare-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.image-label {
  position: absolute;
  top: 14px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
}

.label-before { left: 14px; }
.label-after { right: 14px; }

.single-preview {
  min-height: 540px;
  object-fit: contain;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.progress-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #49b8ff);
  transition: width .2s ease;
}

.progress-wrap span {
  min-width: 100px;
  color: var(--text-muted);
  font-size: .78rem;
  text-align: right;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 24px 0;
}

.feature-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.feature-card > span { font-size: 1.45rem; }
.feature-card h3 { margin: 12px 0 7px; font-size: 1rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: .9rem; line-height: 1.6; }

.disclosure { padding: 22px; box-shadow: none; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .8rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(380px, calc(100% - 44px));
  padding: 13px 15px;
  border-radius: 12px;
  background: #181a27;
  color: #fff;
  box-shadow: 0 12px 35px rgba(0,0,0,.25);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

.hidden { display: none !important; }

@media (max-width: 880px) {
  .editor { grid-template-columns: 1fr; }
  .controls-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .stats, .controls-panel .button, .fine-print { grid-column: 1 / -1; }
  .feature-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-shell { width: min(100% - 20px, 1180px); padding-top: 30px; }
  .site-header { padding: 12px 14px; }
  .engine-badge { display: none; }
  .workspace-heading { align-items: flex-start; }
  .drop-zone { min-height: 350px; padding: 24px 16px; }
  .controls-panel { grid-template-columns: 1fr; }
  .stats, .controls-panel .button, .fine-print { grid-column: auto; }
  .preview-stage, .comparison, .single-preview { min-height: 390px; }
  footer { flex-direction: column; width: calc(100% - 28px); }
}
