:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1c1f1d; --muted: #6a706b; --line: #e3dfd5;
  --brand: #1f3a2e; --brand-ink: #ffffff; --accent: #2f7d5b;
  --warn-bg: #fff1d6; --warn-ink: #8a5300; --ok-bg: #e2f3ea; --ok-ink: #1d6a45;
  --danger: #b3261e; --chip: #ece8dd; --chip-on: #1f3a2e; --chip-on-ink: #fff;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121512; --card: #1b1f1c; --ink: #ecefe9; --muted: #98a09a; --line: #2c322d;
    --brand: #0f1f17; --accent: #5cc796; --warn-bg: #3a2c10; --warn-ink: #ffd27a;
    --ok-bg: #153325; --ok-ink: #8fe0b5; --danger: #ff8a80; --chip: #262c27; --chip-on: #5cc796; --chip-on-ink: #0b1510;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.shell { max-width: 720px; margin: 0 auto; padding-bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 100vh; }
.topbar { background: var(--brand); color: var(--brand-ink); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 700; letter-spacing: .2px; }
.who { font-size: 13px; opacity: .85; }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; padding: 8px 4px; font-size: 13px; }

.sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 16px 8px; border-bottom: 1px solid var(--line); }
.search { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; font-size: 16px; }
.search:focus, .field:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; align-items: center; }
.scroll { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--chip); border-radius: 999px; padding: 0 14px; height: 38px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--chip-on); color: var(--chip-on-ink); }
.chip.avoid.on { background: var(--danger); color: #fff; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-top: 8px; }

.list { padding: 8px 16px 0; }
.cat { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; display: flex; justify-content: space-between; }
.dish { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; box-shadow: var(--shadow); overflow: hidden; }
.dish-main { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 56px; width: 100%; background: none; border: 0; text-align: left; }
.dn { flex: 1; font-weight: 600; font-size: 16px; }
.dish.hid .dn { opacity: .55; }
.ic { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }
.al { width: 34px; height: 34px; border-radius: 10px; background: var(--chip); display: grid; place-items: center; font-size: 20px; }
.badge { font-size: 12px; font-weight: 600; border-radius: 8px; padding: 5px 8px; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.muted { background: var(--chip); color: var(--muted); }
.dish-more { border-top: 1px solid var(--line); padding: 10px 14px 12px; font-size: 14px; }
.dish-more .contains { font-weight: 600; margin-bottom: 4px; }
.meta { color: var(--muted); font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0 0; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.notice button { background: none; border: 1px solid currentColor; color: inherit; border-radius: 8px; padding: 6px 10px; white-space: nowrap; }
.key { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; padding: 10px 2px 0; color: var(--muted); }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.nav-in { display: flex; width: 100%; max-width: 720px; }
.nav button { flex: 1; background: none; border: 0; padding: 8px 0 7px; min-height: 60px; display: grid; gap: 2px; justify-items: center; font-size: 12px; color: var(--muted); }
.nav button span { font-size: 22px; line-height: 1; }
.nav button.on { color: var(--accent); font-weight: 700; }

/* forms / cards */
.page { padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.field { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 0 12px; margin-bottom: 10px; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.lbl { display: block; font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
.btn { height: 48px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; padding: 0 18px; font-weight: 700; }
.btn.block { width: 100%; }
.btn.sec { background: var(--chip); color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn:disabled { opacity: .5; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0; }
.stack { display: grid; gap: 10px; }

.login { max-width: 380px; margin: 0 auto; padding: calc(60px + env(safe-area-inset-top)) 20px 20px; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }

/* allergen tick grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
.box { position: relative; border: 2px solid var(--line); border-radius: 14px; padding: 12px 10px; min-height: 76px; background: var(--bg); display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; }
.box .em { font-size: 26px; }
.box .nm { font-weight: 700; flex: 1; }
.tick { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; font-weight: 900; color: transparent; flex: none; }
.box.on { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--card)); }
.box.on .tick { background: var(--danger); border-color: var(--danger); color: #fff; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.preview { background: var(--chip); border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 22px; height: 22px; }

.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 720px; max-height: 94vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 12px; font-size: 19px; display: flex; justify-content: space-between; align-items: center; }
.x { background: var(--chip); border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 40; max-width: 90%; text-align: center; font-size: 15px; }
.toast.bad { background: var(--danger); }

/* history, users, drafts */
.hrow { border-bottom: 1px solid var(--line); padding: 10px 0; }
.hrow:last-child { border: 0; }
.hrow .t { font-weight: 600; }
.hrow .d { font-size: 14px; color: var(--muted); margin-top: 2px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 6px; background: var(--chip); margin-right: 6px; text-transform: uppercase; letter-spacing: .4px; }
.tag.allergens { background: var(--warn-bg); color: var(--warn-ink); }
.tag.delete, .tag.user-delete { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.urow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.urow:last-child { border: 0; }
.urow .n { flex: 1; font-weight: 600; }
.draft { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.draft .check { min-height: 0; }
.catrow { display: flex; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.catrow .n { flex: 1; }
.mini { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
