/* =====================================================================
   The Health Lab — design system ("B": warm, light, Airbnb-like)
   White space, soft shadows instead of borders, coral used sparingly,
   navy text, Archivo display type and Inter body type.
   ===================================================================== */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --ink: #1d2033;            /* headings and body */
  --ink-2: #6a6f85;          /* secondary text */
  --ink-3: #9a9fb2;          /* hints */
  --line: #ebebee;
  --navy: #1d2550;
  --coral: #e8746b;
  --coral-deep: #d6545b;
  --coral-ink: #c4483f;      /* coral text on white, readable */
  --coral-bg: #fdf0ee;
  --red: #e5484d;  --red-bg: #fde8e8;
  --amber: #b9770c; --amber-bg: #fdf3e1;
  --green: #2f9e6a; --green-bg: #e6f6ee;
  --shadow: 0 6px 24px rgba(29, 32, 51, 0.08);
  --shadow-lg: 0 18px 40px rgba(29, 32, 51, 0.14);
  --radius: 20px;
  --display: "Archivo", "Inter", system-ui, -apple-system, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

main { max-width: 960px; margin: 0 auto; padding: 0 20px 72px; }
main.narrow { max-width: 520px; }

h1, h2, h3 { font-family: var(--display); color: var(--ink); letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: clamp(2rem, 6.5vw, 2.75rem); font-weight: 800; margin: 0; }
h2 { font-size: 1.3rem; font-weight: 800; margin: 0 0 8px; }
h3 { font-size: 1.3rem; font-weight: 800; margin: 32px 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--coral-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
strong { color: var(--ink); }

.muted { color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: 0.9rem; margin: 6px 0 0; }
.eyebrow { margin: 0 0 6px; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.eyebrow a { color: inherit; text-decoration: none; }
.disclaimer { font-size: 0.82rem; color: var(--ink-3); margin-top: 24px; }

/* ---- Header & footer ---- */
.site-header {
  position: sticky; top: 0; z-index: 20; margin: 0 -20px 8px; padding: 12px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.88); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.site-header .mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 1.02rem; white-space: nowrap; }
.site-header .mark .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--coral), var(--coral-deep)); box-shadow: 0 4px 12px rgba(232, 116, 107, 0.35); }
.site-header .mark .logo svg { width: 19px; height: 19px; stroke: #fff; }
.site-header .mark small { display: block; font: 500 0.72rem var(--body); color: var(--ink-2); }
.site-header nav { display: flex; gap: 16px; align-items: center; font-size: 0.92rem; font-weight: 600; }
.site-header nav a { color: var(--ink); text-decoration: none; white-space: nowrap; }
.site-header nav a.pill { padding: 7px 14px; border-radius: 999px; background: var(--ink); color: #fff; }
.site-footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--ink-3); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 20px 0 24px; }
.account { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }
.brand { margin: 28px 0 22px; }
.brand .muted { font-size: 1.05rem; margin-top: 10px; }

/* ---- Surfaces ---- */
.card { background: var(--surface); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; background: var(--surface-2); }

/* ---- Buttons ---- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--body); padding: 0.95rem 1.4rem; border: 0; border-radius: 14px; cursor: pointer; text-decoration: none;
  background: linear-gradient(90deg, var(--coral), var(--coral-deep)); color: #fff;
  box-shadow: 0 8px 20px rgba(214, 84, 91, 0.25); transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
button:not(:disabled):active, .button:active { transform: scale(0.98); }
button:not(.link):not(:disabled):hover, .button:hover { box-shadow: 0 10px 26px rgba(214, 84, 91, 0.35); }
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.button.secondary, button.secondary { background: #fff; color: var(--ink); border: 1px solid #dcdce2; box-shadow: none; }
.button.secondary:hover, button.secondary:hover { background: var(--surface-2); box-shadow: none; }
button.link { background: none; box-shadow: none; color: var(--ink); padding: 4px 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { box-shadow: none; }
button.link.danger { color: var(--red); }
form.card button[type="submit"] { width: 100%; }
#code-form button.link { display: block; margin: 12px auto 0; }

/* ---- Inputs ---- */
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; color: var(--ink); }
input[type="email"], input[type="text"], input[type="number"], input[type="search"], input:not([type]), select {
  width: 100%; font: 500 1rem var(--body); color: var(--ink); background: #fff;
  padding: 13px 14px; border: 1px solid #dcdce2; border-radius: 12px; margin-bottom: 12px; outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(29, 32, 51, 0.08); }
input::placeholder { color: var(--ink-3); }
input[type="file"] { margin-bottom: 12px; max-width: 100%; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--coral-deep); }

