/* Eat or Not phone app. Layout: one thumb-reach column: actions on top, the result card as the hero, lists below. */
:root {
  --bg: #f3f6f2;
  --surface: #ffffff;
  --sunk: #e8eee7;
  --ink: #142019;
  --muted: #56675b;
  --line: #d5dfd5;
  --accent: #23703f;
  --accent-ink: #ffffff;
  --treat: #c43d2b;
  --sometimes: #d98a1f;
  --good: #7fae2f;
  --great: #23894a;
  /* System fonts only: nothing loads from another site (Google Fonts is blocked in China). */
  --display: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1511; --surface: #172019; --sunk: #1d2a20; --ink: #e5eee6; --muted: #9aae9f; --line: #2a392e;
  --accent: #5cc47f; --accent-ink: #0f1511; --treat: #ec6a55; --sometimes: #eda640; --good: #a5cf55; --great: #4fc277;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0f1511; --surface: #172019; --sunk: #1d2a20; --ink: #e5eee6; --muted: #9aae9f; --line: #2a392e;
  --accent: #5cc47f; --accent-ink: #0f1511; --treat: #ec6a55; --sometimes: #eda640; --good: #a5cf55; --great: #4fc277;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
.app { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
header { display: flex; align-items: baseline; justify-content: space-between; padding-top: 20px; gap: 12px; }
.brand { font: 800 30px/1 var(--display); letter-spacing: -.02em; margin: 0; }
.brand em { font-style: normal; color: var(--accent); }
.tag { font-size: 13px; color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.act {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 96px; justify-content: center; text-align: center;
}
.act .ico { font-size: 28px; line-height: 1; }
.act b { font: 600 14px/1.2 var(--body); }
.act[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.act:disabled { opacity: .45; cursor: not-allowed; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font: 600 17px/1.3 var(--display); margin: 0; }
.panel p { margin: 0; font-size: 14px; color: var(--muted); }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
textarea { width: 100%; min-height: 96px; resize: vertical; font: 16px/1.4 var(--body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 16px; font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

.status { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--sunk); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.error { color: var(--treat); font-size: 14px; }

/* Result card */
.result { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.result .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.example { font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; background: var(--sunk); padding: 4px 8px; border-radius: 99px; }
.result h2 { font: 600 22px/1.2 var(--display); margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.scoreline { display: flex; align-items: baseline; gap: 12px; }
.big { font: 800 76px/0.9 var(--display); letter-spacing: -.03em; color: var(--sc); font-variant-numeric: tabular-nums; }
.outof { font: 600 18px var(--display); color: var(--muted); }
.verdict { font: 600 20px var(--display); color: var(--sc); margin-left: auto; text-align: right; }
.meter { position: relative; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--treat) 0%, var(--sometimes) 38%, var(--good) 62%, var(--great) 100%); }
.meter i { position: absolute; top: -5px; width: 6px; height: 20px; margin-left: -3px; border-radius: 3px; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.meter-scale { display: flex; justify-content: space-between; font: 500 11px var(--mono); color: var(--muted); margin-top: -8px; }
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reasons li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.reasons li::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--dot); }
.note { font-size: 13px; color: var(--muted); background: var(--sunk); border-radius: 10px; padding: 8px 10px; }
.about { font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.about b { font-weight: 600; }
.options { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 500; }
.swap { background: var(--sunk); border-radius: 12px; padding: 12px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.swap .sn { font-weight: 600; }
details { border-top: 1px solid var(--line); padding-top: 10px; }
summary { font-weight: 600; font-size: 14px; cursor: pointer; color: var(--accent); }
.grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin-top: 10px; font-size: 14px; }
.grid span:nth-child(even) { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.grid .sep { grid-column: 1 / -1; border-top: 1px dashed var(--line); margin: 4px 0; }
.small { font-size: 12px; color: var(--muted); margin-top: 8px; }
.result-actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* Recent */
.recent h3 { font: 600 15px var(--display); margin: 0 0 8px; color: var(--muted); letter-spacing: .02em; }
.recent ul { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.recent li + li { border-top: 1px solid var(--line); }
.recent button { width: 100%; background: none; border: none; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; }
.recent .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.recent .when { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.recent .by { display: block; font-size: 12px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.lists-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 3px; }
.seg button { white-space: nowrap; border: none; background: none; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.count { font: 500 12px var(--mono); color: var(--muted); }
.family-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.family-tools input { flex: 1 1 180px; min-width: 0; font: 16px var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.family-tools input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.sortbtn { font-size: 13px; }
.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; background: var(--sunk); border-radius: 10px; padding: 8px 10px; }
.banner b { font-weight: 600; }
.seed { margin-top: 10px; }
.pill { flex: none; min-width: 44px; text-align: center; font: 500 14px var(--mono); padding: 3px 8px; border-radius: 99px; color: var(--surface); background: var(--sc); }
.empty { font-size: 14px; color: var(--muted); padding: 14px; background: var(--surface); border: 1px dashed var(--line); border-radius: 16px; }
.foot { font-size: 12px; color: var(--muted); text-align: center; }

/* Phase 2 additions */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; padding-top: env(safe-area-inset-top, 0px); }
.actions { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act { min-height: 88px; padding: 12px 4px 10px; }
.act b { font-size: 13px; }
.hello { font-size: 13px; color: var(--muted); }
input[type="text"], input[type="search"], input[inputmode="numeric"] {
  font: 16px var(--body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.join { max-width: 420px; margin: 12vh auto 0; }
.join .brand { font-size: 40px; margin-bottom: 8px; }
#scanner { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #000; }
#scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The band the reader looks at: the middle of the frame, edge to edge. */
.scan-guide { position: absolute; left: 6%; right: 6%; top: 30%; bottom: 30%; border: 2px solid rgba(255,255,255,.85); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.28); pointer-events: none; }
.scan-guide::after { content: ""; position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: #ff5a4e; opacity: .8; }
#scanner.got .scan-guide { border-color: #3ecf6e; }
.scan-tools { margin-top: -4px; }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; }
.people { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.people .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge { font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--great) 18%, transparent); color: var(--great); }
@media (max-width: 380px) { .act .ico { font-size: 24px; } .act b { font-size: 12px; } }

/* Opening card, before the first check */
.welcome .lede { margin: 0; color: var(--muted); font-size: 15px; }
.ways { display: flex; flex-direction: column; gap: 8px; }
.way { display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px; font: inherit; color: inherit; }
.way .ico { font-size: 22px; width: 28px; text-align: center; flex: none; }
.way > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.way b { font-weight: 600; font-size: 15px; }
.way .small { color: var(--muted); font-size: 13px; }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Estimated badge and the "Score seems off?" form */
.badge.est { background: color-mix(in srgb, var(--sometimes) 20%, transparent); color: var(--sometimes); }
.feedback { display: flex; flex-direction: column; gap: 10px; background: var(--sunk); border-radius: 12px; padding: 12px; }
.feedback .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.feedback .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.feedback textarea { min-height: 56px; }

/* Label photo vs barcode data */
.dispute { display: flex; flex-direction: column; gap: 10px; border: 1px solid color-mix(in srgb, var(--sometimes) 55%, var(--line)); background: color-mix(in srgb, var(--sometimes) 9%, var(--surface)); border-radius: 14px; padding: 12px; }
.dispute p { margin: 0; font-size: 14px; }
.dispute ul { margin: 0; padding-left: 18px; font-size: 14px; }
.dispute .btn { align-self: flex-start; }
.cmp-wrap { overflow-x: auto; }
.cmp { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.cmp caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.cmp th { text-align: right; font-weight: 600; font-size: 12px; color: var(--muted); padding: 4px 6px; }
.cmp td { text-align: right; padding: 5px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.cmp td:first-child, .cmp th:first-child { text-align: left; white-space: normal; }
.cmp tr.differs td { background: color-mix(in srgb, var(--sometimes) 18%, transparent); font-weight: 600; }
.cmp tr.score-row td { font-weight: 700; }
.cmp-done summary { font-size: 13px; color: var(--muted); cursor: pointer; }
.cmp-done .cmp-wrap { margin-top: 8px; }

/* Language switch */
.head-right { display: flex; align-items: center; gap: 10px; }
.langbtn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 11px; font: 600 13px/1 var(--body); }
.join-top { display: flex; justify-content: flex-end; }
:lang(zh-Hans) body { font-family: var(--body), "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
.alt-name { margin-top: -8px; font-size: 13px; color: var(--muted); }
.join-hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
