:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #ebe7de;
  --text: #171717;
  --muted: #68645c;
  --line: #d9d4c8;
  --accent: #116466;
  --accent-2: #d95d39;
  --shadow: 0 18px 60px rgba(20, 20, 20, 0.12);
}

:root.dark {
  color-scheme: dark;
  --bg: #151719;
  --surface: #202326;
  --surface-2: #2d3235;
  --text: #f4f1e9;
  --muted: #b8b2a6;
  --line: #3a3f42;
  --accent: #52c7b8;
  --accent-2: #ff8a5b;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.topbar,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
}

h2 {
  font-size: 22px;
}

.restore-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  align-items: start;
}

.control-panel,
.preview-panel,
.status-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.panel-section {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 128px;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

.dropzone {
  position: relative;
  min-height: 170px;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  cursor: pointer;
  padding: 24px;
}

.dropzone.dragging {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 30px;
  line-height: 1;
}

.drop-title {
  color: var(--text);
  font-size: 17px;
}

.drop-copy,
.file-meta,
.log-list {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.hint-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.file-meta {
  min-height: 20px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.primary-button,
.download-button,
.icon-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.primary-button {
  min-height: 48px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

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

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

.download-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--accent-2);
  color: white;
  font-weight: 800;
  padding: 0 16px;
}

.download-button.secondary {
  background: var(--accent);
}

.download-button.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.preview-panel {
  padding: 18px;
}

.compare-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

figure {
  margin: 0;
}

figcaption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.image-frame {
  position: relative;
  display: grid;
  min-height: 460px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 60%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 60%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 60%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 60%, transparent) 75%);
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
}

.image-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-frame.has-image img {
  display: block;
}

.image-frame.has-image .empty-state {
  display: none;
}

.empty-state {
  color: var(--muted);
  font-weight: 800;
}

.status-card {
  margin-top: 14px;
  padding: 14px;
}

#statusText {
  font-weight: 800;
}

.result-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.log-list {
  display: grid;
  gap: 5px;
  margin: 12px 0 0;
  padding-left: 18px;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 18px;
  }

  .restore-grid,
  .compare-stage {
    grid-template-columns: 1fr;
  }

  .image-frame {
    min-height: 320px;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 36px;
  }

  .topbar,
  .preview-toolbar,
  .two-col {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    display: grid;
  }

  .download-actions {
    justify-content: stretch;
  }
}
