:root {
  color-scheme: dark;
  --bg: #070912;
  --panel: rgba(18, 24, 42, 0.72);
  --panel-strong: rgba(23, 31, 55, 0.88);
  --text: #f7f8ff;
  --muted: #a9b0c7;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #2ee6a6;
  --accent-2: #35a7ff;
  --danger: #ff5d73;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --radius: 18px;
  --font-body: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Poppins", var(--font-body);
}

body.light-theme {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --text: #111827;
  --muted: #5f6b83;
  --line: rgba(17, 24, 39, 0.12);
  --shadow: 0 24px 70px rgba(52, 78, 112, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(46, 230, 166, 0.18), transparent 28%),
    radial-gradient(circle at 82% 8%, rgba(53, 167, 255, 0.16), transparent 30%),
    linear-gradient(145deg, var(--bg), #101526 58%, var(--bg));
  color: var(--text);
  font-family: var(--font-body);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.workspace,
.section-heading,
.card-top,
.card-actions,
.upload-meta,
.settings-header,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #061018;
  font-family: var(--font-display);
  font-weight: 800;
  box-shadow: 0 0 30px rgba(46, 230, 166, 0.28);
}

.brand strong,
h1,
h2 {
  font-family: var(--font-display);
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  align-items: flex-start;
  gap: 22px;
}

.studio {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-copy {
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 5.2rem);
  line-height: 0.98;
}

.hero-copy p {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

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

.upload-card {
  padding: 16px;
}

.drop-zone {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 150px;
  padding: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.26);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(46, 230, 166, 0.09), rgba(53, 167, 255, 0.08));
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.drop-zone:hover,
.drop-zone.drag-over,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(46, 230, 166, 0.15), rgba(53, 167, 255, 0.13));
  outline: none;
  transform: translateY(-2px);
}

.drop-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent);
  font-size: 2.4rem;
}

.drop-zone h2,
.settings-panel h2,
.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.drop-zone p,
.settings-note span,
.toggle-row small {
  color: var(--muted);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 999px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0 18px;
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111a;
  box-shadow: 0 12px 34px rgba(46, 230, 166, 0.24);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.icon-button {
  display: grid;
  width: 42px;
  min-width: 42px;
  place-items: center;
  padding: 0;
  font-weight: 900;
}

button:not(:disabled):hover {
  transform: translateY(-2px);
}

.upload-meta {
  justify-content: space-between;
  gap: 12px;
  padding: 12px 6px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 14px;
}

.section-heading.compact {
  margin: 0 0 12px;
}

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 32px;
  text-align: center;
}

.empty-state span {
  color: var(--muted);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.image-card {
  overflow: hidden;
  padding: 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.image-card:hover,
.image-card:focus-visible {
  border-color: rgba(46, 230, 166, 0.55);
  outline: none;
  transform: translateY(-2px);
}

.image-card.is-selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(46, 230, 166, 0.14), rgba(53, 167, 255, 0.08));
}

.card-top {
  gap: 12px;
  margin-bottom: 10px;
}

.thumb {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

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

.file-name,
.file-size {
  display: block;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.83rem;
}

.focus-preview {
  margin-bottom: 14px;
  padding: 16px;
}

.focus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.focus-file {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.focus-file img {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.focus-file strong,
.focus-file span {
  display: block;
}

.focus-file strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-file span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.focus-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.comparison {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  --compare: 50%;
}

.focus-comparison {
  aspect-ratio: 16 / 9;
  max-height: 560px;
}

.comparison::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--compare);
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(46, 230, 166, 0.55);
  content: "";
  pointer-events: none;
}

.before-img,
.after-layer,
.svg-preview,
.svg-preview svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.before-img,
.svg-preview svg {
  object-fit: contain;
}

.before-img {
  padding: 12px;
}

.after-layer {
  overflow: hidden;
  clip-path: inset(0 calc(100% - var(--compare)) 0 0);
  background: rgba(7, 9, 18, 0.78);
}

body.light-theme .after-layer {
  background: rgba(255, 255, 255, 0.78);
}

.svg-preview svg {
  padding: 12px;
}

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

.preview-label {
  position: absolute;
  top: 10px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.44);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.preview-label.before {
  left: 10px;
}

.preview-label.after {
  right: 10px;
}

.progress-wrap {
  margin: 10px 0;
}

.progress-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 220ms ease;
}

.progress-text {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.card-actions {
  justify-content: space-between;
  gap: 10px;
}

.card-actions button {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.image-card .remove-btn {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
}

.settings-panel {
  position: sticky;
  top: 18px;
  width: 360px;
  flex: 0 0 360px;
  padding: 20px;
}

.settings-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.live-pill {
  border: 1px solid rgba(46, 230, 166, 0.32);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
}

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

.control-group label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 800;
}

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

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0 12px;
  font-weight: 800;
  outline: none;
}

select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 230, 166, 0.18);
}

.control-stack {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row small {
  margin-top: 4px;
  line-height: 1.4;
}

.toggle-row input {
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.settings-note {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(46, 230, 166, 0.22);
  border-radius: 16px;
  background: rgba(46, 230, 166, 0.08);
  line-height: 1.5;
}

.history-panel {
  margin-top: 18px;
  padding: 18px;
}

.history-list {
  display: grid;
  gap: 8px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.moon {
  display: none;
}

body.light-theme .sun {
  display: none;
}

body.light-theme .moon {
  display: inline;
}

@media (max-width: 1120px) {
  .workspace {
    display: block;
  }

  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-panel {
    position: static;
    width: 100%;
    margin-top: 22px;
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar,
  .drop-zone {
    align-items: stretch;
  }

  .topbar,
  .drop-zone,
  .section-heading {
    flex-direction: column;
  }

  .drop-zone {
    display: flex;
  }

  .top-actions,
  .section-heading,
  .upload-meta {
    width: 100%;
  }

  .top-actions > button,
  .section-heading > button {
    flex: 1;
  }

  .image-grid {
    grid-template-columns: 1fr;
  }

  .focus-header,
  .focus-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .focus-comparison {
    aspect-ratio: 4 / 3;
  }

  .upload-meta,
  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