/* ---- Messages ---- */
.message { padding: 12px 16px; border-radius: 12px; background: var(--surface-2); color: var(--ink); font-weight: 500; }
.message.error { background: var(--red-bg); color: #b4262b; }
.warning { background: var(--amber-bg); border-radius: 12px; padding: 12px 14px; margin: 12px 0; color: #7a4f07; }
.warning label { font-weight: 500; }

/* ---- Chips & badges ---- */
.chip { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.stated, .chip.verdict-clean, .chip.dose-ok { background: var(--green-bg); color: var(--green); }
.chip.blend_undisclosed, .chip.verdict-caution, .chip.dose-near { background: var(--amber-bg); color: var(--amber); }
.chip.not_readable, .chip.verdict-red, .chip.dose-over { background: var(--red-bg); color: var(--red); }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.badge.free { background: var(--green-bg); color: var(--green); }
.badge.members { background: var(--coral-bg); color: var(--coral-ink); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }

/* ---- Hero (Free Lab home) ---- */
.hero { margin: 0 -20px 8px; padding: 36px 20px 40px; border-radius: 0 0 32px 32px; background: radial-gradient(120% 90% at 85% 0%, #f9c5bd, transparent 60%), linear-gradient(160deg, #fdebe7, #f3ecff); }
.hero h1 { max-width: 14ch; font-size: clamp(2.2rem, 8vw, 3.3rem); margin-top: 6px; }
.hero .eyebrow { color: var(--coral-ink); font-weight: 700; }
.hero .sub { font-size: 1.08rem; color: #474c63; max-width: 34em; margin: 16px 0 24px; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .actions .button { flex: 1 1 200px; }
@media (min-width: 640px) { .hero .actions .button { flex: 0 0 auto; } .hero { padding: 56px 40px 60px; margin: 0 0 12px; border-radius: 32px; } }
.tim-intro { display: flex; align-items: center; gap: 12px; margin-top: 26px; }
.tim-intro p { margin: 0; font-size: 0.92rem; color: #474c63; }

/* ---- Tool tiles ---- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin-top: 24px; }
.tool { position: relative; background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.tool h2 { margin-bottom: 6px; }
.tool p { color: var(--ink-2); margin: 0 0 14px; }
.tool-link { display: block; color: inherit; text-decoration: none; }
.tool-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tool .icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 16px; background: var(--coral-bg); }
.tool .icon svg { width: 22px; height: 22px; stroke: var(--coral-ink); }

/* ---- Tim's photo (falls back to initials) ---- */
.tim-photo { width: 48px; height: 48px; min-width: 48px; border-radius: 50%; display: grid; place-items: center; font: 700 0.95rem var(--body); color: #fff; background: linear-gradient(135deg, var(--navy), #4a57a0); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); background-size: cover; background-position: center; }
.tim-photo.has-photo { color: transparent; background-image: url("/img/tim.jpg"); }

/* ---- Members offer ---- */
.members-cta { margin-top: 28px; background: var(--surface-2); box-shadow: none; }
.members-cta .eyebrow { color: var(--coral-ink); font-weight: 700; }
.members-cta ul { padding-left: 20px; margin: 8px 0 18px; color: #474c63; }
.members-cta li { margin: 6px 0; }
.members-cta .button { width: 100%; }

/* ---- Stepper (scanner) ---- */
.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 18px 0 20px; }
.stepper li { flex: 1; font-size: 0.78rem; font-weight: 600; color: var(--ink-3); padding-top: 8px; border-top: 4px solid var(--line); border-radius: 2px; }
.stepper li.done { color: var(--ink-2); border-top-color: #f3b6af; }
.stepper li.current { color: var(--ink); border-top-color: var(--coral); }
.step-title { font-size: 1.4rem; margin-bottom: 6px; }
.free-note { color: var(--coral-ink); font-weight: 600; font-size: 0.9rem; margin: 0 0 10px; }

/* ---- Photo step ---- */
.photo-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.photo-buttons .button { flex: 1 1 140px; white-space: nowrap; padding: 0.95rem 0.75rem; }
.thumbs { list-style: none; padding: 0; margin: 0 0 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.thumbs li { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); }
#read, #confirm, #save { width: 100%; }
.scanning { display: flex; align-items: center; gap: 12px; }
.scanning::before { content: ""; width: 18px; height: 18px; min-width: 18px; border-radius: 50%; border: 3px solid var(--coral-bg); border-top-color: var(--coral); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Review step ---- */
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 12px; }
.field-row label { margin: 0; }
.field-row input { margin: 6px 0 0; }
.ingredients { width: 100%; border-collapse: collapse; margin: 8px 0; }
.ingredients th { text-align: left; font-size: 0.78rem; color: var(--ink-2); font-weight: 600; padding: 4px; }
.ingredients td { padding: 8px 4px; vertical-align: top; border-top: 1px solid var(--line); }
.ingredients td:nth-child(2) { width: 22%; }
.ingredients td:nth-child(3) { width: 18%; }
.ingredients td:last-child { white-space: nowrap; text-align: right; }
.ingredients td:last-child button { margin-left: 10px; padding: 4px 6px; text-decoration: none; }
.ingredients input { margin: 0; padding: 9px 10px; font-size: 0.95rem; }
.ingredients .hint { margin: 4px 0 0; font-size: 0.8rem; }
.confirm-actions { margin-top: 8px; }
.confirm-actions .hint { text-align: center; }
@media (max-width: 480px) {
  .ingredients thead { display: none; }
  .ingredients tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
  .ingredients td { border: 0; padding: 0; width: auto !important; }
  .ingredients td:first-child, .ingredients td:last-child { grid-column: 1 / -1; text-align: left; }
}

/* ---- Results ---- */
.result-hero {
  position: relative; height: 230px; margin: 0 -20px; border-radius: 0 0 28px 28px;
  background: radial-gradient(120% 90% at 80% 10%, #f7b7ae, transparent 60%), linear-gradient(160deg, #fbe1dc, #f2e9ff);
  display: grid; place-items: center; overflow: hidden;
}
.result-hero img, .result-hero .placeholder { width: 140px; height: 170px; object-fit: cover; border-radius: 16px; transform: rotate(-4deg); box-shadow: var(--shadow-lg); background: #fff; border: 4px solid #fff; display: grid; place-items: center; font-size: 42px; }
@media (min-width: 640px) { .result-hero { margin: 0; border-radius: 28px; } }
.result-head { margin: 22px 0 6px; }
.result-head .eyebrow { margin-bottom: 4px; }
.result-head h2 { font-size: clamp(1.6rem, 6vw, 2rem); margin: 0; }
.verdict-card { display: flex; align-items: center; gap: 18px; margin: 18px 0; padding: 18px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.verdict-card p { margin: 2px 0 0; color: var(--ink-2); }
.score-label { font: 800 1.45rem var(--display); margin: 0; color: var(--ink); }
.score {
  --pct: 0; --ring: var(--green);
  width: 88px; height: 88px; min-width: 88px; border-radius: 50%; display: grid; place-items: center;
  font: 800 2rem var(--display); color: var(--ink);
  background: radial-gradient(closest-side, #fff 80%, transparent 81% 100%), conic-gradient(var(--ring) calc(var(--pct) * 1%), #efeff2 0);
}
.score[data-label="Keep It"] { --ring: var(--green); }
.score[data-label="Acceptable"] { --ring: #7cae32; }
.score[data-label="Reconsider"] { --ring: var(--amber); }
.score[data-label="Replace It"] { --ring: var(--red); }
.score.small { width: 54px; height: 54px; min-width: 54px; font-size: 1.15rem; }
.product .score.small { background: radial-gradient(closest-side, var(--surface-2) 80%, transparent 81% 100%), conic-gradient(var(--ring) calc(var(--pct) * 1%), #e6e6eb 0); }
.tim-take { display: flex; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--coral-bg); margin-bottom: 8px; }
.tim-take b { font-size: 0.95rem; }
.tim-take p { margin: 4px 0 0; font-size: 1.02rem; line-height: 1.5; color: var(--ink); }

.filter-pills { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 6px; padding-bottom: 2px; }
.filter-pills button { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid #dcdce2; background: #fff; color: var(--ink); font-size: 0.88rem; font-weight: 600; box-shadow: none; }
.filter-pills button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.verdict-list, .dose-list { list-style: none; padding: 0; margin: 0; }
.verdict-list li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.verdict-list li:last-child { border-bottom: 0; }
.verdict-list .vbadge { width: 40px; height: 40px; min-width: 40px; border-radius: 12px; display: grid; place-items: center; font: 800 1.05rem var(--display); }
.verdict-list li.red .vbadge { background: var(--red-bg); color: var(--red); }
.verdict-list li.caution .vbadge { background: var(--amber-bg); color: var(--amber); }
.verdict-list li.clean .vbadge { background: var(--green-bg); color: var(--green); }
.verdict-list li.unknown .vbadge { background: var(--surface-2); color: var(--ink-3); }
.verdict-list .vbody { flex: 1; min-width: 0; }
.verdict-list .vbody b { display: block; }
.verdict-list .vbody .sub { color: var(--ink-3); font-size: 0.82rem; }
.verdict-list .vbody p { margin: 4px 0 0; color: var(--ink-2); font-size: 0.93rem; }
.verdict-head, .dose-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }

.dose-list li { padding: 16px; border-radius: 16px; background: var(--surface-2); margin-bottom: 10px; }
.dose-list li .hint { margin-top: 4px; }
.meter { position: relative; height: 8px; border-radius: 99px; background: #e6e6eb; margin: 10px 0 6px; overflow: hidden; }
.meter span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--green); }
.meter.near span { background: var(--amber); }
.meter.over span { background: var(--red); }
.meter::after { content: ""; position: absolute; top: 0; bottom: 0; left: calc(100% / 1.5); width: 2px; background: var(--ink); opacity: 0.35; }

.dock { position: sticky; bottom: 0; z-index: 10; margin: 24px -20px 0; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.dock .button, .dock button { flex: 1; }
.save-card .field-row { margin-bottom: 14px; }

/* ---- Cabinet ---- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.stat-value { display: block; font: 800 1.6rem var(--display); color: var(--ink); }
.stat-label { font-size: 0.8rem; color: var(--ink-2); }
.product-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.product { border-radius: 18px; padding: 16px; background: var(--surface-2); }
.product.paused { opacity: 0.55; }
.product-head { display: flex; gap: 14px; align-items: center; }
.product-head p { margin: 2px 0 0; }
.product-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.product-fields label { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); margin: 0; }
.product-fields input { margin: 6px 0 0; padding: 10px; background: #fff; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.product-foot .hint { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.nc { margin-top: 12px; color: var(--ink-2); font-size: 0.88rem; }
.nc summary { cursor: pointer; color: var(--ink); font-weight: 600; }
@media (max-width: 480px) {
  .stats-row { gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 1.2rem; }
  .product-fields { grid-template-columns: 1fr 1fr; }
  .product-fields label:first-child { grid-column: 1 / -1; }
}

/* ---- Admin / rules ---- */
.steps { padding-left: 20px; margin: 0 0 10px; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0 0 12px; }
.stats dt { color: var(--ink-2); }
.stats dd { margin: 0; font-weight: 700; text-align: right; }
.rubric-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.rubric-filter input { flex: 1 1 200px; margin: 0; }
.rubric-filter select { flex: 0 0 auto; width: auto; margin: 0; }
.rubric-table { width: 100%; border-collapse: collapse; }
.rubric-table td { border-top: 1px solid var(--line); padding: 10px 4px; vertical-align: top; overflow-wrap: anywhere; }
.rubric-table td:first-child { font-weight: 600; }
.rubric-table a { white-space: nowrap; }

@media (max-width: 420px) {
  .site-header nav { gap: 10px; font-size: 0.86rem; }
  .site-header .mark { font-size: 0.95rem; }
  .site-header nav a.pill { padding: 6px 11px; }
}
.mt-12 { margin-top: 12px; } .mt-24 { margin-top: 24px; }
.verdict-card .score-label { color: var(--ink); }
.section .dose-list { margin-top: 12px; }
@media (max-width: 640px) {
  .grid .tool { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: start; padding: 18px; }
  .grid .tool .icon { margin: 0; grid-row: span 3; }
  .grid .tool h2 { font-size: 1.1rem; margin: 2px 0 4px; }
  .grid .tool p { margin: 0; font-size: 0.93rem; }
  .grid .tool .badge { justify-self: start; margin-top: 8px; }
}
