@font-face {
  font-family: "Söhne";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/soehne-400.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --grotesk: "Söhne", "Mona Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --sub: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg: #f9fafb;
  --surface: #f3f4f6;
  --surface-2: #e8eaed;
  --hover: #eceff2;
  --surface-raised: #fff;
  --text: #1a1a1a;
  --text-2: #4a4a4a;
  --text-mute: #686868;
  --border: #e2e4e8;
  --border-strong: #c8ccd2;
  --signal: #0aa1c4;
  --signal-hi: #08819d;
  --signal-text: #0d6f86;
  --on-signal: #04222a;
  --on-signal-hi: #f9fafb;
  --alert: #c8390d;
  --missed: #ff7847;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  --space-4xl: 40px;
  --radius: 0;
  --radius-sm: 6px;
  --radius-card: 10px;
  --radius-panel: clamp(8px, 1vw, 14px);
  --hairline: 1px;
  --margin: clamp(20px, 4.5vw, 64px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--grotesk);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
  border-radius: var(--radius);
}

button,
input,
textarea {
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 11px 18px;
  border: var(--hairline) solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-family: var(--sub);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.22s var(--ease), border-color 0.22s var(--ease), background 0.22s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

button:hover:not(:disabled) {
  border-color: var(--text);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--signal-text);
  outline-offset: 2px;
}

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

button.primary {
  border-color: var(--signal-text);
  background: var(--signal);
  color: var(--on-signal);
}

button.primary:hover:not(:disabled) {
  border-color: var(--signal-hi);
  background: var(--signal-hi);
  color: var(--on-signal-hi);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--signal) 23%, transparent);
}

button.secondary {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text-2);
}

button.secondary:hover:not(:disabled),
button.secondary.active {
  border-color: var(--signal-text);
  background: color-mix(in srgb, var(--signal) 9%, var(--surface-raised));
  color: var(--signal-text);
}

button.danger-button {
  border-color: color-mix(in srgb, var(--alert) 42%, var(--border));
  color: var(--alert);
}

button.danger-button:hover:not(:disabled) {
  border-color: var(--alert);
  background: color-mix(in srgb, var(--alert) 8%, var(--surface-raised));
}

input:not([type="radio"]):not([type="checkbox"]),
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: var(--hairline) solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  font-family: var(--grotesk);
  font-size: 15px;
  line-height: 1.4;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input:not([type="radio"]):not([type="checkbox"]):hover,
textarea:hover {
  border-color: var(--text-mute);
}

input:not([type="radio"]):not([type="checkbox"]):focus,
textarea:focus {
  border-color: var(--signal);
  outline: 0;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--signal) 17%, transparent);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-mute);
  opacity: 1;
}

input[type="file"] {
  padding: 7px;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--sub);
  font-size: 12px;
}

input[type="file"]::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 600 11px var(--sub);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--signal-text);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 10px;
  font-size: clamp(32px, 4.4vw, 48px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.04;
}

h2 {
  font-size: clamp(21px, 2.5vw, 27px);
  font-weight: 500;
  letter-spacing: -0.024em;
  line-height: 1.12;
}

h3 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 14px;
  padding: 12px var(--margin);
  border-bottom: var(--hairline) solid var(--border);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  backdrop-filter: blur(18px) saturate(1.35);
}

.brand {
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.075em;
  line-height: 1;
  text-decoration: none;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border-strong);
}

.product-name {
  color: var(--text-2);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.header-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--text-mute);
  font-family: var(--sub);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 13%, transparent);
}

.app-shell {
  width: 100%;
  max-width: 1370px;
  margin-inline: auto;
  padding: clamp(22px, 3.4vw, 44px) var(--margin) 72px;
}

.view-intro {
  max-width: 760px;
  margin: 16px 0 32px;
}

.view-intro > p {
  max-width: 59ch;
  margin-top: 12px;
  color: var(--text-2);
  font-size: clamp(16px, 1.8vw, 19px);
  line-height: 1.5;
}

.eyebrow {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
}

.section-num {
  color: var(--signal-text);
  font-family: var(--sub);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.t-label,
.panel-label {
  color: var(--signal-text);
  font-family: var(--sub);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  line-height: 1.3;
  text-transform: uppercase;
}

.muted {
  color: var(--text-2);
}

.card {
  margin: 0;
  padding: clamp(20px, 2.8vw, 30px);
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
}

.create-panel {
  margin-bottom: clamp(36px, 5vw, 58px);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-xl);
  margin-bottom: 22px;
}

.panel-heading h2 {
  margin-top: 5px;
}

.panel-heading p {
  max-width: 66ch;
  margin-top: 7px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

.panel-heading-row {
  align-items: center;
}

.panel-heading-row #teachProgress {
  margin-top: 6px;
}

.create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: var(--text-2);
  font-family: var(--sub);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.095em;
  line-height: 1.3;
  text-transform: uppercase;
}

