/* Tokens follow nutrilion-ai (apps/mobile/src/theme/tokens.ts, design.md):
   orange = the one tappable thing, teal = credibility only, warm neutrals, never pure black. */
:root {
  --orange: #FCA104;
  --orange-600: #E08D00;
  --orange-50: #FFF4E0;
  --teal: #04B6B0;
  --teal-600: #039B96;
  --teal-50: #E3F7F6;
  --ink: #1B1A17;
  --ink-2: #54514A;
  --ink-3: #8A867D;
  --line: #ECE7DD;
  --cream: #FFF8EE;
  --surface: #FFFFFF;
  --sunken: #F1EFEA;
  --tint-1: #FFF4E0;
  --tint-2: #E3F7F6;
  --tint-3: #E9F6EC;
  --tint-4: #F2EEFB;
  /* macro chart — data colours, not controls */
  --fat: #54514A;
  --carb: #FCA104;
  --protein: #04B6B0;
  --track: #F1EFEA;
  --shadow-card: 0 8px 24px #0000000A;
  --shadow-brand: 0 10px 26px #FCA10455;
  --r-card: 18px;
  --r-md: 12px;
  --gutter: 20px;
  font-family: "Inter", "Noto Sans TC", -apple-system, "PingFang HK", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font-size: 15px; line-height: 1.6; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--ink-3); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.topbar { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; gap: 20px; align-items: center; padding-top: 14px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 17px; letter-spacing: -0.3px; white-space: nowrap; }
