/* Internal tool, not a storefront surface — it borrows the KKL palette so the
   two do not feel like different projects, but nothing here is theme code. */
:root {
  color-scheme: light;
  --paper: #f8f8f6;
  --card: #fff;
  --well: #efefec;
  --ink-900: #1a1a18;
  --ink-700: #4a4a46;
  --ink-500: #7d7d77;
  --ink-300: #b6b6b0;
  --border-soft: #e2e2dd;
  --pink: #ff9ec6;
  --pink-deep: #d6538d;
  --ok: #2e794f;
  --bad: #cf4633;
  --mono: "Courier New", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-900);
  font: 400 14px/1.5 system-ui, sans-serif;
}

h1, h2 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1 { font-size: 15px; }
h2 { font-size: 11px; color: var(--ink-700); margin-block: 20px 8px; }
h2:first-child { margin-block-start: 0; }

code { font-family: var(--mono); font-size: 0.9em; }

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--card);
  border-block-end: 1.5px solid var(--ink-900);
  position: sticky;
  top: 0;
  z-index: 5;
}

.bar__note { margin: 0; color: var(--ink-500); font-size: 12px; }
.bar__actions { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }

.save-state { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--ink-500); }
.save-state[data-tone="dirty"] { color: var(--pink-deep); }
.save-state[data-tone="ok"] { color: var(--ok); }
.save-state[data-tone="bad"] { color: var(--bad); }

.btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border: 1.5px solid var(--ink-900);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink-900);
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: var(--well); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn--primary { background: var(--ink-900); color: var(--paper); }
.btn--primary:hover:not(:disabled) { background: var(--ink-700); }

:focus-visible { outline: none; box-shadow: 0 0 0 2px rgb(255 158 198 / 60%); }

.grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  gap: 1.5px;
  background: var(--border-soft);
  min-height: calc(100vh - 54px);
}

.panel, .stage { background: var(--paper); padding: 20px; min-width: 0; }

.hint { margin: 0 0 10px; font-size: 12px; color: var(--ink-500); }

.list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }

.list button {
  width: 100%;
  text-align: start;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
}

.list button[aria-current="true"] { border-color: var(--ink-900); }
.list button:hover { background: var(--well); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot--set { background: var(--ok); }
.dot--unset { background: var(--ink-300); }

.stage { display: flex; flex-direction: column; gap: 12px; }
.stage__bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.stage__title { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }

.zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-700);
  margin-inline-start: auto;
}

.zoom output { min-width: 44px; }

.viewport {
  flex: 1;
  min-height: 420px;
  border: 1.5px solid var(--ink-900);
  border-radius: 10px;
  background:
    repeating-conic-gradient(var(--well) 0% 25%, var(--card) 0% 50%) 0 0 / 16px 16px;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 40px;
}

.plate { position: relative; }
.plate img { display: block; image-rendering: pixelated; }

/* Crosshairs sit at their exact coordinate; the transform centres the mark on
   the point rather than on its own top-left corner. */
.anchor {
  position: absolute;
  z-index: 2;
  width: 21px;
  height: 21px;
  margin: -10px 0 0 -10px;
  cursor: grab;
  touch-action: none;
}

.anchor::before, .anchor::after {
  content: "";
  position: absolute;
  background: currentcolor;
}

.anchor::before { inset-block: 0; inset-inline-start: 10px; width: 1px; }
.anchor::after { inset-inline: 0; inset-block-start: 10px; height: 1px; }
.anchor--top { color: var(--pink-deep); }
.anchor--bottom { color: #3d68c9; }
.anchor:active { cursor: grabbing; }

.anchor__tag {
  position: absolute;
  inset-block-start: -14px;
  inset-inline-start: 14px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  background: var(--card);
  padding: 0 3px;
}

.body-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1.5px dashed var(--ink-900);
  background: rgb(255 158 198 / 12%);
  pointer-events: none;
  z-index: 1;
}

.body-overlay[data-shape="circle"] { border-radius: 50%; }

.body-overlay__tag {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 4px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-900);
}

.body-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 1.5px solid var(--ink-900);
  border-radius: 3px;
  background: var(--card);
  pointer-events: auto;
  touch-action: none;
}

.body-handle[hidden] { display: none; }
.body-handle--n { left: 50%; top: 0; cursor: ns-resize; }
.body-handle--s { left: 50%; top: 100%; cursor: ns-resize; }
.body-handle--e, .body-handle--r { left: 100%; top: 50%; cursor: ew-resize; }
.body-handle--w { left: 0; top: 50%; cursor: ew-resize; }

.check, .radios label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-700);
  margin-block-start: 12px;
}

.radios { display: flex; gap: 16px; }
.reference + .reference, .fields + .reference { margin-block-start: 12px; }

.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.facts dt { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ink-500); }
.facts dd { margin: 0; font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-block-start: 12px; }

.fields label, .reference {
  display: grid;
  gap: 4px;
  /* Grid items default to min-width:auto, and a number input's min-content
     width is far wider than this column — without this the panel overflows. */
  min-width: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-500);
}

.fields input, .reference select {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink-900);
}

