/* Food Scout — design tokens shared with the approved mockup */
:root {
  --paper: #F6F4EF;
  --card: #FFFFFF;
  --ink: #1C2128;
  --ink-2: #5A6272;
  --line: #E3E0D8;
  --brand: #24466E;
  --brand-ink: #FFFFFF;
  --chip: #ECE9E1;
  --chip-on: #24466E;
  --chip-on-ink: #FFFFFF;
  --certified: #1F7A45;
  --certified-soft: #E2F1E8;
  --friendly: #9A6400;
  --friendly-soft: #F6ECD8;
  --unknown: #6B7280;
  --unknown-soft: #ECECEC;
  --danger: #B23A31;
  --danger-soft: #F7E4E2;
  --sheet-scrim: rgba(20, 24, 30, 0.45);
  --ph-a: #D9E2EC;
  --ph-b: #C3D0DE;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14171C;
    --card: #1D222A;
    --ink: #E8E6E0;
    --ink-2: #9AA3B2;
    --line: #2C333E;
    --brand: #7FA4D4;
    --brand-ink: #10141A;
    --chip: #262C36;
    --chip-on: #7FA4D4;
    --chip-on-ink: #10141A;
    --certified: #5CBB84;
    --certified-soft: #1C3A2A;
    --friendly: #D9A84E;
    --friendly-soft: #3A2F17;
    --unknown: #9AA3B2;
    --unknown-soft: #2A2F38;
    --danger: #E07A70;
    --danger-soft: #3E2321;
    --sheet-scrim: rgba(0, 0, 0, 0.6);
    --ph-a: #2A3340;
    --ph-b: #222A35;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.phone { max-width: 430px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* login */
.loginbox { margin: auto; width: 100%; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.loginbox h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.loginbox .sub { color: var(--ink-2); font-size: 14.5px; line-height: 1.5; margin: 0; }
.loginbox input {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 13px 14px; font-size: 17px; font-family: inherit;
}
.loginerr { color: var(--danger); font-size: 13.5px; margin: 0; }

/* header */
header.app { padding: 18px 16px 10px; }
.headrow { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; color: var(--ink-2); text-transform: uppercase; }
header.app h1, #app h1 { margin: 2px 0 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.synced { font-size: 11px; color: var(--ink-2); padding-bottom: 6px; white-space: nowrap; }
.search {
  margin-top: 12px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; color: var(--ink-2);
}
.search svg { flex: none; }
.search input { border: none; background: none; outline: none; color: var(--ink); font-size: 15px; width: 100%; font-family: inherit; }

/* filters */
.filters { padding: 6px 0 4px; }
.chiprow { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px; scrollbar-width: none; }
.chiprow::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.chip.on { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-ink); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.rowlabel { font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); padding: 6px 16px 0; }

/* grid */
main { flex: 1; padding: 8px 16px 110px; }
.count { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  cursor: pointer; display: flex; flex-direction: column; padding: 0; text-align: left;
  font-family: inherit; color: var(--ink);
}
.item:focus-visible, .chip:focus-visible, .tab:focus-visible, .addbtn:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.photo {
  position: relative; aspect-ratio: 1 / 0.85;
  background: linear-gradient(135deg, var(--ph-a), var(--ph-b));
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .initials { font-size: 34px; font-weight: 800; color: var(--ink-2); opacity: 0.55; }
.photo .phnote { position: absolute; bottom: 6px; right: 8px; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; color: var(--ink-2); opacity: 0.7; text-transform: uppercase; }
.verdict {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.flagstripe { background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; text-align: center; padding: 4px 0; }
.meta { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 7px; }
.iname { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.icat { font-size: 12px; color: var(--ink-2); }
.badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gf {
  font-size: 10px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase;
  border-radius: 6px; padding: 3px 7px; display: inline-flex; align-items: center; gap: 4px;
}
.gf.cert { background: var(--certified-soft); color: var(--certified); }
.gf.friendly { background: var(--friendly-soft); color: var(--friendly); }
.gf.unknown { background: var(--unknown-soft); color: var(--unknown); }
.gf.never { background: var(--danger-soft); color: var(--danger); }
.storedots { margin-left: auto; display: flex; gap: 3px; }
.storedot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); flex: none; }

/* tabs */
nav.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px; background: var(--card); border-top: 1px solid var(--line);
  display: flex; align-items: stretch;
  padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; background: none; border: none; color: var(--ink-2);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0 2px; cursor: pointer; font-family: inherit; text-transform: uppercase;
}
.tab.on { color: var(--brand); }
.addbtn {
  flex: none; align-self: center; width: 54px; height: 54px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); border: none;
  font-size: 30px; line-height: 1; cursor: pointer; margin: 0 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

/* sheets */
.scrim { position: fixed; inset: 0; background: var(--sheet-scrim); display: none; z-index: 20; }
.scrim.open { display: block; }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translate(-50%, 105%);
  width: 100%; max-width: 430px; background: var(--card);
  border-radius: 18px 18px 0 0; border: 1px solid var(--line); border-bottom: none;
  z-index: 21; max-height: 88vh; overflow-y: auto; transition: transform 0.28s ease;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
}
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
.sheet.open { transform: translate(-50%, 0); }
.grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.sheet .sub { color: var(--ink-2); font-size: 13px; margin: 0 0 14px; }
.dphoto {
  border-radius: 12px; aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--ph-a), var(--ph-b));
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); font-weight: 800; font-size: 40px; margin-bottom: 12px; overflow: hidden;
}
.dphoto img { width: 100%; height: 100%; object-fit: cover; }
.photostrip { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 9px 12px; font-size: 14px; margin: 14px 0; }
.kv .k { color: var(--ink-2); font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding-top: 2px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 700;
  border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.dangerline { color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 5px; }
.field input[type=text], .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; font-family: inherit;
}
.field textarea { min-height: 64px; resize: vertical; }
.seg { display: flex; gap: 7px; flex-wrap: wrap; }
.photoslots { display: flex; gap: 10px; margin-bottom: 14px; }
.photoslot {
  flex: 1; border: 1.5px dashed var(--brand); border-radius: 12px; padding: 14px 8px;
  text-align: center; color: var(--brand); font-weight: 700; font-size: 13px;
  cursor: pointer; background: none; font-family: inherit; position: relative; overflow: hidden;
}
.photoslot small { display: block; font-weight: 500; color: var(--ink-2); margin-top: 3px; font-size: 11px; }
.photoslot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }
.photoslot .slotlabel { position: relative; z-index: 1; }
.photoslot.filled { border-style: solid; }
.photoslot.filled .slotlabel { background: rgba(0,0,0,0.55); color: #fff; border-radius: 6px; padding: 2px 6px; display: inline-block; }

/* store run */
.storelist { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.storecard {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  cursor: pointer; font-family: inherit; color: var(--ink); font-size: 15px; text-align: left;
}
.storecard .bigdot { width: 18px; height: 18px; border-radius: 50%; flex: none; }
.storecard .sname { font-weight: 700; }
.storecard .scount { margin-left: auto; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.runnote { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; margin: 14px 0 0; }

/* toast */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-size: 13.5px; font-weight: 600;
  border-radius: 10px; padding: 10px 16px; z-index: 40; max-width: 90%;
}
