:root {
  --paper: #f3f6f4;
  --surface: #ffffff;
  --ink: #15201c;
  --muted: #5a6964;
  --rule: #d3dbd7;
  --brand: #0e5a4a;
  --brand-soft: #e2efeb;
  --better: #17713d;
  --better-bg: #dff2e5;
  --gi-low: #17713d;
  --gi-mid: #96650f;
  --gi-high: #a83a15;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tray-h: 0px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.4; }
body.has-tray { --tray-h: 64px; padding-bottom: var(--tray-h); }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

.ghost { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: .45rem .8rem; font-weight: 500; list-style: none; }
.ghost:hover { border-color: var(--brand); }
.primary { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .55rem 1.1rem; font-weight: 700; }
.primary:hover { background: #0a4638; }
.link { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.check { display: flex; gap: .45rem; align-items: center; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 3px solid var(--ink); }
.brand h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
.brand p { font-size: .8rem; }
.search { flex: 1 1 16rem; }
.search input { width: 100%; padding: .55rem .8rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.basis { display: flex; margin: 0; padding: 0; border: 1px solid var(--ink); border-radius: 6px; overflow: hidden; }
.basis label { cursor: pointer; }
.basis input { position: absolute; opacity: 0; }
.basis span { display: block; padding: .5rem .8rem; font-weight: 500; white-space: nowrap; }
.basis label + label span { border-left: 1px solid var(--ink); }
.basis input:checked + span { background: var(--ink); color: #fff; }
.basis input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -4px; }
.only-narrow { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 19rem minmax(0, 1fr); align-items: start; }
.filters { position: sticky; top: 4.1rem; max-height: calc(100vh - 4.1rem - var(--tray-h)); overflow-y: auto; padding: 1rem 1rem 2rem 1.25rem;
  border-right: 1px solid var(--rule); }
.filters-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.filters h2 { font-size: 1rem; font-weight: 800; }
.fgroup { border-top: 1px solid var(--rule); }
.fgroup:first-child { border-top: 2px solid var(--ink); }
.fgroup summary { cursor: pointer; padding: .6rem 0; font-weight: 700; }
.fgroup[open] { padding-bottom: .75rem; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks label { display: flex; align-items: center; gap: .45rem; padding: .15rem 0; cursor: pointer; }
.checks .n, .cov { color: var(--muted); font-size: .75rem; margin-left: auto; font-variant-numeric: tabular-nums; }
.cov { margin-left: .15rem; }
.ranges { display: grid; gap: .25rem; }
.range, .range-head { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem 4.2rem; gap: .35rem; align-items: center; }
.range-head { font-size: .75rem; color: var(--muted); }
.range.sub .rl { padding-left: .8rem; }
.rl { font-size: .9rem; }
.rl small { color: var(--muted); }
.range input { width: 100%; padding: .25rem .35rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); font-variant-numeric: tabular-nums; }
.range input:not(:placeholder-shown):valid { border-color: var(--brand); }
.checks + .ranges { margin-top: .6rem; }
.note { font-size: .8rem; margin-top: 1rem; }

/* ---------- results ---------- */
.results { padding: 1rem 1.25rem 3rem; min-width: 0; }
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
#count { font-weight: 700; }
.popover { position: relative; }
.popover summary::-webkit-details-marker { display: none; }
.popover-body { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 15; width: 17rem; max-height: 60vh; overflow: auto; padding: .75rem 1rem 1rem;
  background: var(--surface); border: 1px solid var(--ink); border-radius: 6px; box-shadow: 0 8px 24px rgb(21 32 28 / .16); }
.popover-body h3 { font-size: .8rem; color: var(--muted); font-weight: 700; margin: .7rem 0 .25rem; }
.popover-body h3:first-child { margin-top: 0; }
.popover-body .check { padding: .12rem 0; }
.popover-body .link { margin-top: .75rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--ink); }
.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: .5rem .7rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.grid thead th { position: sticky; top: 0; background: var(--surface); border-bottom: 2px solid var(--ink); white-space: nowrap; padding: 0; }
.grid .num { text-align: right; white-space: nowrap; }
.sort { width: 100%; background: none; border: 0; padding: .6rem .7rem; font-weight: 700; text-align: inherit; }
.sort:hover, .sort.on { color: var(--brand); }
.arrow { display: inline-block; width: .9em; font-size: .7em; margin-left: .2em; }
.pick { width: 2.2rem; padding-right: 0 !important; }
.prod { min-width: 15rem; max-width: 26rem; }
.pname { display: block; font-weight: 700; }
.pmeta { display: block; font-size: .82rem; color: var(--muted); }
.grid tbody tr:hover { background: var(--paper); }
.grid tbody tr.on { background: var(--brand-soft); }
.grid td.empty { color: #a3aeaa; }
.grid td.filtered { font-weight: 700; color: var(--brand); }
.grid td.none { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.more { display: block; margin: 1rem auto 0; }

.gi { display: inline-block; min-width: 2.1rem; padding: .05rem .4rem; border-radius: 999px; font-weight: 700; text-align: center; color: #fff; }
.gi-low { background: var(--gi-low); }
.gi-intermediate { background: var(--gi-mid); }
.gi-high { background: var(--gi-high); }
.checks .gi { min-width: 0; font-weight: 500; font-size: .85rem; }

/* ---------- compare tray ---------- */
.tray { position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  min-height: 64px; padding: .6rem 1.25rem; background: var(--ink); color: #fff; }
.tray[hidden] { display: none; }
.tray ul { display: flex; gap: .4rem; list-style: none; margin: 0; padding: 0; overflow-x: auto; }
.tray li { display: flex; align-items: center; gap: .3rem; padding: .25rem .3rem .25rem .7rem; border: 1px solid rgb(255 255 255 / .35); border-radius: 999px; white-space: nowrap; font-size: .88rem; }
.tray li span { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.tray li button { background: none; border: 0; color: #fff; font-size: 1.1rem; line-height: 1; padding: 0 .35rem; }
.tray-actions { display: flex; gap: 1rem; align-items: center; flex: none; }
.tray .link { color: #fff; }
.tray .primary { background: #fff; color: var(--ink); }

/* ---------- compare view: built like the nutrition panel on a pack ---------- */
dialog { width: min(100vw - 2rem, 78rem); max-height: calc(100vh - 2rem); padding: 0; border: 3px solid var(--ink); border-radius: 4px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(21 32 28 / .55); }
.compare-head { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; align-items: center;
  padding: .9rem 1.25rem; background: var(--surface); border-bottom: 6px solid var(--ink); }
.compare-head h2 { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.compare-tools { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; }
.label-wrap { overflow-x: auto; padding: 0 1.25rem; }
.label { border-collapse: collapse; width: 100%; min-width: calc(13rem + var(--cols, 2) * 10rem); font-variant-numeric: tabular-nums; table-layout: fixed; }
.label th, .label td { padding: .4rem .6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--ink); }
.label .rowh { width: 13rem; font-weight: 700; padding-left: 0; }
.label .rowh small { font-weight: 400; color: var(--muted); }
.label thead th { border-bottom: 3px solid var(--ink); vertical-align: bottom; padding-top: 1rem; padding-bottom: .7rem; font-weight: 400; }
.label thead .rowh { font-weight: 400; font-size: .9rem; color: var(--muted); }
.pcol img { display: block; height: 72px; max-width: 100%; object-fit: contain; margin-bottom: .5rem; }
.plinks { display: flex; gap: .9rem; margin-top: .35rem; font-size: .85rem; }
.plinks a { color: var(--brand); }
.label .grp th { padding: 1.1rem 0 .3rem; font-size: 1.05rem; font-weight: 800; border-bottom: 3px solid var(--ink); }
.label tr.sub .rowh { padding-left: 1rem; font-weight: 400; }
.label td { position: relative; }
.label td .v { font-weight: 700; }
.label td.empty .v { font-weight: 400; color: #a3aeaa; font-size: .85rem; }
.label td.best { background: var(--better-bg); }
.label td.best .v { color: var(--better); }
.label td.best .v::after { content: " ✓"; }
.bar { display: block; height: 4px; width: var(--w); margin-top: .25rem; background: var(--ink); opacity: .28; border-radius: 2px; }
.label td.best .bar { background: var(--better); opacity: .8; }
.label .src { display: block; margin-top: .2rem; color: var(--muted); font-size: .75rem; line-height: 1.25; }
.label .tags td { font-size: .88rem; }
.foot { padding: 1rem 1.25rem 1.25rem; font-size: .82rem; max-width: 75ch; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-block; }
  .filters { display: none; position: static; max-height: none; border-right: 0; border-bottom: 3px solid var(--ink); background: var(--surface); }
  .filters.open { display: block; }
  .top { position: static; }
  .basis span { padding: .45rem .55rem; font-size: .88rem; }
  .prod { min-width: 11rem; }
  .compare-head h2 { font-size: 1.4rem; }
}
@media print {
  .top, .filters, .tray, .results-bar, .more, .compare-tools { display: none !important; }
}

/* ---------- loading, toast, small bits ---------- */
[hidden] { display: none !important; }
.loading { padding: 4rem 1.25rem; text-align: center; color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 700; }
.wide { width: 100%; }
.error { color: #a3261a; font-weight: 500; }
.notice { padding: .7rem .9rem; border-left: 4px solid var(--brand); background: var(--brand-soft); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tray-h) + 1.25rem); transform: translateX(-50%); z-index: 60; max-width: min(92vw, 34rem);
  padding: .8rem 1.1rem; background: var(--ink); color: #fff; border-radius: 6px; box-shadow: 0 8px 24px rgb(21 32 28 / .25); }
.brand .title { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
.user-menu { display: grid; gap: .5rem; width: 15rem; justify-items: start; }
.user-menu a { color: var(--brand); }
.user-menu p { overflow-wrap: anywhere; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- signed-out and payment pages ---------- */
.gate { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); min-height: 100vh; }
.gate-pitch { padding: clamp(2rem, 7vw, 6rem) clamp(1.25rem, 5vw, 5rem); background: var(--ink); color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 1.5rem; }
.gate-pitch h1 { font-size: clamp(2rem, 4.4vw, 3.5rem); font-weight: 800; line-height: 1.04; letter-spacing: -.025em; max-width: 15ch; }
.gate-pitch .lede { font-size: 1.1rem; max-width: 46ch; color: #d4dcd9; }
.gate-pitch .notice { color: var(--ink); max-width: 46ch; }
/* the database described the way a pack describes its contents */
.facts { width: 100%; max-width: 30rem; margin-top: 1rem; border-collapse: collapse; background: #fff; color: var(--ink); border: 3px solid #fff; outline: 2px solid var(--ink); outline-offset: -5px; font-variant-numeric: tabular-nums; }
.facts caption { caption-side: top; text-align: left; padding: .9rem 1rem .5rem; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; background: #fff; border-bottom: 6px solid var(--ink); margin: 0 5px; }
.facts th, .facts td { padding: .45rem 1rem; border-bottom: 1px solid var(--ink); text-align: left; font-weight: 700; }
.facts td { text-align: right; font-weight: 800; }
.facts tr.sub th, .facts tr.sub td { font-weight: 400; }
.facts tr:last-child th, .facts tr:last-child td { border-bottom: 0; padding-bottom: .9rem; }
.gate-form { padding: clamp(2rem, 6vw, 5rem) clamp(1.25rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: center; gap: 1rem; background: var(--surface); }
.gate-form > * { max-width: 26rem; width: 100%; }
.tabs { display: flex; border-bottom: 2px solid var(--ink); }
.tabs button { background: none; border: 0; padding: .6rem 1rem .6rem 0; margin-right: 1rem; font-weight: 700; font-size: 1.1rem; color: var(--muted); border-bottom: 4px solid transparent; margin-bottom: -2px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
#auth-form, .signup-only { display: grid; gap: .9rem; }
#auth-form label { display: grid; gap: .25rem; font-weight: 500; }
#auth-form input, #auth-form select { padding: .6rem .7rem; border: 1px solid #9aa7a2; border-radius: 6px; background: #fff; font: inherit; }
.plans { list-style: none; margin: 0; padding: 0; border-top: 3px solid var(--ink); }
.plans li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--ink); }
.plan-name { font-weight: 800; font-size: 1.15rem; }
.plan-price { font-weight: 800; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.plans li .primary { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .gate { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .gate-pitch { padding-block: 2.5rem; }
}
