:root {
  color-scheme: light;
  --ink: #10211c;
  --muted: #5b6f69;
  --paper: #f3faf7;
  --panel: #ffffff;
  --line: #d5e6df;
  --accent: #0d9488;
  --accent-dark: #0f766e;
  --lime: #99f6e4;
  font-family:
    "Noto Sans SC", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 0, #d9f3ea 0, transparent 29rem),
    var(--paper);
}

button,
select,
input {
  font: inherit;
}

button,
.link-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background 160ms ease;
}

button:hover:not(:disabled),
.link-button:hover {
  transform: translateY(-1px);
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.credit-badge {
  padding: 7px 12px;
  border-radius: 999px;
  background: #e6f7f3;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.brand small {
  margin-left: 5px;
  color: var(--accent);
  font-size: 0.68em;
  text-transform: uppercase;
}

.local-badge {
  padding: 7px 11px;
  border: 1px solid #a8bb68;
  border-radius: 999px;
  background: #edf8cd;
  font-size: 12px;
  font-weight: 700;
}

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

.header-actions .sample-button {
  margin: 0;
  width: auto;
  white-space: nowrap;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.intro {
  padding: 70px 0 50px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-family: inherit;
  font-size: clamp(44px, 7vw, 82px);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.94;
}

h1 em {
  color: var(--accent);
  font-weight: inherit;
}

.lede {
  max-width: 650px;
  margin: 27px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 610px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(16, 33, 28, 0.06);
}

.panel {
  padding: 25px;
  border-right: 1px solid var(--line);
}

.step-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 5px 0 13px;
  font-size: 13px;
  font-weight: 800;
}

.step-label:not(:first-child) {
  margin-top: 27px;
}

.step-label span {
  color: var(--accent);
  font-family: inherit;
  font-size: 15px;
}

.dropzone {
  display: grid;
  min-height: 115px;
  padding: 22px;
  place-content: center;
  border: 1.5px dashed #aaa69a;
  border-radius: 12px;
  background: #f8f6ef;
  text-align: center;
  cursor: pointer;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: #fff0e8;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone strong {
  font-size: 14px;
}

.dropzone span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.sample-button {
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.button-row,
.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.primary,
.secondary,
.ghost,
.link-button {
  min-height: 42px;
  padding: 11px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.primary {
  color: white;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent-dark);
}

.secondary {
  color: var(--ink);
  background: var(--lime);
  box-shadow: inset 0 -2px 0 #9cbd3e;
}

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

.controls > .primary {
  width: 100%;
  margin-top: 25px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.controls > label:not(.dropzone, .check-line) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 11px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  max-width: 135px;
  padding: 7px 29px 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  font-size: 12px;
  font-weight: 700;
}

.color-row.is-disabled {
  opacity: 0.42;
}

.status {
  min-height: 32px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.status.is-error {
  color: #b12512;
}

.status.is-analyzing {
  color: var(--accent-dark);
  animation: status-pulse 1.2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.canvas-wrap.is-analyzing #selectionCanvas {
  outline: 2px solid rgb(233 80 43 / 35%);
  outline-offset: 4px;
}

.ocr-summary {
  display: grid;
  gap: 5px;
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8f6ef;
  color: var(--muted);
  font-size: 11px;
}

.ocr-summary strong {
  color: var(--ink);
  font-size: 18px;
  font-family: inherit;
}

.removal-controls {
  margin-top: 20px;
  padding-top: 3px;
  border-top: 1px solid var(--line);
}

.removal-controls > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.removal-controls .primary {
  width: 100%;
}

.removal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.removal-actions .sample-button {
  margin: 0;
  padding-inline: 8px;
  font-size: 10px;
}

#removalMeta {
  display: block;
  min-height: 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.layer-panel {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 0;
  padding: 22px 22px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.layer-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.layer-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fbfaf5;
}

.layer-card.is-busy {
  opacity: 0.72;
}

.layer-card.is-selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.layer-card.is-dirty {
  border-color: #b9892d;
}

.layer-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}

.layer-compare-item {
  display: grid;
  gap: 4px;
}

.layer-compare-item span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.layer-thumb {
  width: 100%;
  height: 72px;
  object-fit: contain;
  background:
    linear-gradient(45deg, #ece8dc 25%, transparent 25%) 0 0 / 10px 10px,
    linear-gradient(-45deg, #ece8dc 25%, transparent 25%) 0 5px / 10px 10px,
    #fff;
  border: 1px solid var(--line);
}

.layer-card-body {
  min-width: 0;
}

.layer-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.layer-card-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.layer-card-head small {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

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

.layer-params .preset-field {
  grid-column: 1 / -1;
}

.layer-params .preset-hint {
  grid-column: 1 / -1;
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.45;
}

.layer-params label {
  position: relative;
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.layer-params .param-caption {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.layer-params .param-tip {
  display: inline-grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d9d6ca;
  color: #4d4d45;
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.layer-params label[data-tip].is-tip-visible::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 8;
  left: 0;
  bottom: calc(100% + 6px);
  width: min(260px, 70vw);
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #1f1f1a;
  color: #f7f4ea;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 8px 20px rgb(0 0 0 / 18%);
  pointer-events: none;
}

.layer-params input[type='number'],
.layer-params select {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.layer-params .toggle-field {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}

.layer-params .toggle-field input {
  width: auto;
}

.layer-actions {
  margin-top: 10px;
}

.layer-actions .layer-recompute {
  width: 100%;
  margin: 0;
}

.layer-status {
  display: block;
  margin-top: 8px;
  color: #315800;
  font-size: 10px;
  min-height: 14px;
}

@media (max-width: 760px) {
  .layer-card {
    grid-template-columns: 1fr;
  }

  .layer-params {
    grid-template-columns: 1fr 1fr;
  }
}

.final-controls {
  margin-top: 18px;
  padding-top: 3px;
  border-top: 1px solid var(--line);
}

.final-controls > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.final-controls .secondary {
  width: 100%;
}

#psdMeta {
  display: block;
  min-height: 16px;
  margin-top: 8px;
  color: #315800;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.stage-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: #ebe8df;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  font-size: 11px;
  font-weight: 700;
}

.stage-empty {
  display: grid;
  flex: 1;
  place-content: center;
  color: #969287;
  text-align: center;
}

.stage-empty span {
  display: grid;
  width: 64px;
  height: 64px;
  margin: auto;
  place-items: center;
  border: 1px solid #bdb9ad;
  border-radius: 50%;
  font-family: inherit;
  font-size: 31px;
}

.canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 28px;
  touch-action: none;
}

#selectionCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: auto;
  border: 1px solid #c0bcb1;
  background: white;
  box-shadow: 0 12px 30px rgb(35 34 29 / 16%);
  cursor: default;
}

.ocr-results {
  margin: 90px 0;
  padding-top: 55px;
  border-top: 1px solid var(--line);
}

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

.results-heading h2 {
  margin: 0;
  font-family: inherit;
  font-size: 46px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.results-note {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-list {
  display: grid;
  gap: 8px;
}

.result-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 170px;
  gap: 15px;
  align-items: center;
  width: 100%;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

.result-item.is-appearing {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 220ms ease,
    transform 220ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.result-item.is-appearing.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.result-item:hover,
.result-item.is-selected {
  border-color: #1269d3;
  background: #f0f6ff;
}

.result-item.is-edited {
  border-left: 4px solid #1269d3;
}

.result-number {
  color: var(--accent);
  font-family: inherit;
  font-size: 18px;
}

.result-content {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.text-editor {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font-size: 15px;
  font-weight: 700;
}

.text-editor:focus {
  border-color: #1269d3;
  outline: 3px solid rgb(18 105 211 / 13%);
}

.geometry-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.geometry-editor label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.geometry-editor input[type="number"] {
  width: 62px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font-size: 11px;
}

.geometry-editor .color-field {
  margin-left: 3px;
}

.geometry-editor input[type="color"] {
  width: 30px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.geometry-editor .color-field span {
  min-width: 52px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
}

.record-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 13px;
}

.record-metadata small {
  color: var(--muted);
  font-size: 10px;
}

.record-metadata .edit-state {
  color: #1269d3;
  font-weight: 800;
}

.record-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.locate-button,
.delete-button {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}

.locate-button {
  color: #104f9b;
  background: #dcecff;
}

.delete-button {
  color: #9d2614;
  background: #ffe2db;
}

.confidence {
  min-width: 54px;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.confidence.high {
  color: #315800;
  background: #dcf49b;
}

.confidence.medium {
  color: #855100;
  background: #ffe2a2;
}

.confidence.low {
  color: #8a2818;
  background: #ffd0c6;
}

.result-empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.result {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 60px;
  align-items: center;
  margin: 95px 0;
  padding-top: 60px;
  border-top: 1px solid var(--line);
}

.result h2 {
  margin: 0 0 15px;
  font-family: inherit;
  font-size: 46px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.result p {
  color: var(--muted);
  line-height: 1.6;
}

.preview-frame {
  padding: 14px;
  border: 1px solid var(--ink);
  border-radius: 14px;
  background: var(--panel);
}

.checkerboard {
  display: grid;
  min-height: 330px;
  place-items: center;
  overflow: auto;
  border-radius: 8px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

#svgPreview {
  display: block;
  max-width: 100%;
  max-height: 520px;
}

.preview-frame > p {
  margin: 10px 3px 0;
  font-size: 11px;
}

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 25px 0 45px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 800px) {
  .site-header,
  main,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .local-badge {
    display: none;
  }

  .intro {
    padding-top: 48px;
  }

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

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage-panel {
    min-height: 430px;
  }

  .result {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .results-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .record-item-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}
