:root {
  --bg: #f6f7f4; --surface: #ffffff; --surface-2: #eef1ec; --text: #1b211d; --muted: #5d6860;
  --line: #dde2dc; --accent: #1f7a5a; --accent-ink: #ffffff; --accent-soft: #e2f1ea;
  --l5: #b42318; --l4: #c4560c; --l3: #9a6700; --l2: #3d63b8; --l1: #5d6860;
  --l5bg: #fde8e6; --l4bg: #fdeedd; --l3bg: #fbf3d5; --l2bg: #e5edfb; --l1bg: #eceeeb;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513; --surface: #1b1f1c; --surface-2: #242a26; --text: #e7ece8; --muted: #9aa69e;
    --line: #2f3631; --accent: #4cc493; --accent-ink: #0d1a14; --accent-soft: #1d3a2e;
    --l5: #ff8a80; --l4: #ffab6b; --l3: #e8c35a; --l2: #8fb0ff; --l1: #a6b0a9;
    --l5bg: #3d1c1a; --l4bg: #3b2616; --l3bg: #352d12; --l2bg: #1c2742; --l1bg: #262b28;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: .3rem 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.small { font-size: .875rem; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .75rem; justify-content: space-between;
  padding: .55rem max(1rem, calc((100% - 760px) / 2)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: .15rem; overflow-x: auto; }
.tabs a { padding: .4rem .65rem; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .92rem; white-space: nowrap; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 430px) { .brand span { display: none; } .tabs a { padding: .4rem .55rem; } }

main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.foot { max-width: 760px; margin: 0 auto; padding: 0 1rem 2rem; text-align: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 .9rem; box-shadow: var(--shadow); }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1; min-width: 0; }

input, button, .btn { font: inherit; }
input[type=search], input:not([type]), input[inputmode] {
  width: 100%; padding: .65rem .8rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
input:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .62rem 1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; min-height: 44px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .875rem; }
.btn.danger { color: var(--l5); }
.btn:disabled { opacity: .55; cursor: default; }
.msg { margin: .6rem 0 0; color: var(--muted); font-size: .9rem; min-height: 1em; }
.msg:empty { display: none; }
.examples { margin-top: .4rem; }

.cam { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; margin-bottom: .8rem; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .h5 { position: absolute; inset: 0; }
.cam .h5 video { width: 100% !important; height: 100% !important; object-fit: cover; }
.reticle { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 2px solid rgba(255,255,255,.85); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.cam-hint { position: absolute; left: 0; right: 0; bottom: .5rem; margin: 0; text-align: center; color: #fff; font-size: .85rem; text-shadow: 0 1px 3px #000; }

.results { list-style: none; margin: .6rem 0 0; padding: 0; }
.results li + li { border-top: 1px solid var(--line); }
.hit { display: flex; gap: .7rem; align-items: center; padding: .55rem .2rem; width: 100%; background: none; border: 0; color: inherit; text-align: left; cursor: pointer; font: inherit; text-decoration: none; }
.hit:hover { background: var(--surface-2); }
.thumb { width: 48px; height: 48px; flex: none; border-radius: 8px; object-fit: contain; background: var(--surface-2); }
.hit .t { flex: 1; min-width: 0; }
.hit .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit .t span { display: block; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--l1bg); color: var(--l1); white-space: nowrap; }

/* product */
.phead { display: flex; gap: 1rem; align-items: flex-start; }
.phead img { width: 104px; height: 104px; object-fit: contain; border-radius: 12px; background: #fff; border: 1px solid var(--line); flex: none; }
.phead h1 { margin-top: 0; font-size: 1.35rem; }
.meta { color: var(--muted); font-size: .9rem; }
.scores { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.score { display: flex; align-items: center; gap: .5rem; padding: .45rem .7rem; border-radius: 10px; background: var(--surface-2); font-size: .85rem; }
.score b { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 7px; color: #fff; font-size: 1rem; }
.ns-a { background: #038141; } .ns-b { background: #85bb2f; } .ns-c { background: #e5a800; } .ns-d { background: #ee8100; } .ns-e { background: #e63e11; }
.nova-1 { background: #00aa00; } .nova-2 { background: #c8a500; } .nova-3 { background: #ff6600; } .nova-4 { background: #e00000; }

.summary { display: flex; gap: .75rem; align-items: center; padding: .85rem 1rem; border-radius: var(--radius); margin: 0 0 .9rem; background: var(--accent-soft); }
.summary.has { background: var(--l3bg); }
.summary .n { font-size: 1.8rem; font-weight: 750; line-height: 1; }

.sub { border-left: 4px solid var(--lc, var(--l1)); }
.sub .hd { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; flex-wrap: wrap; }
.sub .codes { color: var(--muted); font-size: .85rem; }
.sub p { margin: .5rem 0; }
.sub .found { font-size: .82rem; color: var(--muted); }
.sub ul { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
.sub li { margin: .2rem 0; }
.lvl { --lc: var(--l1); --lb: var(--l1bg); background: var(--lb); color: var(--lc); }
.lv5 { --lc: var(--l5); --lb: var(--l5bg); } .lv4 { --lc: var(--l4); --lb: var(--l4bg); } .lv3 { --lc: var(--l3); --lb: var(--l3bg); }
.lv2 { --lc: var(--l2); --lb: var(--l2bg); } .lv1 { --lc: var(--l1); --lb: var(--l1bg); }
.research { display: inline-block; margin-top: .5rem; font-size: .88rem; font-weight: 600; }

.addlist { display: flex; flex-wrap: wrap; gap: .4rem; }
.add { padding: .3rem .6rem; border-radius: 8px; background: var(--surface-2); font-size: .85rem; }
.add.flag { background: var(--l3bg); }
.add b { margin-right: .25rem; }
.ingr { font-size: .92rem; overflow-wrap: anywhere; }
.disclaimer { background: var(--surface-2); font-size: .88rem; }
.levels { display: grid; gap: .5rem; }
.levels div { display: flex; gap: .6rem; align-items: baseline; font-size: .9rem; }

/* receipt */
.receipt-preview { max-height: 180px; margin-top: .8rem; border-radius: 8px; border: 1px solid var(--line); }
progress { width: 100%; margin-top: .6rem; accent-color: var(--accent); }
.line .row input { font-size: .95rem; }
.line .x { background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; padding: 0 .3rem; min-height: 44px; }
pre { white-space: pre-wrap; font-size: .8rem; max-height: 300px; overflow: auto; }

.hist .del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.2rem; padding: .3rem .5rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; max-width: calc(100% - 2rem); z-index: 20; }
@media (max-width: 430px) { .phead img { width: 80px; height: 80px; } h1 { font-size: 1.35rem; } }
