/* ═══════════════════════════════════════════════════════════════════════════
   IngredIQ — main.css
   Theme: Bio-Digital Synthesis (dark flat, lime accent, Tailwind-first)
   JS-coupled classes + legacy result-card styles (pending per-card redesign).
   ═══════════════════════════════════════════════════════════════════════════ */

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

  /* ── Palette ── */
  --bg-card:        rgba(6, 20, 26, 0.82);
  --bg-inner:       rgba(4, 14, 20, 0.88);
  --bg-hover:       rgba(10, 30, 40, 0.92);

  --border:         rgba(0, 196, 168, 0.16);

  --accent:         #00c4a8;   /* teal mint — was lime #b8d96e */
  --accent-hover:   #1ddfc4;
  --accent-text:    #050e10;   /* text on accent bg */

  --green:          #2dd494;   /* good / positive */
  --gold:           #c8980e;   /* warning */
  --red:            #d4705a;   /* bad / alert */

  --text:           #c8e8e4;   /* primary */
  --text-muted:     #567a76;   /* secondary */
  --text-dim:       #2a4e4a;   /* very muted */

  --glass-blur:     blur(16px) saturate(1.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── BODY ────────────────────────────────────────────────────────────────────
   Flat dark background — no background image. Bio-Digital Synthesis uses
   surface-lowest (#0d0f0a) as the base, with glass panels layered on top.
   ────────────────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #0d0f0a;  /* Bio-Digital Synthesis: surface-lowest — the "void" */
}

/* Prevent rubber-band / pull-to-refresh from dragging `position: fixed`
   elements (bottom nav) along with the page on iOS Safari and Android
   Chrome. Without this, scrolling past the top on mobile visibly shifts
   the bottom tab bar. */
html, body {
  overscroll-behavior-y: none;
  touch-action: pan-x pan-y;
}

/* Side-menu drawer row — used in #side-menu-panel nav blocks. Keep JS-free. */
.side-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 10px;
  color: var(--md-sys-color-on-surface, #e3e3da);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  background: transparent;
  transition: background-color 160ms ease, color 160ms ease;
}
.side-menu-item:hover:not(:disabled) {
  background: rgba(212, 246, 135, 0.06);
  color: #d4f687;
}
.side-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.side-menu-item .material-symbols-outlined {
  color: inherit;
  flex-shrink: 0;
  font-family: 'Material Symbols Outlined' !important;
  font-weight: normal !important;
  text-transform: none !important;
  font-style: normal !important;
  letter-spacing: normal !important;
  font-size: 20px;
  line-height: 1;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
}

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

/* ── TOPBAR ─────────────────────────────────────────────────────────────────
   Topbar shell, brand, pro-badge, user-section, sign-in button, dropdown
   container styling now live in Tailwind utilities on the markup itself
   (see <header> in index.html). Only the stateful nav buttons keep a CSS
   rule because JS toggles `.active`.
   ─────────────────────────────────────────────────────────────────────────── */

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: none;
  background: transparent;
  color: #c5c8b5;                             /* on-surface-variant */
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.nav-btn:hover {
  color: #e3e3da;                             /* on-surface */
  background: rgba(212, 246, 135, 0.05);
}
.nav-btn.active {
  color: #d4f687;                             /* primary */
  background: rgba(212, 246, 135, 0.10);
}

/* ── User dropdown row buttons ── */
.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  background: none;
  border: none;
  color: #e3e3da;
  font-family: var(--font-body);
  font-size: 13px;
  padding: 0.625rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.user-dropdown-btn:hover { background: rgba(212, 246, 135, 0.06); }
.user-dropdown-btn.danger { color: #ffb4ab; }
.user-dropdown-btn.danger:hover { background: rgba(255, 180, 171, 0.08); }

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

/* ── SHARED ─────────────────────────────────────────────────────────────────*/
.search-wrap {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.search-row { display: flex; gap: 8px; }
.search-input {
  flex: 1;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }

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

.pills-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Encyclopedia Browse tiles — container-query-driven pill scaling.
   One shared size per tile (both pills share the same cqw rule), single
   row, truncate on overflow. Fallback font-size kicks in on WebViews
   without container-query support (iOS 15 / old Android). */
.enc-tile { container-type: inline-size; }
.enc-tile .pills {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
  max-width: calc(100% - 16px);
}
.enc-tile .pill {
  max-width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 9999px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(52, 53, 47, 0.85);
  color: #d4f687;
  box-shadow: inset 0 0 0 1px rgba(212, 246, 135, 0.30);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  /* fallback for WebViews without container queries */
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 3px 7px;
}
@supports (font-size: 1cqw) {
  .enc-tile .pill {
    font-size: clamp(9px, 4.5cqw, 11px);
    letter-spacing: clamp(0.06em, 0.6cqw, 0.12em);
    padding: clamp(3px, 1.2cqw, 5px) clamp(8px, 2.5cqw, 12px);
  }
}
.qpill {
  padding: 4px 11px;
  border-radius: 100px;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.13s;
  font-family: var(--font-sans);
}
.qpill:hover { border-color: var(--accent); color: var(--accent); }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { font-size: 12px; color: var(--text-muted); 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: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.idle-icon { font-size: 20px; margin-bottom: 8px; }
.idle-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.idle-body { font-size: 12px; color: var(--text-muted); line-height: 1.6; }

/* ── CHIPS — restyled to Bio-Digital tokens (consumed by encyclopedia,
     auditor, decoder for badges and rating pills) ───────────────────────────*/
.chip {
  padding: 4px 11px;
  border-radius: 999px;
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip-acc    { background: rgba(212, 246, 135, 0.06); color: #d4f687; border: 1px solid rgba(212, 246, 135, 0.20); }

/* ── SECTION CARDS — restyled to Bio-Digital glass-panel-soft language ──── */
.sec-card {
  background: rgba(30, 32, 27, 0.70);                /* glass-panel-soft */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(184, 217, 110, 0.10);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}
.sec-hdr {
  padding: 14px 18px;
  background: transparent;
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.sec-hdr:hover { background: rgba(212, 246, 135, 0.03); }
.sec-card.open .sec-hdr { border-bottom-color: rgba(184, 217, 110, 0.10); }
.sec-hdr-icon { font-size: 16px; line-height: 1; }
.sec-hdr-title {
  flex: 1;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  color: #c5c8b5;                                    /* on-surface-variant */
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.sec-card.open .sec-hdr-title { color: #d4f687; }    /* primary on open */
.sec-hdr-chev {
  font-size: 11px;
  color: #8f9381;                                    /* outline */
  transition: transform 0.2s, color 0.2s;
}
.sec-card.open .sec-hdr-chev { transform: rotate(180deg); color: #d4f687; }
.sec-body { display: none; padding: 18px; }
.sec-card.open .sec-body { display: block; }

/* ── Biohacker-mode section variant (amber accent) ── */
.bh-sec { border-color: rgba(240, 193, 44, 0.15); }
.bh-hdr:hover { background: rgba(240, 193, 44, 0.03); }
.bh-sec.open .bh-hdr { border-bottom-color: rgba(240, 193, 44, 0.12); }
.bh-sec.open .sec-hdr-title { color: #f0c12c; }
.bh-sec.open .sec-hdr-chev { color: #f0c12c; }

/* ── Grade ring (S/A/B/C/D tiers, used by encyclopedia hero + biohacker divider) ── */
.grade-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  font-family: var(--font-headline);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  user-select: none;
  transition: transform 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
}
.grade-ring-compact {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 20px;
}
/* S — primary glow halo */
.grade-ring-S {
  background: #d4f687;                       /* primary */
  color: #1a1c17;                            /* surface */
  box-shadow: 0 0 0 2px rgba(212, 246, 135, 0.45),
              0 0 24px rgba(212, 246, 135, 0.45),
              0 4px 12px rgba(184, 217, 110, 0.25);
}
/* A — primary, flat */
.grade-ring-A {
  background: #b8d96e;                       /* primary-container */
  color: #2a3300;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
/* B — secondary (amber), flat */
.grade-ring-B {
  background: #f0c12c;                       /* secondary */
  color: #2a2200;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
/* C — secondary muted */
.grade-ring-C {
  background: rgba(240, 193, 44, 0.55);
  color: #1a1c17;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.20);
}
/* D — tertiary (clay) */
.grade-ring-D {
  background: #d4785a;                       /* tertiary tone */
  color: #1a1c17;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Legacy sec-body inline labels (still used by auditor/decoder) */
.sec-lbl {
  font-family: var(--font-label);
  font-size: 10px;
  color: #8f9381;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin-bottom: 6px;
  margin-top: 14px;
}
.sec-lbl:first-child { margin-top: 0; }
.sec-txt {
  font-family: var(--font-body);
  font-size: 13px;
  color: #e3e3da;
  line-height: 1.65;
}
.sec-txt strong { color: #d4f687; font-weight: 600; }

/* ── ENCYCLOPEDIA — quick-pick pill ──────────────────────────────────────── */
.qpill-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0.5rem 1rem;
  background: var(--surface-container-low, #1a1c17);
  color: #c5c8b5;
  border: 1px solid rgba(212, 246, 135, 0.10);
  border-radius: 999px;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.qpill-new:hover {
  background: rgba(212, 246, 135, 0.06);
  border-color: rgba(212, 246, 135, 0.25);
  color: #e3e3da;
}

/* ── ENCYCLOPEDIA — feature-card (idle state) ────────────────────────────── */
.enc-feature-card {
  background: rgba(30, 32, 27, 0.70);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(184, 217, 110, 0.10);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, background 0.2s;
}
.enc-feature-card:hover { border-color: rgba(212, 246, 135, 0.20); }
.enc-feature-title {
  font-family: var(--font-headline);
  font-size: 14px;
  font-weight: 600;
  color: #e3e3da;
  margin-top: 4px;
}
.enc-feature-body {
  font-family: var(--font-body);
  font-size: 12px;
  color: #c5c8b5;
  line-height: 1.55;
  margin: 0;
}

/* ── ENCYCLOPEDIA — loading spinner (replaces legacy .spinner) ───────────── */
.enc-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(212, 246, 135, 0.15);
  border-top-color: #d4f687;
  animation: enc-spin 0.9s linear infinite;
}
@keyframes enc-spin {
  to { transform: rotate(360deg); }
}
#enc-loading[style*="block"]    { display: flex !important; }
#audit-loading[style*="block"]  { display: flex !important; }
#decode-loading[style*="block"] { display: flex !important; }

/* ── SHARED BOTTOM/ACTION ────────────────────────────────────────────────────*/
.bottom-line-box {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  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 var(--border);
  background: var(--bg-inner);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.act-btn:hover { border-color: var(--accent); color: var(--accent); }

.disclaimer-box {
  background: rgba(200, 152, 14, 0.06);
  border: 1px solid rgba(200, 152, 14, 0.18);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 12px;
}

/* ── ENCYCLOPEDIA ────────────────────────────────────────────────────────────*/
.food-hero {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 12px;
}
.food-name-big { font-size: 26px; font-weight: 500; color: var(--text); 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: var(--bg-inner); border-radius: 6px; padding: 10px 12px; }
.score-lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px; }
.score-val { font-size: 14px; color: var(--text); }
.score-sub { font-size: 11px; color: var(--text-muted); 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: var(--green); }
.ev-y { background: var(--gold); }
.ev-r { background: var(--red); }
.ev-claim { font-size: 12px; font-weight: 500; color: var(--text); }
.ev-detail { font-size: 11px; color: var(--text-muted); 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: var(--bg-inner); 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: var(--bg-inner);
  border: 1px solid transparent;
}
.form-recommended { border-color: rgba(0, 196, 168, 0.22); background: rgba(0, 196, 168, 0.05); }
.form-left { flex: 1; }
.form-name { font-size: 12px; font-weight: 500; color: var(--text); }
.form-rec-tag { font-size: 10px; font-weight: 500; color: var(--accent); margin-left: 6px; }
.form-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-note { font-size: 11px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }

/* ── SUPPLEMENT AUDITOR ──────────────────────────────────────────────────────*/
.stack-builder {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.stack-lbl { font-size: 11px; color: var(--text-dim); 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: var(--bg-inner);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag-remove {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  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: var(--red); color: #fff; }
.add-row { display: flex; gap: 8px; }
.add-input {
  flex: 1;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  font-family: var(--font-sans);
}
.add-input:focus { border-color: var(--accent); }
.add-input::placeholder { color: var(--text-dim); }
.add-btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.add-btn:hover { background: var(--bg-hover); border-color: var(--accent); }

.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 var(--border);
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.13s;
}
.sugg-pill:hover { border-color: var(--accent); color: var(--accent); }

.audit-result { display: flex; flex-direction: column; gap: 10px; }
.audit-overall {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.audit-score-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.audit-score { background: var(--bg-inner); border-radius: 6px; padding: 10px; text-align: center; }
.audit-score-num { font-size: 22px; font-weight: 500; }
.audit-score-lbl { font-size: 10px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.audit-title { font-size: 14px; font-weight: 500; color: var(--text); }
.audit-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.6; }

.finding-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  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: var(--text); margin-bottom: 4px; }
.finding-body { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.finding-body strong { color: var(--accent); font-weight: 500; }
.finding-rec {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-inner);
  border-radius: 5px;
  font-size: 11px;
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
}

/* ── LABEL DECODER — MODE TOGGLE ─────────────────────────────────────────────*/
.decode-mode-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  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: var(--text-muted);
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--bg-hover); color: var(--accent); }

/* ── LABEL DECODER — UPLOAD ZONE ─────────────────────────────────────────────*/
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-inner);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-over { border-color: var(--accent); background: rgba(0, 196, 168, 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: var(--text-muted); line-height: 1.5; }
.upload-sub  { font-size: 11px; color: var(--text-dim); }

#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 var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.upload-clear:hover { border-color: var(--red); color: var(--red); }

/* ── LABEL DECODER ───────────────────────────────────────────────────────────*/
.label-input-area {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.label-textarea {
  width: 100%;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  outline: none;
}
.label-textarea:focus { border-color: var(--accent); }
.label-textarea::placeholder { color: var(--text-dim); 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 var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.13s;
}
.ex-btn:hover { border-color: var(--accent); color: var(--accent); }

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

.overall-verdict {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  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(45, 212, 148, 0.15);  color: var(--green); border: 2px solid rgba(45, 212, 148, 0.35); }
.grade-b { background: rgba(0, 196, 168, 0.12);   color: var(--accent); border: 2px solid rgba(0, 196, 168, 0.28); }
.grade-c { background: rgba(200, 152, 14, 0.12);  color: var(--gold);  border: 2px solid rgba(200, 152, 14, 0.28); }
.grade-d { background: rgba(212, 112, 90, 0.12);  color: var(--red);   border: 2px solid rgba(212, 112, 90, 0.28); }

.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: var(--bg-inner); }
.ing-status { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.ing-name { font-size: 12px; font-weight: 500; color: var(--text); }
.ing-verdict { font-size: 11px; color: var(--text-muted); 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(45, 212, 148, 0.12); color: var(--green); }
.ib-ok   { background: rgba(200, 152, 14, 0.12); color: var(--gold); }
.ib-bad  { background: rgba(212, 112, 90, 0.12); color: var(--red); }

/* ══════════════════════════════════════════════════════
   MEDICAL DISCLAIMER OVERLAY — markup + styling now in
   index.html via Tailwind utilities + tailwind.src.css
   @layer components. The ONLY remaining bits below are:
   1) [hidden] support (overrides display:flex)
   2) fade-in / fade-out animations
   3) .btn-locked disabled visual state
   These are kept here because they're triggered by JS class
   toggles that exist outside Tailwind's ergonomic surface.
   ══════════════════════════════════════════════════════ */

/* ── Overlay z-index stack (Tailwind arbitrary values don't compile — set here) ── */
#disclaimer-overlay   { z-index: 1000; }
#auth-overlay         { z-index: 1000; }
#beta-overlay         { z-index: 999;  }
#privacy-overlay      { z-index: 1000; }
#feedback-sheet       { z-index: 500;  }
#lang-picker-overlay  { z-index: 1100; }
#units-picker-overlay { z-index: 1100; }
#side-menu-overlay    { z-index: 300;  }
#app-toast            { z-index: 1200; }

#disclaimer-overlay { animation: discFadeIn 0.4s ease both; }
#disclaimer-overlay[hidden]      { display: none !important; }
#auth-overlay[hidden]            { display: none !important; }
#beta-overlay[hidden]            { display: none !important; }
#privacy-overlay[hidden]         { display: none !important; }
#feedback-sheet[hidden]          { display: none !important; }
#lang-picker-overlay[hidden]     { display: none !important; }
#units-picker-overlay[hidden]    { display: none !important; }
#supp-scan-sheet[hidden]         { display: none !important; }
#supp-edit-sheet[hidden]         { display: none !important; }
#enc-filter-sheet[hidden]        { display: none !important; }
#save-stack-overlay[hidden]      { display: none !important; }
#saved-stacks-panel[hidden]      { display: none !important; }
#history-panel[hidden]           { display: none !important; }
#source-choice-overlay[hidden]   { display: none !important; }
#side-user-signed-in[hidden]     { display: none !important; }
#side-user-signed-out[hidden]    { display: none !important; }
#tier-toggle[hidden]             { display: none !important; }
#disclaimer-overlay.dismissing   { animation: discFadeOut 0.35s ease both; }

@keyframes discFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes discFadeOut { from { opacity: 1; } to { opacity: 0; } }

#disclaimer-accept-btn.btn-locked {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════
   BOTTOM NAV — markup styled with Tailwind. Only the
   stateful tab button needs a CSS rule for `.active`.
   ══════════════════════════════════════════════════════ */
.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: rgba(197, 200, 181, 0.55);           /* on-surface-variant @ 55% */
  cursor: pointer;
  font-family: var(--font-label);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-tab:hover  { color: #c5c8b5; }
.bottom-tab.active { color: #d4f687; }         /* primary */
.bottom-tab-label  {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

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

  /* ── Screens (account for fixed bottom nav) ── */
  .screen {
    padding: 16px
             calc(14px + env(safe-area-inset-right))
             calc(80px + env(safe-area-inset-bottom))
             calc(14px + env(safe-area-inset-left));
  }

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

  /* ── Quick pills ── */
  .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 ── */
  .score-row       { grid-template-columns: repeat(2, 1fr); }
  .audit-score-row { grid-template-columns: repeat(2, 1fr); }

  /* ── Bio grid ── */
  .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 ── */
  .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 ── */
  .form-row { flex-direction: column; gap: 8px; }

  /* ── Idle cards ── */
  .idle-card { padding: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH MODAL
   Markup lives in index.html and is styled with Tailwind utilities + the
   `glass-panel` / `bio-gradient` component classes from tailwind.src.css.
   What remains here:
     • `.auth-tab` / `.auth-tab.active` — JS toggles `.active`, so we need a
       CSS rule for the active vs. inactive visual state.
     • `.auth-input` / `.auth-submit` — consumed by the feedback sheet
       (kept until that dialog is restyled too).
     • `.auth-msg` (+ `.error` / `.success`) — JS sets these classes on
       #auth-msg to render status banners.
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-tab {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(197, 200, 181, 0.55);          /* on-surface-variant @ 55% */
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.auth-tab:hover { color: #c5c8b5; }
.auth-tab.active {
  color: #d4f687;                            /* primary */
  border-bottom-color: #d4f687;
}

.auth-input {
  width: 100%;
  background: rgba(0,196,168,0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--text-dim); }

.auth-submit {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 11px;
  cursor: pointer;
  margin-top: 2px;
  transition: background 0.2s;
}
.auth-submit:hover { background: var(--accent-hover); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-msg {
  font-size: 12px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 6px;
  margin-top: 10px;
  display: none;
  line-height: 1.5;
}
.auth-msg.error   { display: block; background: rgba(212,112,90,0.14); color: #d4705a; }
.auth-msg.success { display: block; background: rgba(45,212,148,0.10); color: var(--green); }

/* The History panel is now styled inline with the Bio-Digital Tailwind
   utilities (glass-panel + bio-gradient) — same shape as save-stack and
   saved-stacks bottom sheets. The legacy .history-* class blocks were
   removed when the markup was rebuilt. */

/* Save-stack dialog and Saved-stacks panel are now styled inline with the
   Bio-Digital Tailwind utilities (glass-panel + bio-gradient). The legacy
   .save-stack-* / .stacks-sheet / .stack-saved-* class blocks were removed
   when those dialogs were rebuilt as bottom sheets matching #supp-edit-sheet. */

/* Auditor toolbar */
.stacks-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.btn-save-stack {
  background: rgba(0,196,168,0.10);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-save-stack:hover { background: rgba(0,196,168,0.20); }
.btn-load-stacks {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-load-stacks:hover { background: rgba(255,255,255,0.09); }

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════════════════════ */

#nutrilens-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: rgba(6,20,26,0.96);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 18px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 1100;
  white-space: nowrap;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#nutrilens-toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY — Pre-Delivery Checklist §1 / §2
   ═══════════════════════════════════════════════════════════════════════════ */

/* Global keyboard focus — outlines follow the element's own border-radius. */
:focus-visible {
  outline: 2px solid var(--primary, #d4f687);
  outline-offset: 2px;
}

/* Respect prefers-reduced-motion globally (boot-splash already handles itself). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile touch-target minimums on currently live chip/tab classes
   (Apple HIG 44pt / Material 48dp). Auditor/decoder migrated chips to
   Tailwind utilities, so only .qpill-new and .mode-tab are still hit by
   global CSS — everything else is sized via Tailwind in markup. */
@media (max-width: 640px) {
  .qpill-new,
  .mode-tab { min-height: 44px; }
}
