:root {
  color-scheme: dark;
  --ink: #141412;
  --panel: #1c1c19;
  --panel-raised: #25241f;
  --line: #38372f;
  --line-strong: #565246;
  --text: #f1efe8;
  --muted: #a9a69c;
  --quiet: #77746b;
  --accent: #d6ad62;
  --accent-strong: #edc77d;
  --danger: #d98272;
  --radius: 10px;
  --topbar-height: 70px;
  --rail-width: 350px;
  --layer-nav: 20;
  --layer-toast: 40;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-synthesis: none;
  scrollbar-color: var(--line-strong) var(--ink);
  scrollbar-width: thin;
}

* {
  box-sizing: border-box;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--ink);
}

*::-webkit-scrollbar-thumb {
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--line-strong);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

html {
  background: var(--ink);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--ink);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
.drop-zone:focus-within {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--layer-nav);
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  padding: 0 24px;
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  width: 22px;
  aspect-ratio: 1;
  border: 1px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px var(--ink), inset 0 0 0 6px color-mix(in srgb, var(--accent) 75%, transparent);
}

.top-actions,
.view-switch,
.image-meta {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 10px;
}

.privacy-note {
  margin-right: 10px;
  color: var(--quiet);
  font-size: 12px;
}

.button,
.text-button,
.view-switch button,
.preset {
  cursor: pointer;
}

.button {
  min-height: 38px;
  border-radius: var(--radius);
  padding: 0 15px;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.button:active,
.preset:active,
.text-button:active,
.view-switch button:active {
  transform: translateY(1px);
}

.button-ghost {
  border: 1px solid var(--line);
  background: transparent;
}

.button-ghost:hover {
  border-color: var(--line-strong);
  background: var(--panel);
}

.button-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #17140f;
}

.button-primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.workspace {
  display: grid;
  min-height: calc(100dvh - var(--topbar-height));
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
}

.control-rail {
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.rail-section {
  border-bottom: 1px solid var(--line);
  padding: 22px 24px;
}

.project-heading {
  padding-top: 32px;
  padding-bottom: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 310px;
  margin-bottom: 15px;
  font-family: "Helvetica Neue", Helvetica, sans-serif;
  font-size: clamp(31px, 3vw, 42px);
  font-weight: 300;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.intro {
  max-width: 31ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.section-heading {
  display: flex;
  min-height: 24px;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.section-heading > span,
.text-button {
  color: var(--quiet);
  font-size: 11px;
}

.text-button {
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0;
}

.text-button:hover {
  color: var(--accent-strong);
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 92px;
  cursor: pointer;
  place-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--ink);
  padding: 16px;
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--ink));
}

.drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

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

.drop-detail {
  margin-top: 4px;
  color: var(--quiet);
  font-size: 11px;
}

.field-message {
  min-height: 18px;
  margin: 8px 0 -8px;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
}

.preset-grid {
  display: grid;
  gap: 8px;
}

.preset {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  padding: 0 13px;
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease;
}

.preset span {
  font-size: 12px;
  font-weight: 600;
}

.preset small {
  color: var(--quiet);
  font-size: 10px;
}

.preset:hover {
  border-color: var(--line-strong);
}

.preset.active {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.preset.active small {
  color: var(--accent-strong);
}

.adjustments {
  padding-bottom: 30px;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
}

.control output {
  min-width: 25px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}

.control input {
  grid-column: 1 / -1;
  width: 100%;
  height: 18px;
  cursor: pointer;
  appearance: none;
  background: transparent;
}

.control input::-webkit-slider-runnable-track,
.comparison-input::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-strong);
}

.control input::-webkit-slider-thumb,
.comparison-input::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -6px;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent-strong);
}

.image-workspace {
  display: grid;
  min-width: 0;
  grid-template-rows: auto minmax(520px, 1fr) auto;
  background: #10100f;
}

.stage-toolbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 9px 20px;
}

.view-switch {
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 3px;
}

.view-switch button {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 0 12px;
  color: var(--quiet);
  font-size: 11px;
}

.view-switch button:hover {
  color: var(--text);
}

.view-switch button.active {
  background: var(--panel-raised);
  color: var(--text);
}

.image-meta {
  gap: 12px;
  color: var(--quiet);
  font-size: 10px;
}

.image-meta span + span::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 10px;
  margin-right: 12px;
  background: var(--line);
  vertical-align: -1px;
}

.image-stage {
  position: relative;
  display: grid;
  min-height: 520px;
  overflow: hidden;
  place-items: center;
  background-color: #0e0e0d;
  background-image:
    linear-gradient(45deg, #121211 25%, transparent 25%),
    linear-gradient(-45deg, #121211 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #121211 75%),
    linear-gradient(-45deg, transparent 75%, #121211 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  padding: 28px 34px 46px;
}

.comparison {
  position: relative;
  width: min(100%, 1320px);
  overflow: hidden;
  border-radius: 2px;
  background: #0a0a09;
  box-shadow: 0 22px 70px rgb(0 0 0 / 0.35);
}

.comparison::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  border: 1px solid rgb(255 255 255 / 0.08);
  pointer-events: none;
}

.base-image,
.after-layer img {
  display: block;
  width: 100%;
  max-height: calc(100dvh - 238px);
  object-fit: contain;
}

.after-layer {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  bottom: 0;
  width: 42%;
  overflow: hidden;
}

.after-layer img {
  position: absolute;
  top: 0;
  right: 0;
  width: auto;
  min-width: var(--image-width, 100%);
  max-width: none;
  height: 100%;
}

.comparison-rule {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  left: 58%;
  width: 1px;
  background: rgb(255 255 255 / 0.8);
  pointer-events: none;
}

.comparison-rule span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  border: 1px solid rgb(255 255 255 / 0.55);
  border-radius: 50%;
  background: rgb(19 19 17 / 0.82);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.26);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(9px);
}

