:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #66727e;
  --line: #ccd5dc;
  --panel: #ffffff;
  --page: #f4f7f8;
  --accent: #1f7a5c;
  --danger: #b13a32;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 760;
}

.heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.heading p {
  max-width: 760px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.viewTabs,
.segmentedControl,
.faceButtons,
.labelerActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewTab,
.segmentedControl button,
.faceButtons button,
.labelerActions button,
.labelerJsonPanel button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fbfcfc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.viewTab.is-active,
.segmentedControl button.is-active,
.faceButtons button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.panel,
.result,
.batchResults {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

form {
  display: grid;
  gap: 14px;
}

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

.dropZone {
  min-height: 112px;
  align-content: center;
  justify-items: center;
  border: 1px dashed #91a5b1;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.dropZone:hover {
  border-color: var(--accent);
}

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

.dropZoneTitle {
  font-weight: 760;
  color: var(--ink);
  font-size: 14px;
}

.dropZoneHint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.dropZoneFiles {
  display: grid;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
  width: 100%;
  margin-top: 4px;
}

.dropZoneFiles:empty {
  display: none;
}

.manualOverride {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fbfcfc;
}

.manualOverride[open] {
  padding-bottom: 10px;
}

.manualOverride > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  padding: 4px 0;
  list-style: none;
}

.manualOverride > summary::marker,
.manualOverride > summary::-webkit-details-marker {
  display: none;
}

.manualOverride > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.12s ease;
}

.manualOverride[open] > summary::before {
  content: "▾ ";
}

.manualOverride label {
  margin-top: 8px;
}

.recentRuns {
  margin-top: 18px;
}

.recentRunsHint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.recentRunsRow {
  cursor: pointer;
}

.recentRunsRow:hover td {
  background: #eef8f4;
}

.recentRunsRow:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.recentRuns .resultHeader button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
}

input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfc;
  color: var(--ink);
}

input[type="text"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfc;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
}

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

.resultHeader {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

h2 {
  font-size: 18px;
}

#state {
  display: block;
  min-height: 34px;
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #eff4f2;
  overflow-wrap: anywhere;
  font-size: 15px;
}

pre {
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 6px;
  background: #111820;
  color: #e7eef3;
  font-size: 12px;
  line-height: 1.45;
}

.batchResults {
  margin-top: 18px;
}

table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 750;
}

td code {
  display: block;
  max-width: 380px;
  overflow-wrap: anywhere;
}

.overlays {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.labelerView {
  display: none;
  grid-template-columns: minmax(240px, 320px) minmax(360px, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.app[data-active-view="labeler"] .recognizerView {
  display: none;
}

.app[data-active-view="labeler"] .labelerView {
  display: grid;
}

.labelerControls {
  display: grid;
  gap: 14px;
}

.labelerFields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

.faceButtons button {
  width: 40px;
  padding: 0;
}

.faceButtons button.is-muted {
  opacity: 0.32;
}

.faceButtons button:disabled {
  cursor: not-allowed;
}

.labelFaceGuidance {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.labelerActions button {
  flex: 1 1 120px;
}

.labelStatus {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.labelCanvasWrap {
  position: relative;
  min-height: 360px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
  background:
    linear-gradient(45deg, #eef3f5 25%, transparent 25%),
    linear-gradient(-45deg, #eef3f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef3f5 75%),
    linear-gradient(-45deg, transparent 75%, #eef3f5 75%);
  background-color: #f8fafb;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

#labelCanvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 320px;
  cursor: crosshair;
  touch-action: none;
}

#labelCanvas[data-mode="template"] {
  cursor: grab;
}

#labelCanvas:empty {
  min-height: 360px;
}

#labelJson {
  min-height: 220px;
  max-height: 380px;
}

.labelHistoryHeader {
  margin-top: 14px;
}

figure {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

figcaption {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.appFooter {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.appFooter.is-warning {
  color: var(--danger);
}

img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 780px) {
  .workbench,
  .overlays,
  .labelerView,
  .heading {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }
}
