:root {
  --blush: #f2e4e1;
  --petal: #fbf4f2;
  --line: #dcc8c3;
  --sea: #2e8b57;
  --sea-deep: #1f5e43;
  --ink: #1e2622;
  --muted: #5d6762;
  --high: #a1443a;
  --medium: #b0661c;
  --low: #8a7a2e;
  --stone: #8c8580;
  --radius: 3px;
  --pad: clamp(20px, 6vw, 40px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--blush);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  font-variation-settings: "wdth" 100;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--sea-deep); }
:focus-visible { outline: 2px solid var(--sea-deep); outline-offset: 3px; }

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad) calc(48px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Wordmark: the one bold thing. */
.mark {
  font-weight: 800;
  font-variation-settings: "wdth" 112;
  font-size: clamp(76px, 26vw, 148px);
  line-height: 0.82;
  letter-spacing: -0.045em;
  color: var(--sea);
  margin: 8px 0 0 -0.04em;
}
.mark.small { font-size: 34px; line-height: 1; margin: 0; letter-spacing: -0.03em; }
.lede { font-size: 19px; max-width: 30ch; margin: 22px 0 40px; color: var(--ink); }

header.bar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 36px; }
.link-btn {
  background: none; border: 0; padding: 6px 0; cursor: pointer;
  color: var(--sea-deep); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}

.credit { margin: 32px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 500; font-variation-settings: "wdth" 112; letter-spacing: .06em; text-transform: lowercase; color: #9a908c; }

/* The three ways in */
.ways { display: grid; gap: 10px; }
.way {
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 112px; padding: 18px 20px;
  border: 1.5px solid var(--ink); border-radius: var(--radius);
  background: transparent; text-align: left; cursor: pointer;
  transition: background-color .15s ease;
}
.way strong { font-size: 24px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.1; }
.way span { color: var(--muted); font-size: 15px; margin-top: 4px; }
.way:hover { background: var(--petal); }
.way.primary { background: var(--sea); border-color: var(--sea); color: var(--petal); min-height: 168px; }
.way.primary span { color: #d6eadf; }
.way.primary:hover { background: var(--sea-deep); border-color: var(--sea-deep); }
.way input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.foot { margin-top: auto; padding-top: 48px; font-size: 14px; color: var(--muted); max-width: 46ch; }

h1.title {
  font-size: 40px; font-weight: 800; font-variation-settings: "wdth" 106;
  line-height: 1; letter-spacing: -0.03em; margin: 0 0 12px;
}
.sub { color: var(--muted); margin: 0 0 24px; }

textarea {
  width: 100%; min-height: 260px; resize: vertical;
  background: var(--petal); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 16px; font-size: 16px; line-height: 1.5;
}
textarea::placeholder { color: #9a908c; }

.btn {
  display: block; width: 100%; margin-top: 14px; padding: 18px 20px;
  background: var(--sea); color: var(--petal); border: 0; border-radius: var(--radius);
  font-size: 19px; font-weight: 700; text-align: left; cursor: pointer;
}
.btn:hover { background: var(--sea-deep); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.ghost:hover { background: var(--petal); }

/* Reading state */
.photo { width: 100%; max-height: 46vh; object-fit: cover; border-radius: var(--radius); display: block; filter: saturate(.85); }
.reading { margin-top: 20px; display: flex; align-items: center; gap: 12px; font-weight: 600; }
.pulse { width: 12px; height: 12px; background: var(--sea); border-radius: 50%; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.5); opacity: .4; } }
.error { margin-top: 18px; padding: 16px; border-left: 3px solid var(--high); background: var(--petal); }

/* Results */
.verdict { margin: 4px 0 28px; }
.verdict .num {
  font-weight: 800; font-variation-settings: "wdth" 112;
  font-size: clamp(96px, 30vw, 168px); line-height: .8; letter-spacing: -0.05em;
  color: var(--high);
}
.verdict.clear .num { color: var(--sea); }
.verdict p { font-size: 22px; font-weight: 600; line-height: 1.25; margin: 14px 0 0; max-width: 22ch; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.toggle input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--line); position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--petal); transition: transform .15s; }
.toggle input:checked { background: var(--sea); }
.toggle input:checked::after { transform: translateX(16px); }

section.group { margin-top: 30px; }
section.group > h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
section.group > .hint { color: var(--muted); font-size: 15px; margin: 0 0 10px; }

details.item { border-top: 1px solid var(--line); }
details.item:last-of-type { border-bottom: 1px solid var(--line); }
details.item summary {
  list-style: none; cursor: pointer; padding: 14px 0;
  display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: baseline;
}
details.item summary::-webkit-details-marker { display: none; }
.dot { width: 12px; height: 12px; border-radius: 2px; transform: translateY(1px); background: var(--stone); }
.dot.High { background: var(--high); } .dot.Medium { background: var(--medium); } .dot.Low { background: var(--low); }
.dot.fine { background: var(--sea); } .dot.none { background: transparent; border: 1.5px solid var(--stone); }
.iname { font-weight: 600; }
.iname small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; white-space: nowrap; }
.top { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--sea-deep); font-weight: 600; }
.more { padding: 0 0 16px 24px; font-size: 15px; }
.more dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.more dt { color: var(--muted); }
.more dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; font-size: 15px; color: var(--muted); }
.plain li { break-inside: avoid; padding: 3px 0; }