.scale-check, .chain-check {
  border: 1.5px dashed var(--ink-300);
  border-radius: 8px;
  background: var(--card);
  padding: 12px;
  min-height: 90px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.scale-check { grid-auto-flow: column; gap: 16px; align-items: end; }
.scale-check figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
.scale-check figcaption { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; color: var(--ink-500); }
.scale-check img, .chain-check img { display: block; }

.chain-check__stack { position: relative; }
.chain-check__stack img { position: absolute; }

.validation { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.validation li {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.45;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.validation li[data-tone="ok"] { color: var(--ok); background: #e2f0e7; }
.validation li[data-tone="bad"] { color: var(--bad); background: #f9e2dd; }
.validation li[data-tone="warn"] { color: #8a610a; background: #f8eed6; }

/* ---------------------------------------------------- intake and publish */

[hidden] { display: none !important; }

a.btn { text-decoration: none; display: inline-block; }
.bar__actions form { margin: 0; }

.session-banner {
  position: fixed;
  inset-inline: 0;
  inset-block-start: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: #f9e2dd;
  border-block-end: 1.5px solid var(--bad);
  color: #b23624;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.session-banner a { color: var(--ink-900); }

.panel > .btn { width: 100%; }

.fields--stack { grid-template-columns: 1fr; }

.fields textarea, .fields select, .fields input[type="text"] {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink-900);
}

.fields textarea { resize: vertical; font-family: system-ui, sans-serif; }
.fields input[type="file"] { font-family: var(--mono); font-size: 11px; }
.fields [aria-invalid="true"] { border-color: var(--bad); }

.field-error { color: #b23624; font-size: 10px; letter-spacing: 0.04em; }
.field-error:empty { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 12px; }
.actions--end { justify-content: flex-end; }

.note, .sku-preview {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-700);
  overflow-wrap: anywhere;
}

.note:empty { display: none; }
.note[data-tone="ok"], .sku-preview[data-tone="ok"] { color: var(--ok); }
.note[data-tone="bad"], .sku-preview[data-tone="bad"] { color: #b23624; }
.sku-preview { padding: 8px 10px; border: 1.5px dashed var(--ink-300); border-radius: 6px; background: var(--well); }
.sku-preview[data-tone="idle"] { color: var(--ink-500); }

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 20px;
  border: 1.5px solid var(--ink-900);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink-900);
  box-shadow: 5px 7px 0 rgb(26 26 24 / 14%);
}

.dialog--wide { width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(26 26 24 / 35%); }
.dialog .facts { margin-block-end: 4px; }

.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; counter-reset: step; }

.steps li {
  counter-increment: step;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
  font-size: 12px;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-500);
}

.steps .chip {
  margin-inline-start: auto;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border: 1.5px solid currentcolor;
  border-radius: 4px;
  color: var(--ink-500);
}

.steps li[data-status="running"] .chip { color: #3b65c3; background: #e3eafa; }
.steps li[data-status="done"] .chip { color: var(--ok); background: #e2f0e7; }
.steps li[data-status="failed"] { border-color: var(--bad); }
.steps li[data-status="failed"] .chip { color: #b23624; background: #f9e2dd; }
.steps__error { flex-basis: 100%; margin: 0; font-family: var(--mono); font-size: 10px; color: #b23624; overflow-wrap: anywhere; }

.failure { margin-block-start: 12px; padding: 10px; border: 1.5px dashed var(--bad); border-radius: 8px; }
.failure .hint, .failure p { margin-block: 6px 0; }
.failure a { color: var(--pink-deep); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; }

/* ------------------------------------------------------ specimen intake */

.page { max-width: 720px; margin: 0 auto; padding: 20px; }
.page__form { display: grid; gap: 12px; align-content: start; }
.page__form h2 { margin-block-start: 8px; }
.fields__wide { grid-column: 1 / -1; }

.checks { display: grid; gap: 4px; max-height: 200px; overflow: auto; padding: 8px; border: 1.5px solid var(--border-soft); border-radius: 6px; background: var(--card); }
.checks:empty::before { content: "NONE AVAILABLE"; font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ink-500); }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.rows { display: grid; gap: 6px; }
.rows__row { display: flex; gap: 6px; align-items: center; }
.rows__row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink-900);
}
.rows__row .rows__label { flex: 0 0 38%; }
.options-bar { display: flex; align-items: center; gap: 12px; }
.options-bar .note { margin: 0; }
.checks[data-state="unavailable"]:empty::before { content: "UNAVAILABLE"; }

.btn--small { padding: 4px 8px; font-size: 10px; }

.thumbs { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumbs li { display: grid; gap: 6px; padding: 8px; border: 1.5px solid var(--border-soft); border-radius: 8px; background: var(--card); }
.thumbs li[data-featured="true"] { border-color: var(--ink-900); }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--well); border-radius: 4px; }
.thumbs__tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ink-500); overflow-wrap: anywhere; }
.thumbs li[data-featured="true"] .thumbs__tag { color: var(--pink-deep); font-weight: 700; }
.thumbs__bar { display: flex; gap: 4px; flex-wrap: wrap; }
.page__form > .btn { width: auto; justify-self: start; }
