:root {
  color-scheme: dark;
  --bg: #030405;
  --panel: rgba(16, 18, 22, 0.78);
  --panel-strong: rgba(24, 27, 33, 0.92);
  --stroke: rgba(255, 255, 255, 0.11);
  --text: #f5f7fb;
  --muted: #a6adba;
  --cyan: #18d9ff;
  --pink: #ff2d9d;
  --lime: #b9ff18;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 32% 12%, rgba(24, 217, 255, 0.12), transparent 26%),
    radial-gradient(circle at 82% 24%, rgba(255, 45, 157, 0.13), transparent 30%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 100vh;
}

.app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 20;
  border: 2px solid rgba(24, 217, 255, 0.78);
  box-shadow: inset 0 0 46px rgba(24, 217, 255, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out;
}

body.dragging-files .app::after {
  opacity: 1;
}

.stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #000;
}

.topbar {
  position: absolute;
  z-index: 4;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.brand {
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
  font-weight: 700;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.46);
  color: var(--text);
  backdrop-filter: blur(18px);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

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

.drop-zone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #000;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.drop-zone span {
  padding: 14px 18px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
}

.drop-zone.dragging span {
  border-color: rgba(24, 217, 255, 0.75);
  box-shadow: 0 0 36px rgba(24, 217, 255, 0.25);
}

.preview-shell {
  position: absolute;
  inset: 0;
  display: block;
  background: #000;
  overflow: hidden;
  touch-action: manipulation;
}

.preview-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  background: #000;
  opacity: 1;
  pointer-events: none;
  transition: opacity 120ms ease-out;
}

.preview-image.original {
  opacity: 0;
}

.preview-shell.show-original #processedPreview {
  opacity: 0;
}

.preview-shell.show-original #originalPreview {
  opacity: 1;
}

.compare-button {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
  padding: 10px 14px;
  cursor: pointer;
}

.busy {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(18px);
  color: var(--text);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}

.controls {
  border-left: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(28px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-row {
  display: grid;
  gap: 7px;
}

.control-row label,
.sliders span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

select {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 10px;
}

.meter {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.sliders {
  display: grid;
  gap: 18px;
}

.sliders label {
  display: grid;
  gap: 9px;
}

.sliders label span {
  display: flex;
  justify-content: space-between;
}

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

.hidden {
  display: none !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 1fr) auto;
  }

  .stage {
    min-height: 68vh;
  }

  .controls {
    border-left: 0;
    border-top: 1px solid var(--stroke);
  }
}
