:root {
  --bg: #f6f6f4; --card: #ffffff; --ink: #141414; --muted: #6b6b6b; --line: #e4e4e0;
  --in: #1f7a4a; --in-bg: #e5f3ea; --out: #9a3412; --out-bg: #fbe9e1;
  --pending: #6b6b6b; --pending-bg: #ececea;
  --miss: #c81e1e; --miss-bg: #fff1f1; --warn-bg: #fff7e0;
  --radius: 14px; --tap: 52px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff; padding: 10px 16px 10px; padding-top: calc(10px + env(safe-area-inset-top)); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brandmark { font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.who { background: #2a2a2a; border: 0; border-radius: 999px; color: #fff; padding: 6px 12px; font-size: 14px; }
.progress { margin-top: 8px; }
.bar { height: 8px; background: #333; border-radius: 99px; overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; transition: width .3s; }
#bar-in { background: #4ade80; } #bar-out { background: #fb923c; }
.progress-text { font-size: 13px; color: #cfcfcf; margin-top: 6px; }

main { padding: 12px 16px 120px; max-width: 720px; margin: 0 auto; }

/* list view */
.filters { display: grid; gap: 8px; margin-bottom: 12px; }
.search { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: #fff; font-size: 16px; }
.row { display: flex; gap: 8px; }
.row select { flex: 1; height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; background: #fff; font-size: 15px; min-width: 0; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.tab[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.start { width: 100%; height: var(--tap); border: 0; border-radius: var(--radius); background: var(--ink); color: #fff; font-weight: 600; font-size: 16px; margin-bottom: 12px; }
.count { font-size: 13px; color: var(--muted); margin: 4px 2px 8px; }

.list { display: grid; gap: 8px; }
.card { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; text-decoration: none; }
.card img, .card .noimg { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #eee; flex: none; }
.card .meta { min-width: 0; flex: 1; }
.card .key { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pills { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.pill.pending { background: var(--pending-bg); color: var(--pending); }
.pill.in_shop { background: var(--in-bg); color: var(--in); }
.pill.not_in_shop { background: var(--out-bg); color: var(--out); }
.pill.miss { background: var(--miss-bg); color: var(--miss); }
.more { width: 100%; height: 46px; margin-top: 8px; border: 1px solid var(--line); background: #fff; border-radius: 12px; }

/* brand summary */
.brands { display: grid; gap: 6px; margin: 4px 0 14px; }
.brandline { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.brandline .mini { grid-column: 1 / -1; height: 5px; background: var(--pending-bg); border-radius: 99px; overflow: hidden; display: flex; }
.brandline .mini span:first-child { background: var(--in); } .brandline .mini span:last-child { background: #fb923c; }
details.summary > summary { font-size: 14px; font-weight: 600; padding: 6px 2px; cursor: pointer; }

/* review view */
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 6px 0; font-size: 15px; color: var(--muted); }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; border-radius: var(--radius); scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.export { display: flex; align-items: center; justify-content: center; text-decoration: none; margin-bottom: 12px; }
.gallery img { flex: none; width: 100%; height: min(100vw - 32px, 46vh); object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); scroll-snap-align: center; }
.gallery .noimg { width: 100%; aspect-ratio: 2; display: grid; place-items: center; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.dots { text-align: center; font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.ident { margin: 10px 0 4px; }
.ident h1 { font-size: 22px; margin: 0; word-break: break-all; }
.ident .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.codes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.code { font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; }
.code b { font-weight: 600; }

.question { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.question h2 { font-size: 18px; margin: 0 0 12px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 16px; padding: 0 14px; }
.btn.yes { background: var(--in); color: #fff; border-color: var(--in); }
.btn.no { background: #fff; color: var(--out); border-color: #f0c2ae; }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }

.status-box { border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; font-size: 14px; }
.status-box.in_shop { background: var(--in-bg); color: var(--in); }
.status-box.not_in_shop { background: var(--out-bg); color: var(--out); }
.status-box b { font-size: 16px; }

.missing-banner { background: var(--miss-bg); border: 1px solid #f5b5b5; color: var(--miss); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 0 0 12px; }
.missing-banner.ok { background: var(--in-bg); border-color: #b7dfc5; color: var(--in); }
form.edit { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 16px; }
.field textarea { min-height: 80px; resize: vertical; }
.field.missing input, .field.missing select { border-color: var(--miss); background: var(--miss-bg); }
.field.missing label { color: var(--miss); }
.field .flag { font-size: 11px; font-weight: 700; background: var(--miss); color: #fff; border-radius: 99px; padding: 1px 8px; }
.field.missing .flag { display: inline-block; } .field .flag { display: none; }
.field .was { font-size: 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 10px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.qty { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); gap: 8px; align-items: center; }
.qty button { height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 24px; }
.qty input { text-align: center; font-size: 22px; font-weight: 700; height: var(--tap); }
.qty-field.missing input { border-color: var(--miss); background: var(--miss-bg); }

.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.actionbar .inner { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.actionbar .hint { grid-column: 1 / -1; font-size: 12px; color: var(--miss); text-align: center; min-height: 0; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; }
.sheet { background: #fff; width: 100%; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.sheet h3 { margin: 0 0 6px; font-size: 18px; }
.sheet p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.sheet .grid { display: grid; gap: 8px; margin-top: 12px; }

.log { font-size: 12px; color: var(--muted); margin-top: 18px; }
.log div { padding: 2px 0; }

#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; max-width: 90vw; }
#toast.show { opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---- sign in / account */
.top[hidden] { display: none; }
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth-mark { font-weight: 800; letter-spacing: .04em; font-size: 14px; text-transform: uppercase; color: var(--muted); }
.auth h1, .page-title { font-size: 26px; margin: 6px 0 18px; }
.auth-note { font-size: 13px; color: var(--muted); margin: 14px 2px 0; }
.form-error { color: var(--miss); font-size: 14px; min-height: 1em; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 8px 0 12px; }
.panel h1 { font-size: 22px; margin: 0; }
.panel .sub, .user .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stack { display: grid; gap: 8px; margin-bottom: 14px; }
.linkbtn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.signout { color: var(--miss); }
.section { font-size: 16px; margin: 20px 2px 8px; }
.user { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.user.off { opacity: .6; }
.user .key { font-weight: 600; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.row input { flex: 1; min-width: 0; }

/* ---- brands home */
.home-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 10px; }
.home-head h1 { font-size: 24px; margin: 0; }
.link { font-size: 15px; font-weight: 600; }
.home-head + .search { margin-bottom: 10px; }
.brand-tile { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-decoration: none; margin-bottom: 10px; }
.brand-tile img, .brand-tile .noimg { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--pending-bg); flex: none; }
.brand-tile .bt-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.bt-name { font-weight: 700; font-size: 16px; }
.bt-sub { font-size: 13px; color: var(--muted); }
.bt-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.brand-tile .mini { height: 6px; background: var(--pending-bg); border-radius: 99px; overflow: hidden; display: flex; }
.brand-tile .mini span:first-child { background: var(--in); } .brand-tile .mini span:last-child { background: #fb923c; }
.brand-tile.complete { border-color: #b7dfc5; }
.brand-grid { display: grid; gap: 0 10px; }
@media (min-width: 640px) { .brand-grid { grid-template-columns: 1fr 1fr; } }
.list-head select { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; background: #fff; font-size: 16px; font-weight: 600; margin: 4px 0 8px; }
.all-done { background: var(--in-bg); color: var(--in); border-radius: var(--radius); padding: 12px; text-align: center; font-weight: 600; margin-bottom: 12px; }
.brand-tile .all-tile { background: var(--ink); color: #fff; display: grid; place-content: center; text-align: center; font-weight: 800; font-size: 18px; line-height: 1; }
.brand-tile .all-tile small { display: block; font-size: 10px; font-weight: 600; opacity: .7; margin-top: 2px; }
