:root { color-scheme: dark; }
* { box-sizing: border-box; }
body {
  font: 16px/1.5 system-ui, -apple-system, sans-serif;
  margin: 0; background: #0e0e14; color: #e6e6ef;
}
header {
  max-width: 980px; margin: 0 auto; padding: 1rem;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem;
}
header .brand { font-size: 1rem; font-weight: 800; color: #e6e6ef; text-decoration: none; }
header .brand:hover { color: #9aa0ff; }
footer { max-width: 980px; margin: 0 auto; padding: 1rem; }
.meta { color: #8a8aa0; font-size: .9rem; margin: 0; }
.meta a { color: #9aa0ff; }
#stats { font-size: 1rem; color: #8a8aa0; }
#stats b { color: #e6e6ef; }
footer .meta { font-size: .62rem; line-height: 1.4; color: #6e6e85; }

main {
  max-width: 980px; margin: 0 auto; padding: 0 1rem 2rem;
  display: grid; grid-template-columns: 1fr; gap: 2rem;
}
@media (min-width: 760px) {
  /* Desktop: header + footer + search form + label stay put; only results scroll. */
  body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  main { flex: 1; min-height: 0; width: 100%; grid-template-columns: 1fr 340px; align-items: stretch; padding-bottom: 1rem; }
  .search { display: flex; flex-direction: column; min-height: 0; }
  .results { flex: 1; min-height: 0; overflow-y: auto; }
  .label-panel { position: static; align-self: start; max-height: 100%; overflow-y: auto; }
}

input[type="search"] {
  width: 100%; padding: .8rem 1rem; font-size: 1rem; border-radius: 10px;
  border: 1px solid #33334a; background: #16161f; color: inherit;
}
input[type="search"]:focus { outline: none; border-color: #6e6eff; }

/* ── Filter bar ──────────────────────────────────────────────── */
.filters {
  margin-top: .8rem; display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center;
  font-size: .82rem; color: #9a9ab0;
}
.filters label { display: inline-flex; align-items: center; gap: .35rem; }
.filters select, .filters input[type="number"] {
  background: #16161f; color: #e6e6ef; border: 1px solid #33334a; border-radius: 6px;
  padding: .3rem .4rem; font-size: .82rem;
}
.filters input[type="number"] { width: 4.5rem; }
.filters .chk { cursor: pointer; }
.filters .ranges { width: 100%; }
.filters .ranges summary { cursor: pointer; color: #9aa0ff; font-size: .8rem; }
.range-grid {
  display: grid; grid-template-columns: max-content auto auto; gap: .4rem .6rem;
  align-items: center; margin-top: .6rem; max-width: 320px;
}

.results { margin-top: 1rem; display: flex; flex-direction: column; }
.result {
  text-align: left; width: 100%; background: none; border: none; cursor: pointer;
  color: inherit; padding: .7rem .6rem; border-bottom: 1px solid #22222e;
  border-radius: 6px;
}
.result:hover, .result:focus { background: #1a1a26; outline: none; }
.result .title { font-weight: 600; }
.result .sub { color: #8a8aa0; font-size: .85rem; }
.badge {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .1rem .4rem; border-radius: 4px; margin-right: .5rem; vertical-align: middle;
}
.badge.usda { background: #1f3d1f; color: #8fe08f; }
.badge.off  { background: #1f2d3d; color: #8fc6e0; }
.empty { color: #8a8aa0; padding: .7rem .6rem; }
.kcal { color: #8a8aa0; }
.result .sub .kcal { margin-left: .5rem; }
.vcount { margin-left: .5rem; color: #9aa0ff; }
/* Variant / serving dropdown above the label */
.variant-pick { display: block; font-size: .8rem; color: #9a9ab0; margin-bottom: .6rem; }
.variant-pick select {
  display: block; margin-top: .25rem; width: 100%; max-width: 320px;
  background: #16161f; color: #e6e6ef; border: 1px solid #33334a; border-radius: 6px; padding: .35rem .4rem;
}
/* Nutri-Score chip — same footprint as the source badge */
.nutri { display: inline-block; margin-left: .5rem; font-size: .62rem; font-weight: 800;
  letter-spacing: .06em; padding: .1rem .4rem; border-radius: 4px; vertical-align: middle; }
.nutri-a { background: #038141; color: #fff; }
.nutri-b { background: #85bb2f; color: #062; }
.nutri-c { background: #fecb02; color: #5a4a00; }
.nutri-d { background: #ee8100; color: #fff; }
.nutri-e { background: #e63e11; color: #fff; }

/* ── FDA-style Nutrition Facts label ───────────────────────────── */
.label-panel { }
.nf {
  background: #fff; color: #000; width: 100%; max-width: 320px;
  border: 1px solid #000; padding: 6px 9px; font-family: Helvetica, Arial, sans-serif;
}
.nf * { margin: 0; }
.nf .brand { font-size: 11px; color: #333; }
.nf .name { font-size: 14px; font-weight: bold; line-height: 1.2; margin-bottom: 2px; }
.nf .title { font-size: 30px; font-weight: 800; border-bottom: 1px solid #000; letter-spacing: -.5px; }
.nf .serving { font-size: 12px; padding: 2px 0; }
.nf .serving-select { font: inherit; font-size: 12px; color: #000; background: #fff;
  border: 1px solid #000; border-radius: 3px; padding: 1px 3px; max-width: 200px; }
.nf .bar { border-top: 10px solid #000; }
.nf .cal-row { display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 4px solid #000; padding: 2px 0; }
.nf .cal-row .lbl { font-weight: 800; font-size: 13px; }
.nf .cal-row .val { font-weight: 800; font-size: 26px; }
.nf .dv-head { text-align: right; font-size: 11px; font-weight: bold; padding: 2px 0;
  border-bottom: 1px solid #000; }
.nf table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nf td { padding: 1px 0; border-bottom: 1px solid #000; vertical-align: baseline; }
.nf td.dv { text-align: right; font-weight: bold; }
.nf .ind { padding-left: 16px; }
.nf .ind2 { padding-left: 32px; font-style: italic; }
.nf b { font-weight: 800; }
.nf .thick td { border-bottom-width: 6px; }
.nf .footnote { font-size: 10px; line-height: 1.25; padding-top: 4px; color: #000; }
.nf .ingredients { font-size: 10px; color: #222; padding-top: 6px; }
.nf .na { font-size: 11px; color: #555; padding-top: 4px; }