.brand-mark { width: 10px; height: 10px; border-radius: 999px; background: var(--orange); }
.search { flex: 1; position: relative; max-width: 520px; margin-left: auto; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input {
  width: 100%; height: 42px; padding: 0 16px 0 40px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--cream); font-size: 15px;
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--orange); background: var(--surface); }
.groupbar { display: flex; gap: 8px; overflow-x: auto; padding: 0 var(--gutter) 12px; max-width: 1040px; margin: 0 auto; scrollbar-width: none; }
.groupbar::-webkit-scrollbar { display: none; }
.groupbar a {
  flex: none; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.groupbar a:hover { border-color: var(--ink-3); }
.groupbar a.on { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

main.wrap { padding-top: 32px; padding-bottom: 56px; min-height: 60vh; }

/* ---------- shared ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-card); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.section-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; margin: 0; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 0 0 24px; }
.crumbs a:hover { color: var(--orange-600); }
.crumbs .icon { width: 14px; height: 14px; }
.crumbs span:last-child { color: var(--ink-2); }
h1.page { font-size: 32px; font-weight: 900; letter-spacing: -0.6px; line-height: 1.15; margin: 0 0 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.pill .icon { width: 14px; height: 14px; }
.pill.trust { background: var(--teal-50); color: var(--teal-600); }
.pill.soft { background: var(--sunken); color: var(--ink-2); }
.tile { border-radius: 14px; display: grid; place-items: center; flex: none; }
.t1 { background: var(--tint-1); } .t2 { background: var(--tint-2); } .t3 { background: var(--tint-3); } .t4 { background: var(--tint-4); }

/* ---------- home ---------- */
body.is-home .topbar .search { display: none; }
.home-hero { max-width: 640px; margin: 8px auto 40px; text-align: center; }
.home-hero .pill { margin-bottom: 14px; }
.home-hero h1 { font-size: 36px; font-weight: 900; letter-spacing: -0.8px; line-height: 1.15; margin: 0 0 8px; }
.home-hero p { color: var(--ink-2); margin: 0 0 24px; }
.home-hero .search { max-width: none; margin: 0; }
.home-hero .search input { height: 54px; font-size: 16px; padding-left: 46px; background: var(--surface); box-shadow: var(--shadow-card); }
.home-hero .search .icon { left: 18px; width: 20px; height: 20px; }
.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.quick a { font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.quick a:hover { border-color: var(--ink-3); color: var(--ink); }
.meta-line { margin-top: 18px; font-size: 13px; color: var(--ink-3); }
.meta-line b { color: var(--ink); font-weight: 800; }

.home-section { margin-bottom: 40px; }
.section-head a { font-size: 13px; font-weight: 700; color: var(--orange-600); }

.featured { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.featured a { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 10px; transition: border-color .15s; }
.featured a:hover { border-color: var(--ink-3); }
.featured .nm { font-weight: 700; line-height: 1.3; }
.featured .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.featured .kc { font-size: 24px; font-weight: 900; letter-spacing: -0.5px; line-height: 1; margin-top: auto; }
.featured .kc small { font-size: 12px; font-weight: 600; letter-spacing: 0; color: var(--ink-3); margin-left: 3px; }
.featured .stack { height: 6px; margin: 0; }
.featured .pcf { display: flex; gap: 10px; font-size: 12px; color: var(--ink-3); }
.featured .pcf b { color: var(--ink); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid a {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px; transition: border-color .15s;
}
.grid a:hover { border-color: var(--ink-3); }
.grid .txt { flex: 1; min-width: 0; }
.grid strong { display: block; font-size: 15px; font-weight: 700; line-height: 1.3; }
.grid .sub { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid .count { font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--sunken); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.grid .icon { color: var(--ink-3); width: 16px; height: 16px; }

/* ---------- group ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.tabs a { font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.tabs a:hover { border-color: var(--ink-3); }
.tabs a.on { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.toolbar select { height: 36px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; }

/* ---------- lists ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 14px 10px; margin: 0 -10px; border-radius: var(--r-md); }
.list a:hover { background: var(--cream); }
.list .nm { font-weight: 700; line-height: 1.3; }
.list .sub { display: block; font-size: 13px; color: var(--ink-3); line-height: 1.4; margin-top: 2px; }
.list .kc { font-weight: 800; font-size: 17px; white-space: nowrap; align-self: center; text-align: right; line-height: 1.1; }
.list .kc small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); }

/* ---------- food ---------- */
.food-head { display: flex; gap: 20px; align-items: flex-start; }
.food-head .tile { width: 72px; height: 72px; font-size: 36px; border-radius: 18px; }
.food-head h1 { margin: 0; font-size: 32px; font-weight: 900; letter-spacing: -0.6px; line-height: 1.15; }
.food-head .en { color: var(--ink-2); margin: 4px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.serving-row { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.serving { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.serving button {
  height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 700;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.serving button:hover { border-color: var(--ink-3); }
.serving button.on { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.serving label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.serving input { width: 76px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--cream); }
.serving input:focus { outline: none; border-color: var(--orange); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col .card { margin-bottom: 0; }
.food-page > .two-col { margin-bottom: 20px; }

.kcal-card { background: var(--ink); color: #FFFFFF; border-radius: var(--r-card); padding: 20px 22px; margin-top: 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.kcal-card .eyebrow { color: #9C988E; }
.kcal-card .big { font-size: 44px; font-weight: 900; letter-spacing: -1px; line-height: 1; margin-top: 6px; }
.kcal-card .big small { font-size: 15px; font-weight: 600; letter-spacing: 0; color: #D6D2C8; margin-left: 4px; }
.kcal-card .pcf { display: flex; gap: 24px; }
.kcal-card .pcf div { text-align: right; }
.kcal-card .pcf b { display: block; font-size: 17px; font-weight: 800; }
.kcal-card .pcf span { font-size: 12px; font-weight: 600; color: #9C988E; }
.stack { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--track); margin-bottom: 20px; }
.stack i { display: block; height: 100%; }
.ring { display: flex; justify-content: center; margin: 4px 0 24px; }
.ring svg { width: 180px; height: 180px; }
.bars { display: grid; gap: 18px; }
.bar-row .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.bar-row .nm { font-weight: 700; }
.bar-row .v { font-weight: 800; }
.bar-row .v small { font-weight: 600; color: var(--ink-3); font-size: 13px; margin-left: 6px; }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; }
.note { font-size: 12px; color: var(--ink-3); margin: 18px 0 0; line-height: 1.5; }

/* supplement-facts style panel */
.label { border: 2px solid var(--ink); border-radius: 14px; padding: 16px 18px; }
.label h3 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.4px; border-bottom: 8px solid var(--ink); padding-bottom: 6px; }
.label .per { font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--ink); padding: 6px 0; }
.label .per b { color: var(--ink); }
.label table { width: 100%; border-collapse: collapse; }
.label td { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.label td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.label tr:last-child td { border-bottom: 0; }
.label tr.major td { font-weight: 700; }
.label tr.sub td:first-child { padding-left: 16px; color: var(--ink-2); }
.label tr.sec td { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--ink-3); padding-top: 14px; border-bottom: 2px solid var(--ink); }
.src { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; line-height: 1.5; }

.footer { font-size: 13px; color: var(--ink-3); padding-top: 20px; padding-bottom: 40px; border-top: 1px solid var(--line); }
.footer a { color: var(--orange-600); font-weight: 700; }

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  h1.page, .food-head h1 { font-size: 26px; letter-spacing: -0.5px; }
  .food-head .tile { width: 56px; height: 56px; font-size: 28px; }
  .featured { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-hero h1 { font-size: 28px; letter-spacing: -0.5px; }
  .kcal-card .big { font-size: 36px; }
  .kcal-card { flex-direction: column; align-items: stretch; }
  .kcal-card .pcf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-top: 14px; border-top: 1px solid #36342F; }
  .kcal-card .pcf div { text-align: left; }
  .card { padding: 20px; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; gap: 12px; }
  .search { max-width: none; flex-basis: 100%; }
}