.field em {
  margin-left: 4px;
  color: var(--text-mute);
  font-size: 9px;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.field input {
  text-transform: none;
}

.create-photo {
  grid-column: 1 / -1;
  max-width: 480px;
}

.form-actions,
.tool-row,
.upload-row,
.review-actions,
.missed-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-actions {
  margin-top: 18px;
}

.status-message {
  min-width: 0;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.4;
}

.error {
  color: var(--alert);
}

.success {
  color: var(--signal-text);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-top: 4px;
}

.profiles-list {
  display: grid;
  gap: 12px;
}

.profiles-list:empty::after {
  display: block;
  padding: 22px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  color: var(--text-mute);
  content: "No parts yet. Add a part above to begin.";
  font-size: 14px;
  text-align: center;
}

.profile {
  display: grid;
  min-width: 0;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 15px;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.profile:hover {
  border-color: var(--border-strong);
  box-shadow: 0 5px 20px rgba(20, 22, 26, 0.045);
}

.profile .grow {
  min-width: 0;
}

.profile strong {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.profile .muted {
  overflow-wrap: anywhere;
  color: var(--text-mute);
  font-size: 13px;
}

.profile-photo {
  width: 112px;
  height: 82px;
  flex: none;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.profile-photo-empty {
  display: grid;
  place-items: center;
  color: var(--text-mute);
  font-family: var(--sub);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

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

.view-toolbar {
  display: flex;
  align-items: flex-start;
  gap: clamp(18px, 3vw, 36px);
  margin: 10px 0 28px;
}

.back-button {
  flex: 0 0 auto;
  margin-top: 4px;
}

.compact-intro {
  min-width: 0;
  margin: 0;
}

.compact-intro h1 {
  overflow-wrap: anywhere;
}

.content-stack {
  display: grid;
  gap: 18px;
}

.upload-row {
  align-items: end;
}

.upload-field {
  width: min(100%, 500px);
  flex: 1 1 300px;
}

.clean-preview {
  margin-top: 16px;
}

.thumb {
  width: 158px;
  height: 116px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.annotation-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.tool-row {
  margin-top: 18px;
}

.tool-divider {
  width: 1px;
  height: 25px;
  margin-inline: 2px;
  background: var(--border);
}

.stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 20px 0 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  line-height: 0;
  touch-action: none;
  user-select: none;
}

.stage img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
}

.stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.stage svg rect,
.stage svg ellipse {
  fill: color-mix(in srgb, var(--alert) 17%, transparent);
  stroke: var(--alert);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.stage svg .draft {
  stroke-dasharray: 6 4;
}

.stage svg .missed {
  fill: color-mix(in srgb, var(--missed) 22%, transparent);
  stroke: var(--missed);
}

.mark-list {
  margin-top: 12px;
}

.mark-row {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
}

.mark-row span {
  min-width: 110px;
}

.mark-row input {
  flex: 1;
  min-width: 140px;
}

.annotation-actions {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -3px 0 17px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--signal) 24%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--signal) 8%, var(--surface-raised));
  color: var(--signal-text);
  font-family: var(--sub);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.025em;
}

.examples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.example {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg);
}

.example .thumb {
  width: 100%;
  height: 132px;
  border: 0;
  background: var(--surface);
}

.example div {
  min-height: 39px;
  margin: 9px 0;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
}

.example button {
  width: 100%;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.mode-options legend {
  width: 100%;
  margin-bottom: 9px;
  color: var(--text-2);
  font-family: var(--sub);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.option {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
}

.instruction-field,
.inspection-upload {
  max-width: 620px;
  margin-top: 14px;
}

.fast-option {
  margin-top: 16px;
}

.result-card {
  overflow: hidden;
}

.result-stage {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 4px 0 22px;
}

.result-stage img {
  max-height: 72vh;
}

.review {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--signal);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.review strong {
  font-size: 15px;
  font-weight: 500;
}

.review p {
  max-width: 70ch;
  margin-top: 4px;
  font-size: 13px;
}

.review-actions {
  gap: 8px;
}

.detections-list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
}

.list-row strong,
.list-row p {
  grid-column: 1 / -1;
}

.list-row strong {
  font-size: 15px;
  font-weight: 500;
}

.list-row p {
  color: var(--text-2);
  font-size: 13px;
}

.list-row input {
  min-width: 150px;
}

.missed-review {
  border-left-color: var(--missed);
}

.missed-controls input {
  width: min(100%, 260px) !important;
}

.missed-list {
  color: var(--signal-text);
  font-size: 13px;
}

@media (max-width: 720px) {
  .create-grid,
  .annotation-fields {
    grid-template-columns: 1fr;
  }

  .create-photo {
    grid-column: auto;
  }

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

  .profile {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
  }

  .profile-photo {
    width: 84px;
    height: 72px;
  }

  .profile-actions {
    grid-column: 2;
  }

  .view-toolbar {
    flex-direction: column;
    gap: 16px;
  }

  .list-row {
    grid-template-columns: 1fr 1fr;
  }

  .list-row input,
  .list-row strong,
  .list-row p,
  .list-row span {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .app-header {
    min-height: 58px;
    gap: 10px;
  }

  .product-name {
    font-size: 11px;
  }

  .header-context {
    font-size: 0;
  }

  .header-context .live-dot {
    width: 8px;
    height: 8px;
  }

  .app-shell {
    padding-top: 20px;
  }

  .profile {
    grid-template-columns: 68px minmax(0, 1fr);
    padding: 11px;
  }

  .profile-photo {
    width: 68px;
    height: 64px;
  }

  .profile-actions {
    grid-column: 1 / -1;
    padding-left: 80px;
  }

  .tool-row {
    gap: 7px;
  }

  .tool-row button {
    min-height: 40px;
    padding-inline: 11px;
  }

  .tool-divider {
    display: none;
  }

  .review-actions button,
  .missed-controls button {
    flex: 1 1 auto;
  }

  .mark-row {
    flex-wrap: wrap;
  }

  .mark-row span {
    min-width: 0;
    flex: 1;
  }
}

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