.again { margin-top: 36px; }

/* Barcode scanner */
.viewfinder { position: relative; aspect-ratio: 4 / 3; background: var(--ink); border-radius: var(--radius); overflow: hidden; margin-bottom: 4px; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 2px solid var(--petal); border-radius: var(--radius); box-shadow: 0 0 0 999px rgba(30, 38, 34, .35); }
.guide::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--sea); opacity: .9; }
label.btn { cursor: pointer; }
.code-form { margin-top: 28px; }
.code-form label { display: block; font-weight: 600; margin-bottom: 8px; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; padding: 14px 16px; font-size: 18px; letter-spacing: .04em; background: var(--petal); border: 1.5px solid var(--ink); border-radius: var(--radius); font-variant-numeric: tabular-nums; }
.btn.small { width: auto; margin: 0; padding: 14px 20px; font-size: 17px; }

/* Product found */
.product { padding: 0 0 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.product strong { display: block; font-size: 20px; letter-spacing: -0.01em; line-height: 1.25; }
.product span { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
.found { display: flex; gap: 16px; align-items: flex-start; padding: 16px; background: var(--petal); border: 1.5px solid var(--ink); border-radius: var(--radius); }
.found-img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: var(--radius); flex: none; }
.found strong { font-size: 18px; }
.found p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

/* Loading: a quiet spinner, centred */
.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; min-height: 55vh; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #d9cfcc; border-top-color: var(--sea); animation: spin .9s linear infinite; }
.loading p { margin: 0; color: var(--muted); font-size: 17px; max-width: 26ch; line-height: 1.45; }
.loading strong { display: block; color: var(--ink); font-weight: 600; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Results: colour groups */
.g-clog { --g: var(--high); --g-bg: #f6dcd7; }
.g-weak { --g: var(--stone); --g-bg: #ebe4e1; }
.g-fungal { --g: #7a5a99; --g-bg: #ece2f1; }
.g-safe { --g: var(--sea); --g-bg: #d9ece0; }
.g-unknown { --g: #b8aeab; --g-bg: transparent; }
.glance { margin: 0 0 22px; }
.glance .bar { display: flex; gap: 3px; height: 14px; border-radius: var(--radius); overflow: hidden; }
.glance .bar span { background: var(--g); min-width: 6px; }
.glance .legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; }
.glance .legend li { display: flex; align-items: center; gap: 7px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--g); flex: none; }
section.group { margin-top: 26px; padding: 18px 16px 6px; background: var(--g-bg); border-left: 4px solid var(--g); border-radius: var(--radius); }
section.group.g-unknown { border: 1.5px dashed var(--line); border-left: 4px solid var(--g); padding-bottom: 16px; }
section.group > h2 { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; margin: 0 0 4px; }
section.group > h2 .count { margin-left: auto; font-size: 15px; font-weight: 700; color: var(--g); background: var(--petal); border-radius: 20px; padding: 2px 10px; }
section.group details.item { border-top-color: rgba(30, 38, 34, .12); }
section.group details.item:last-of-type { border-bottom: 0; }
.pill { display: inline-block; font-size: 14px; font-weight: 700; padding: 2px 8px; border-radius: 20px; color: var(--petal); background: var(--stone); }
.pill.High { background: var(--high); } .pill.Medium { background: var(--medium); } .pill.Low { background: var(--low); }
.pill.fine { background: var(--sea); }
.toggle small { color: var(--muted); font-size: 13px; margin-left: 2px; }
.toggle { flex-wrap: wrap; }
.inline-link { color: var(--sea-deep); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; display: inline; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* First-visit intro */
dialog.intro { border: 0; padding: 36px 28px 28px; max-width: min(400px, calc(100vw - 40px)); background: var(--petal); color: var(--ink); border-radius: var(--radius); box-shadow: 0 18px 50px rgba(30, 38, 34, .12); }
dialog.intro::backdrop { background: rgba(242, 228, 225, .35); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
body.intro-open .wrap { filter: blur(10px); transition: filter .2s ease; }
body .wrap { transition: filter .2s ease; }
dialog.intro .mark.small { margin: 0 0 22px; }
dialog.intro h2 { font-size: 26px; line-height: 1.15; font-weight: 750; font-variation-settings: "wdth" 108; margin: 0 0 14px; letter-spacing: -.01em; }
dialog.intro p { margin: 0 0 10px; color: var(--muted); font-size: 17px; line-height: 1.5; }
dialog.intro .btn { margin-top: 18px; width: 100%; }
