:root {
  --bg: #f6f2ea;
  --surface: #fffdf9;
  --surface-sunken: #efe9de;
  --border: #e2d9c8;
  --ink: #26221c;
  --ink-soft: #5b5347;
  --ink-faint: #8b8272;
  --accent: #2f6f66;
  --accent-strong: #204d46;
  --accent-soft: #e2efec;
  --warn: #93590e;
  --warn-soft: #f5ead2;
  --danger: #a8402b;
  --danger-soft: #f6e2db;
  --shadow-sm: 0 1px 2px rgba(38, 34, 28, 0.06);
  --shadow-md: 0 4px 10px rgba(38, 34, 28, 0.05), 0 12px 28px rgba(38, 34, 28, 0.07);
  --radius: 16px;
  --radius-sm: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--accent);
  color: var(--surface);
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

html {
  scrollbar-color: var(--border) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-7) var(--space-4) 72px;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent-strong);
}

.wordmark__mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

h1 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 500;
  font-size: 1.9rem;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.tagline {
  color: var(--ink-faint);
  margin: var(--space-2) 0 0;
  font-size: 0.95rem;
}

main {
  width: 100%;
  max-width: 520px;
}

.hidden {
  display: none !important;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

#disclaimer p {
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 56ch;
}

#disclaimer strong {
  color: var(--ink);
}

button {
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: #fbfaf7;
  border: none;
  padding: 13px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(32, 77, 70, 0.25);
  transition: background-color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(32, 77, 70, 0.28);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(32, 77, 70, 0.25);
}

.footnote {
  color: var(--ink-faint);
  font-size: 0.85rem;
  margin-bottom: 0;
}

.footnote a {
  color: var(--ink-soft);
  text-underline-offset: 2px;
}

#stage {
  padding: var(--space-4);
}

#instruction-line {
  margin: 0 0 var(--space-4);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  min-height: 1.4em;
}

#reference-photo {
  margin: 0 0 var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

#reference-photo img {
  display: block;
  width: 100%;
  max-width: 260px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#reference-photo figcaption {
  font-size: 0.82rem;
  color: var(--ink-faint);
  text-align: center;
}

.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #12100c;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: box-shadow 300ms ease;
}

.camera-wrap--good {
  box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px rgba(47, 111, 102, 0.3);
}

#video {
  display: none;
}

#overlay {
  width: 100%;
  height: 100%;
  display: block;
}

#status-line {
  margin: var(--space-4) var(--space-1) 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--space-2);
  text-align: center;
  color: var(--ink-soft);
  min-height: 1.4em;
  font-size: 0.95rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 0.5em;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
  transition: background-color 200ms ease;
}

.status-dot--warn {
  background: var(--warn);
}

.status-dot--good {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The live measurement, always on screen while measuring. Deliberately plain
   and quiet: it's reference information you read when something looks wrong,
   not a second status line competing with the instruction. */
.readout {
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  text-align: center;
}

#readout-text {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-soft);
}

#readout-detail {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.readout--met {
  background: var(--accent-soft);
  border-color: transparent;
}

.readout--met #readout-text {
  color: var(--accent-strong);
}

.readout--met #readout-detail {
  color: var(--accent);
}

.measured {
  margin: 0 0 var(--space-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

#results h2 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 500;
  margin: 0 0 var(--space-5);
  font-size: 1.5rem;
}

.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.result-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.result-card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--border);
}

.badge-positive {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.badge-negative {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
}

.tier {
  margin: 0 0 var(--space-4);
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.tier-note {
  color: var(--warn);
}

.tier-checked {
  color: var(--danger);
  font-weight: 500;
}

.sparkline {
  display: block;
  width: 100%;
  height: 56px;
}

#results .footnote {
  margin: var(--space-5) 0 var(--space-5);
  line-height: 1.5;
}

#again-btn {
  width: 100%;
}

@media (max-width: 480px) {
  body {
    padding: var(--space-6) var(--space-3) 56px;
  }

  section {
    padding: var(--space-5);
    border-radius: var(--radius-sm);
  }

  h1 {
    font-size: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .camera-wrap,
  .status-dot {
    transition: none !important;
  }
}
