:root {
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-mono: 'Courier New', Courier, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background: #0d0f0a; color: #e8e6df; min-height: 100vh; }

/* Prevent iOS from zooming into focused inputs (font-size < 16px triggers zoom) */
@media (max-width: 640px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ── TOPBAR ── */
.topbar {
  background: #0a0c08;
  border-bottom: 1px solid #1e2219;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
}
.logo { font-size: 15px; font-weight: 500; color: #b8d96e; letter-spacing: 0.04em; margin-right: 28px; flex-shrink: 0; }
.logo span { color: #555549; font-weight: 400; font-size: 12px; }

.nav { display: flex; gap: 2px; flex: 1; }
.nav-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: #8a8a7a;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-btn:hover { background: #1c201a; color: #e8e6df; }
.nav-btn.active { background: #1c201a; color: #b8d96e; }
.nav-icon { font-size: 14px; }

.pro-badge {
  margin-left: auto;
  background: #b8d96e;
  color: #0a0c08;
  font-size: 10px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 100px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── SCREENS ── */
.screen { display: none; padding: 24px 20px; max-width: 860px; margin: 0 auto; }
.screen.active { display: block; }

/* ── SHARED ── */
.search-wrap {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.search-row { display: flex; gap: 8px; }
.search-input {
  flex: 1;
  background: #1c201a;
  border: 1px solid #2a2f26;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: #e8e6df;
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}
.search-input:focus { border-color: #b8d96e; }
.search-input::placeholder { color: #555549; }

.btn-go {
  background: #b8d96e;
  color: #0a0c08;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.btn-go:hover { background: #caea82; }
.btn-go:disabled { opacity: 0.4; cursor: not-allowed; }

.pills-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.qpill {
  padding: 4px 11px;
  border-radius: 100px;
  background: #1c201a;
  border: 1px solid #2a2f26;
  font-size: 11px;
  color: #8a8a7a;
  cursor: pointer;
  transition: all 0.13s;
  font-family: var(--font-sans);
}
.qpill:hover { border-color: #b8d96e; color: #b8d96e; }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 2px solid #2a2f26;
  border-top-color: #b8d96e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { font-size: 12px; color: #8a8a7a; font-family: var(--font-sans); }

.result-area { animation: fadeUp 0.3s ease both; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── IDLE CARDS ── */
.idle-card {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 8px;
  padding: 16px;
}
.idle-icon { font-size: 20px; margin-bottom: 8px; }
.idle-title { font-size: 13px; font-weight: 500; color: #e8e6df; margin-bottom: 4px; }
.idle-body { font-size: 12px; color: #8a8a7a; line-height: 1.6; }

/* ── CHIPS ── */
.chip {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.chip-green { background: rgba(109,184,122,0.15); color: #6db87a; border: 0.5px solid rgba(109,184,122,0.3); }
.chip-yellow { background: rgba(232,197,71,0.12); color: #e8c547; border: 0.5px solid rgba(232,197,71,0.3); }
.chip-gem { background: rgba(184,217,110,0.1); color: #b8d96e; border: 0.5px solid rgba(184,217,110,0.25); }
.chip-hype { background: rgba(212,120,90,0.1); color: #d4785a; border: 0.5px solid rgba(212,120,90,0.2); }
.chip-acc { background: rgba(109,184,122,0.08); color: #6db87a; border: 0.5px solid rgba(109,184,122,0.2); }

/* ── SECTION CARDS ── */
.sec-card {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.sec-hdr {
  padding: 11px 14px;
  background: #1c201a;
  border-bottom: 1px solid #2a2f26;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.sec-hdr-icon { font-size: 13px; }
.sec-hdr-title { font-size: 11px; font-weight: 500; color: #8a8a7a; text-transform: uppercase; letter-spacing: 0.1em; flex: 1; }
.sec-hdr-chev { font-size: 10px; color: #555549; transition: transform 0.2s; }
.sec-card.open .sec-hdr-chev { transform: rotate(180deg); }
.sec-body { display: none; padding: 14px; }
.sec-card.open .sec-body { display: block; }
.sec-lbl { font-size: 10px; color: #555549; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 5px; margin-top: 12px; }
.sec-lbl:first-child { margin-top: 0; }
.sec-txt { font-size: 12px; color: #e8e6df; line-height: 1.7; }
.sec-txt strong { color: #b8d96e; font-weight: 500; }

/* ── SHARED BOTTOM/ACTION ── */
.bottom-line-box {
  background: #141710;
  border-left: 3px solid #b8d96e;
  border-radius: 0 8px 8px 0;
  padding: 14px 16px;
  font-size: 13px;
  color: #e8e6df;
  line-height: 1.7;
  font-style: italic;
  font-family: var(--font-serif);
  margin-top: 10px;
}
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.act-btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #2a2f26;
  background: transparent;
  color: #8a8a7a;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.act-btn:hover { border-color: #b8d96e; color: #b8d96e; }

.disclaimer-box {
  background: rgba(232,197,71,0.05);
  border: 1px solid rgba(232,197,71,0.15);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 11px;
  color: #8a8a7a;
  line-height: 1.6;
  margin-top: 12px;
}

/* ── ENCYCLOPEDIA ── */
.food-hero {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 12px;
}
.food-name-big { font-size: 26px; font-weight: 500; color: #e8e6df; font-family: var(--font-serif); font-style: italic; }
.food-meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }

.score-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 14px; }
.score-box { background: #0d0f0a; border-radius: 6px; padding: 10px 12px; }
.score-lbl { font-size: 10px; color: #555549; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px; }
.score-val { font-size: 14px; color: #e8e6df; }
.score-sub { font-size: 11px; color: #8a8a7a; margin-top: 2px; }

.ev-list { display: flex; flex-direction: column; gap: 8px; }
.ev-item { display: flex; gap: 8px; align-items: flex-start; }
.ev-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.ev-g { background: #6db87a; }
.ev-y { background: #e8c547; }
.ev-r { background: #d4785a; }
.ev-claim { font-size: 12px; font-weight: 500; color: #e8e6df; }
.ev-detail { font-size: 11px; color: #8a8a7a; line-height: 1.5; margin-top: 2px; }

.bio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 4px; }
.bio-box { background: #0d0f0a; border-radius: 6px; padding: 10px; }

/* ── SUPPLEMENT ENCYCLOPEDIA ── */
.forms-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.form-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #0d0f0a;
  border: 1px solid transparent;
}
.form-recommended { border-color: rgba(184,217,110,0.2); background: rgba(184,217,110,0.04); }
.form-left { flex: 1; }
.form-name { font-size: 12px; font-weight: 500; color: #e8e6df; }
.form-rec-tag { font-size: 10px; font-weight: 500; color: #b8d96e; margin-left: 6px; }
.form-meta { font-size: 11px; color: #8a8a7a; margin-top: 3px; }
.form-note { font-size: 11px; color: #555549; margin-top: 2px; line-height: 1.5; }

/* ── SUPPLEMENT AUDITOR ── */
.stack-builder {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.stack-lbl { font-size: 11px; color: #555549; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px; }
.stack-tags { display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; margin-bottom: 12px; }
.stack-tag {
  padding: 4px 10px 4px 12px;
  border-radius: 100px;
  background: #1c201a;
  border: 1px solid #2a2f26;
  font-size: 12px;
  color: #e8e6df;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag-remove {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #2a2f26;
  color: #8a8a7a;
  border: none;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  flex-shrink: 0;
}
.tag-remove:hover { background: #d4785a; color: #fff; }
.add-row { display: flex; gap: 8px; }
.add-input {
  flex: 1;
  background: #1c201a;
  border: 1px solid #2a2f26;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #e8e6df;
  outline: none;
  font-family: var(--font-sans);
}
.add-input:focus { border-color: #b8d96e; }
.add-input::placeholder { color: #555549; }
.add-btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #2a2f26;
  background: transparent;
  color: #b8d96e;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
}
.add-btn:hover { background: #1c201a; }

.sugg-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.sugg-pill {
  padding: 3px 10px;
  border-radius: 100px;
  background: transparent;
  border: 1px solid #2a2f26;
  font-size: 11px;
  color: #555549;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.13s;
}
.sugg-pill:hover { border-color: #b8d96e; color: #b8d96e; }

.audit-result { display: flex; flex-direction: column; gap: 10px; }
.audit-overall {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 10px;
  padding: 16px;
}
.audit-score-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.audit-score {
  background: #0d0f0a;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}
.audit-score-num { font-size: 22px; font-weight: 500; }
.audit-score-lbl { font-size: 10px; color: #555549; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.audit-title { font-size: 14px; font-weight: 500; color: #e8e6df; }
.audit-sub { font-size: 12px; color: #8a8a7a; margin-top: 4px; line-height: 1.6; }

.finding-card {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 8px;
  padding: 14px;
}
.finding-type {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.finding-ind { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.finding-title { font-size: 13px; font-weight: 500; color: #e8e6df; margin-bottom: 4px; }
.finding-body { font-size: 12px; color: #8a8a7a; line-height: 1.6; }
.finding-body strong { color: #b8d96e; font-weight: 500; }
.finding-rec {
  margin-top: 8px;
  padding: 8px 10px;
  background: #0d0f0a;
  border-radius: 5px;
  font-size: 11px;
  color: #8a8a7a;
  border-left: 2px solid #b8d96e;
}

/* ── LABEL DECODER — MODE TOGGLE ── */
.decode-mode-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: #0d0f0a;
  border: 1px solid #2a2f26;
  border-radius: 7px;
  padding: 3px;
  width: fit-content;
}
.mode-tab {
  padding: 5px 14px;
  border-radius: 5px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: #8a8a7a;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.mode-tab:hover { color: #e8e6df; }
.mode-tab.active { background: #1c201a; color: #b8d96e; }

/* ── LABEL DECODER — UPLOAD ZONE ── */
.upload-zone {
  border: 1.5px dashed #2a2f26;
  border-radius: 8px;
  background: #1c201a;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-over { border-color: #b8d96e; background: rgba(184,217,110,0.04); }
.upload-zone.has-image { border-style: solid; cursor: default; }

#upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  gap: 8px;
  text-align: center;
}
.upload-icon { font-size: 28px; }
.upload-hint { font-size: 13px; color: #8a8a7a; line-height: 1.5; }
.upload-sub  { font-size: 11px; color: #555549; }

#upload-preview {
  flex-direction: column;
  align-items: center;
  padding: 16px;
  gap: 12px;
}
#preview-img {
  max-height: 200px;
  max-width: 100%;
  border-radius: 6px;
  object-fit: contain;
}
.upload-clear {
  padding: 5px 14px;
  border-radius: 5px;
  border: 1px solid #2a2f26;
  background: transparent;
  color: #8a8a7a;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.upload-clear:hover { border-color: #d4785a; color: #d4785a; }

/* ── LABEL DECODER ── */
.label-input-area {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.label-textarea {
  width: 100%;
  background: #1c201a;
  border: 1px solid #2a2f26;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #e8e6df;
  font-family: var(--font-mono);
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  outline: none;
}
.label-textarea:focus { border-color: #b8d96e; }
.label-textarea::placeholder { color: #555549; font-family: var(--font-sans); }

.label-examples { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ex-btn {
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid #2a2f26;
  background: transparent;
  color: #555549;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.13s;
}
.ex-btn:hover { border-color: #b8d96e; color: #b8d96e; }

.label-result { display: flex; flex-direction: column; gap: 10px; }

.overall-verdict {
  background: #141710;
  border: 1px solid #2a2f26;
  border-radius: 10px;
  padding: 16px;
}
.ov-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.ov-grade {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  flex-shrink: 0;
}
.grade-a { background: rgba(109,184,122,0.2); color: #6db87a; border: 2px solid rgba(109,184,122,0.4); }
.grade-b { background: rgba(184,217,110,0.15); color: #b8d96e; border: 2px solid rgba(184,217,110,0.3); }
.grade-c { background: rgba(232,197,71,0.15); color: #e8c547; border: 2px solid rgba(232,197,71,0.3); }
.grade-d { background: rgba(212,120,90,0.15); color: #d4785a; border: 2px solid rgba(212,120,90,0.3); }

.ingredient-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.ing-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #0d0f0a;
}
.ing-status { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.ing-name { font-size: 12px; font-weight: 500; color: #e8e6df; }
.ing-verdict { font-size: 11px; color: #8a8a7a; line-height: 1.5; margin-top: 2px; }
.ing-verdict strong { font-weight: 500; }
.ing-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.ib-good { background: rgba(109,184,122,0.12); color: #6db87a; }
.ib-ok { background: rgba(232,197,71,0.12); color: #e8c547; }
.ib-bad { background: rgba(212,120,90,0.12); color: #d4785a; }

/* ══════════════════════════════════════════════════════
   BOTTOM NAV — always in DOM, visible only on mobile
   ══════════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #0a0c08;
  border-top: 1px solid #1e2219;
  grid-template-columns: repeat(4, 1fr);
  /* Respect iPhone home indicator / notch */
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  min-height: 56px;
  border: none;
  background: transparent;
  color: #555549;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-tab:hover  { color: #e8e6df; }
.bottom-tab.active { color: #b8d96e; }

.bottom-tab-icon  { font-size: 20px; line-height: 1; }
.bottom-tab-label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ══════════════════════════════════════════════════════
   MOBILE BREAKPOINT  ≤ 640px
   ══════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* ── Topbar: hide nav buttons, keep logo + pro badge ── */
  .nav { display: none; }
  .topbar { padding: 0 16px; height: 48px; }
  .logo { font-size: 14px; margin-right: 0; }
  .pro-badge { font-size: 9px; padding: 3px 10px; }

  /* ── Show bottom nav ── */
  .bottom-nav { display: grid; }

  /* ── Screens: tighten padding, leave room for bottom nav ── */
  .screen { padding: 16px 14px 80px; }

  /* ── Search ── */
  .search-wrap { padding: 12px; }
  .search-row  { flex-wrap: wrap; }
  .btn-go      { min-height: 44px; padding: 10px 16px; width: 100%; }

  /* ── Quick pills: larger tap targets ── */
  .qpill      { padding: 7px 13px; font-size: 12px; min-height: 34px; }
  .sugg-pill  { padding: 6px 12px; font-size: 12px; min-height: 34px; }

  /* ── Hero card ── */
  .food-name-big { font-size: 22px; }
  .food-hero     { padding: 14px; }

  /* ── Score grids: 2 columns instead of auto-fit ── */
  .score-row       { grid-template-columns: repeat(2, 1fr); }
  .audit-score-row { grid-template-columns: repeat(2, 1fr); }

  /* ── Bio grid: single column on narrow screens ── */
  .bio-grid { grid-template-columns: 1fr 1fr; }

  /* ── Section cards ── */
  .sec-hdr  { padding: 10px 12px; }
  .sec-body { padding: 12px; }

  /* ── Bottom line ── */
  .bottom-line-box { font-size: 12px; padding: 12px 14px; }

  /* ── Action buttons: full-width stack ── */
  .action-row { flex-direction: column; }
  .act-btn    { min-height: 40px; text-align: center; }

  /* ── Auditor ── */
  .stack-builder    { padding: 12px; }
  .add-btn          { min-height: 44px; padding: 8px 16px; }
  .stack-tag        { font-size: 12px; }

  /* ── Decoder ── */
  .label-input-area { padding: 12px; }
  .decode-mode-toggle { width: 100%; justify-content: stretch; }
  .mode-tab         { flex: 1; text-align: center; min-height: 38px; }
  .ex-btn           { min-height: 36px; padding: 6px 12px; font-size: 12px; }
  #upload-placeholder { padding: 28px 16px; }

  /* ── Forms list (supp encyclopedia) ── */
  .form-row { flex-direction: column; gap: 8px; }

  /* ── Idle cards: single column on very small screens ── */
  .idle-card { padding: 14px; }
}