.comparison-rule span::before,
.comparison-rule span::after {
  content: "";
  position: absolute;
  top: 12px;
  width: 7px;
  height: 7px;
  border-top: 1px solid var(--text);
  border-left: 1px solid var(--text);
}

.comparison-rule span::before {
  left: 7px;
  transform: rotate(-45deg);
}

.comparison-rule span::after {
  right: 7px;
  transform: rotate(135deg);
}

.comparison-input {
  position: absolute;
  z-index: 7;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: ew-resize;
  opacity: 0;
}

.stage-caption {
  position: absolute;
  right: 36px;
  bottom: 18px;
  left: 36px;
  display: flex;
  justify-content: space-between;
  color: var(--quiet);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.processing-state {
  position: absolute;
  z-index: 12;
  display: grid;
  visibility: hidden;
  width: min(360px, calc(100% - 48px));
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(24 24 21 / 0.92);
  padding: 24px;
  opacity: 0;
  transition: opacity 180ms ease;
  backdrop-filter: blur(16px);
}

.processing-state.visible {
  visibility: visible;
  opacity: 1;
}

.processing-state p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.processing-line {
  width: 100%;
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.processing-line::after {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  background: var(--accent);
  animation: process 1s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

.analysis-strip {
  display: grid;
  min-height: 76px;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.4fr) minmax(0, 1.1fr);
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.raw-export-button {
  margin-top: 16px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text);
}

.raw-export-button:hover:not(:disabled) { border-color: var(--accent); }
.raw-export-button:disabled { opacity: .45; cursor: not-allowed; }
.raw-export-help { color: var(--muted); font-size: 11px; line-height: 1.5; min-height: 50px; }
#rawDownloadLink[hidden] { display: none; }
#rawDownloadLink { display: inline-block; margin-top: 8px; }

.analysis-strip > div {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 5px;
  border-right: 1px solid var(--line);
  padding: 13px 20px;
}

.analysis-strip > div:last-child {
  border-right: 0;
}

.analysis-label {
  color: var(--quiet);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.analysis-strip strong {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confidence strong {
  color: var(--accent-strong);
  white-space: normal;
}

.toast {
  position: fixed;
  z-index: var(--layer-toast);
  right: 20px;
  bottom: 20px;
  visibility: hidden;
  max-width: 320px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-raised);
  padding: 13px 15px;
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@keyframes process {
  from { transform: translateX(-10%); }
  to { transform: translateX(150%); }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .privacy-note {
    display: none;
  }

  .analysis-strip {
    grid-template-columns: 1fr 1fr;
  }

  .analysis-strip .confidence {
    display: grid;
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }

  .button-ghost,
  .image-meta,
  .project-heading {
    display: none;
  }

  .workspace {
    display: flex;
    min-height: calc(100dvh - var(--topbar-height));
    flex-direction: column-reverse;
  }

  .control-rail {
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .image-workspace {
    grid-template-rows: auto auto auto;
  }

  .stage-toolbar {
    padding-inline: 16px;
  }

  .image-stage {
    min-height: auto;
    padding: 18px 16px 40px;
  }

  .base-image,
  .after-layer img {
    max-height: 62dvh;
  }

  .analysis-strip {
    grid-template-columns: 1fr;
  }

  .analysis-strip > div:nth-child(2) {
    display: none;
  }

  .rail-section {
    padding-inline: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  * {
    scrollbar-color: auto;
  }
}

[hidden] { display: none !important; }
dialog { max-width: min(460px,calc(100vw - 32px)); border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--text); background: var(--panel); padding: 24px; }
dialog::backdrop { background: rgb(0 0 0 / .7); }
dialog h2 { font-size: 18px; }
dialog p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.button:disabled,button:disabled,input:disabled,select:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.field-message { min-height: 48px; margin-bottom: 4px; color: var(--muted); }
.select-label,summary { color: var(--text); font-size: 13px; }
summary { cursor: pointer; padding: 8px 0; }
summary:hover { color: var(--accent-strong); }
summary:focus-visible,select:focus-visible,a:focus-visible,.recipe-import:focus-within { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
select,.coordinate-grid input { width: 100%; min-width: 0; min-height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 9px; color: var(--text); background: var(--ink); font: inherit; }
select { cursor: pointer; margin-top: 8px; font-size: 12px; }
.coordinate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.coordinate-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.recipe-actions { display: flex; gap: 20px; align-items: center; }
.recipe-import { position: relative; color: var(--muted); font-size: 11px; min-height: 32px; display: grid; align-items: center; cursor: pointer; }
.recipe-import input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.recipe-import:hover { color: var(--accent-strong); }
.correction-list { display: grid; margin-top: 10px; }
.review-section h2 { font-size: 13px; }
#reviewStatus { font-size: 12px; color: var(--accent-strong); }
#downloadLink,#rawDownloadLink { display: block; overflow-wrap: anywhere; margin-top: 12px; }
.image-workspace { position: sticky; top: var(--topbar-height); align-self: start; height: calc(100dvh - var(--topbar-height)); grid-template-rows: auto minmax(240px,1fr) auto; }
.image-stage { min-height: 240px; }
.text-button,.drop-detail,.preset small,.image-meta,.analysis-label,.view-switch button { color: var(--muted); }
@media(max-width:760px) {
 .topbar { flex-wrap: wrap; gap: 8px; padding: 12px 16px; position: relative; }
 .top-actions { flex-wrap: wrap; gap: 6px; }
 .top-actions .button-ghost,.rail-section .button-ghost { display: inline-block; }
 .top-actions .button { padding-inline: 9px; font-size: 11px; }
 .image-workspace { position: relative; top: auto; height: auto; }
}
