/* ============================================================
   NutriDex — Clinical Dossier · sleek minimalist
   Warm ivory paper · near-black ink · one clinical-teal accent
   ============================================================ */

:root {
  --paper:    #f5f4ef;   /* warm ivory ground */
  --paper-2:  #faf9f5;
  --surface:  #ffffff;
  --surface-2:#f7f6f1;
  --surface-3:#f1efe8;

  --line:        #e6e4db;   /* hairline */
  --line-strong: #d6d3c8;

  --ink:    #1b1e23;   /* near-black, faintly warm */
  --ink-2:  #2f343b;
  --dim:    #5a5f67;
  --faint:  #8b9098;

  --accent:       #0e7c6b;   /* clinical teal */
  --accent-strong:#0a5e51;
  --accent-weak:  #e7f1ef;
  --icon-tint:    #0f9d8a;   /* turquoise-teal for monochrome icons */

  /* evidence tiers (kept — they carry meaning) */
  --ev-strong:      #1f7a52;  --ev-strong-bg:      #eaf3ec;
  --ev-moderate:    #2563a8;  --ev-moderate-bg:    #eaf1f9;
  --ev-preliminary: #9a6b15;  --ev-preliminary-bg: #f5ecd6;
  --ev-mixed:       #b1453d;  --ev-mixed-bg:       #f7e7e3;
  --ev-none:        #6b717a;  --ev-none-bg:        #eef0f2;
  --ev-banned:      #8a2622;  --ev-banned-bg:      #f6e3e1;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow-soft: 0 1px 2px rgba(27,30,35,0.07), 0 8px 22px -12px rgba(27,30,35,0.30);
  --shadow:      0 10px 30px -16px rgba(27,30,35,0.22);
  --shadow-lift: 0 18px 48px -24px rgba(27,30,35,0.30);

  --maxw:  1200px;
  --gutter: 40px;

  --font:    'Outfit', system-ui, -apple-system, sans-serif;
  --serif:   'Newsreader', Georgia, serif;
  --display: 'Cormorant Garamond', 'Newsreader', Georgia, serif;
}

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

html { scroll-behavior: smooth; overflow-x: hidden; -webkit-tap-highlight-color: rgba(14,124,107,0.12); }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(14,124,107,0.16); }

/* restrained scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid var(--paper); background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ---------- layout wrappers ---------- */
.hero-inner, .dex, .footer, .empty-state {
  position: relative; z-index: 1;
  width: 100%; max-width: var(--maxw);
  margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter);
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px var(--gutter);
  background:
    radial-gradient(360px 170px at 6% 58%, rgba(126,228,205,0.16), transparent 70%),
    radial-gradient(1100px 340px at 52% -60%, rgba(255,255,255,0.06), transparent 72%),
    rgba(8,34,42,0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.18);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.09),
    inset 0 -22px 30px -24px rgba(0,0,0,0.45),
    0 10px 28px -12px rgba(0,0,0,0.42);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 42px; height: 42px; flex: none; display: grid; place-items: center; }
.crest { width: 42px; height: 42px; display: block; }
/* custom logo image (leaf mark) */
.brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; transform: scale(1.12); }
.brand-mark.has-logo .crest { display: none; }

/* ---------- teal icon tint (keeps emoji shading, depth & lighting — recolours the hue) ---------- */
.chip-ico, .cat-ico, .cat-tile-ico {
  filter: grayscale(1) sepia(1) hue-rotate(178deg) saturate(1.7) brightness(1) contrast(1.4);
}
/* substance icon glyph — teal tint + a soft 2px dark translucent shadow (drawn after the tint) */
.ic-glyph {
  display: inline-block; line-height: 1;
  filter:
    grayscale(1) sepia(1) hue-rotate(178deg) saturate(1.7) brightness(1) contrast(1.4)
    drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}
/* lift the icon on the dark active filter chip so it stays visible */
.chip.active .chip-ico { filter: grayscale(1) sepia(1) hue-rotate(178deg) saturate(1.5) brightness(1.5) contrast(1.4); }
.crest text { fill: url(#crestGold); }
.brand-text h1 {
  font-family: var(--display); font-size: 25px; font-weight: 600; letter-spacing: 0.2px; line-height: 1;
  color: #ffffff;
}
.brand-text p { font-size: 9.5px; color: rgba(255,255,255,0.66); letter-spacing: 2.6px; text-transform: uppercase; margin-top: 4px; }

.topbar-meta { display: flex; gap: 9px; align-items: center; }
.badge-pill {
  font-size: 11.5px; font-weight: 600; color: #eef8f6;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.24); background: rgba(255,255,255,0.13);
}
.badge-pill.subtle { color: rgba(255,255,255,0.72); font-weight: 500; }
a.badge-pill { text-decoration: none; cursor: pointer; transition: color .14s, background .14s, border-color .14s; }
a.badge-pill.subtle:hover { color: #ffffff; background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.42); }

/* header search toggle + inline field */
.header-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--dim);
  padding: 7px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.13); border: 1px solid rgba(255,255,255,0.24); color: #eef8f6;
  transition: color .14s, border-color .14s, background .14s;
}
.header-btn:hover { color: #ffffff; border-color: rgba(255,255,255,0.55); background: rgba(255,255,255,0.2); }
.header-btn svg { width: 15px; height: 15px; }
.header-btn kbd {
  font-family: var(--font); font-size: 10px; color: rgba(255,255,255,0.72);
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2); border-radius: 5px; padding: 1px 6px;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  width: min(48vw, 380px);
  padding: 6px 8px 6px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  animation: dropIn .16s ease both;
}
.topbar-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.topbar-search .ts-ico { width: 16px; height: 16px; color: var(--faint); flex: none; }
.topbar-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: var(--font); font-size: 14px; color: var(--ink);
}
.topbar-search input::placeholder { color: var(--faint); }
.topbar-search input::-webkit-search-cancel-button { display: none; }
.ts-close {
  flex: none; cursor: pointer; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--surface-2); color: var(--dim); font-size: 18px; line-height: 1;
}
.ts-close:hover { background: var(--surface-3); color: var(--ink); }
.topbar.searching #headerSearchBtn,
.topbar.searching .badge-pill.subtle { display: none; }

/* ---------- hero ---------- */
.hero { padding: 48px 0 12px; }
.hero-inner { display: flex; flex-direction: column; align-items: center; text-align: center; }
.hero-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 3.4px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 22px;
}
.hero-title {
  font-family: var(--display);
  font-size: clamp(40px, 6.2vw, 66px);
  font-weight: 500; letter-spacing: 0.2px; line-height: 1.05;
  max-width: 880px; color: var(--ink);
}
.hero-title em {
  font-family: var(--display); font-style: normal; font-weight: 600;
  color: var(--accent-strong); letter-spacing: 0;
  background: none; -webkit-text-fill-color: currentColor;
}
.hero-sub {
  margin-top: 22px; max-width: 600px;
  font-family: var(--serif);
  color: var(--dim); font-size: 17.5px; line-height: 1.7;
}

/* hero specimen strip — slim, translucent, full-width band beneath the header */
.hero-strip {
  position: relative; width: 100%;
  height: clamp(132px, 16vw, 200px);
  overflow: hidden; isolation: isolate;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  border-bottom: 1px solid var(--line);
}
.hero-strip .hero-photo {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: center 45%;
  opacity: 0.9; z-index: 0;
}
/* translucent washes: blend into the page up top, darken below for caption legibility */
.hero-strip::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg,
    rgba(245,244,239,0.55) 0%, rgba(245,244,239,0.06) 26%,
    rgba(12,14,17,0) 54%, rgba(12,14,17,0.42) 100%);
}
.hero-fig-cap {
  position: absolute; left: var(--gutter); bottom: 13px; z-index: 2;
  font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase;
  color: #f3f4f2; background: rgba(20,22,26,0.42);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; padding: 5px 12px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* ============================================================
   SEARCH CONSOLE (minimal)
   ============================================================ */
.search-shell { width: 100%; max-width: 660px; margin-top: 40px; position: relative; z-index: 30; }
.search-console {
  position: relative; border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
  padding: 4px 4px 0;
  transition: border-color .18s, box-shadow .18s;
}
.search-console:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.search-console::after { content: none; }

.search-bar { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; }

/* assistant indicator — a quiet pulsing dot */
.ai-orb { position: relative; width: 18px; height: 18px; flex: none; }
.ai-orb i { position: absolute; border-radius: 50%; }
.ai-orb i:nth-child(1) { inset: 5px; background: var(--accent); box-shadow: 0 0 0 0 rgba(14,124,107,0.35); animation: orbDot 2.6s ease-in-out infinite; }
.ai-orb i:nth-child(2), .ai-orb i:nth-child(3) { display: none; }
@keyframes orbDot { 0%,100% { box-shadow: 0 0 0 0 rgba(14,124,107,0.30); } 50% { box-shadow: 0 0 0 5px rgba(14,124,107,0); } }
.search-console.listening .ai-orb i:nth-child(1) { background: #c2453c; animation-duration: 1s; }

#search {
  flex: 1; border: none; outline: none; background: transparent;
  color: var(--ink); font-family: var(--font); font-size: 16px; font-weight: 400;
  padding: 12px 0; caret-color: var(--accent);
}
#search::placeholder { color: var(--faint); }
#search::-webkit-search-cancel-button { display: none; }

.mic-btn, .clear-btn {
  flex: none; cursor: pointer; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  transition: background .15s, color .15s, border-color .15s;
}
.mic-btn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--dim); }
.mic-btn svg { width: 17px; height: 17px; }
.mic-btn:hover { border-color: var(--accent); color: var(--accent); }
.mic-btn.active { background: rgba(194,69,60,0.10); border-color: #c2453c; color: #c2453c; animation: micPulse 1.1s ease-in-out infinite; }
@keyframes micPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(194,69,60,0.35); } 50% { box-shadow: 0 0 0 6px rgba(194,69,60,0); } }
.mic-btn.unsupported { opacity: 0.45; }
.clear-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--dim); font-size: 21px; line-height: 1; }
.clear-btn:hover { background: var(--surface-3); color: var(--ink); }

.search-hint {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 4px 14px 11px; font-size: 12px; color: var(--faint);
}
.hint-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.search-console.listening .hint-dot { background: #c2453c; }
.hint-kbd { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.hint-kbd kbd {
  font-family: var(--font); font-size: 10.5px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--dim);
}

/* suggestions */
.suggest {
  list-style: none; position: absolute; left: 0; right: 0; top: calc(100% + 9px); z-index: 40;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; max-height: 380px; overflow-y: auto;
  animation: dropIn .16s ease both;
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.suggest li { display: flex; align-items: center; gap: 12px; padding: 10px 11px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink); }
.suggest li .s-ico { font-size: 18px; width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.suggest li .s-text { min-width: 0; flex: 1; }
.suggest li .s-name { font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest li .s-meta { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest li .s-ev { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.suggest li .s-ev[data-ev="strong"]      { color: var(--ev-strong);      background: var(--ev-strong-bg); }
.suggest li .s-ev[data-ev="moderate"]    { color: var(--ev-moderate);    background: var(--ev-moderate-bg); }
.suggest li .s-ev[data-ev="preliminary"] { color: var(--ev-preliminary); background: var(--ev-preliminary-bg); }
.suggest li .s-ev[data-ev="mixed"]       { color: var(--ev-mixed);       background: var(--ev-mixed-bg); }
.suggest li .s-ev[data-ev="none"]        { color: var(--ev-none);        background: var(--ev-none-bg); }
.suggest li .s-ev[data-ev="banned"]      { color: var(--ev-banned);      background: var(--ev-banned-bg); }
.suggest li.active, .suggest li:hover { background: var(--surface-2); }
.suggest .s-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--faint); }

/* prescription / medicinal-product notice */
.suggest li.s-rx { align-items: flex-start; gap: 11px; cursor: default; background: var(--accent-weak); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.suggest li.s-rx:hover { background: var(--accent-weak); }
.suggest li.s-rx .s-rx-ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; font-size: 19px; font-weight: 700; color: var(--accent-strong); background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.suggest li.s-rx .s-rx-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.suggest li.s-rx .s-rx-title { font-weight: 700; font-size: 13.5px; color: var(--accent-strong); white-space: normal; }
.suggest li.s-rx .s-rx-meta { font-size: 12px; line-height: 1.4; color: var(--ink-2); white-space: normal; }

mark { background: #fbeeb0; color: var(--ink); border-radius: 3px; padding: 0 2px; }
.suggest mark { background: #fbeeb0; }

/* ---------- toolbar / chips ---------- */
.toolbar { width: 100%; margin-top: 26px; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.toolbar-secondary { margin-top: 14px; justify-content: center; gap: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* category toolbar: a single, simple "Categories" toggle */
.cat-toolbar { justify-content: center; }
.cat-grid-toggle {
  flex: none; display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 600; color: var(--ink);
  padding: 10px 18px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-soft);
  transition: color .14s, border-color .14s, background .14s;
}
.cat-grid-toggle:hover { border-color: var(--accent); }
.cat-grid-toggle .cgt-grid { width: 16px; height: 16px; color: var(--accent); flex: none; }
.cat-grid-toggle .cgt-label b { font-weight: 800; }
.cat-grid-toggle .cgt-caret { width: 14px; height: 14px; color: var(--faint); flex: none; transition: transform .18s ease; }
.cat-grid-toggle[aria-expanded="true"] { color: #fff; background: var(--ink); border-color: var(--ink); }
.cat-grid-toggle[aria-expanded="true"] .cgt-grid { color: #fff; }
.cat-grid-toggle[aria-expanded="true"] .cgt-caret { color: rgba(255,255,255,0.8); transform: rotate(180deg); }

/* "all types" grid — interactive, all-seeing category map */
.category-grid-wrap { width: 100%; margin-top: 12px; animation: dropIn .18s ease both; }
.category-grid {
  display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-soft);
}
.cat-tile {
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: transform .14s, border-color .14s, background .14s, box-shadow .14s;
}
.cat-tile:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.cat-tile-ico { font-size: 19px; line-height: 1; flex: none; }
.cat-tile-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink); white-space: normal; line-height: 1.25; }
.cat-tile-count { flex: none; font-size: 10.5px; font-weight: 700; color: var(--faint); background: none; border: none; padding: 0; }
.cat-tile.active { background: var(--ink); border-color: var(--ink); }
.cat-tile.active .cat-tile-name { color: #fff; }
.cat-tile.active .cat-tile-count { color: #fff; background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.28); }

/* single-row, scrollable category strip (declutter) */
.chip-scroller {
  width: 100%; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 9px;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.chip-scroller::-webkit-scrollbar { height: 6px; }
.chip-scroller::-webkit-scrollbar-track { background: transparent; }
.chip-scroller::-webkit-scrollbar-thumb { background: var(--line-strong); border: none; border-radius: 999px; }
.chip-scroller::-webkit-scrollbar-thumb:hover { background: var(--faint); }
.chip-scroller .chip-row { flex-wrap: nowrap; width: max-content; margin: 0 auto; padding: 2px 6px 0; }

/* evidence dropdown */
.filter-dd { position: relative; }
.filter-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 500; color: var(--dim);
  padding: 9px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: color .14s, border-color .14s, background .14s;
}
.filter-btn:hover { color: var(--ink); border-color: var(--faint); }
.filter-btn svg { width: 15px; height: 15px; }
.filter-btn .dd-caret { width: 13px; height: 13px; opacity: .7; transition: transform .18s; }
.filter-dd.open .dd-caret { transform: rotate(180deg); }
.filter-btn.has-filters { color: var(--ink); border-color: var(--ink); }
.filter-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 10.5px; font-weight: 800; line-height: 1; color: #fff;
  background: var(--ink); border-radius: 999px;
}
.filter-pop {
  position: absolute; z-index: 41; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 232px; padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); animation: dropIn .16s ease both;
  max-height: min(66vh, 400px); overflow-y: auto;
}
/* flip above the button when there isn't room below */
.filter-dd.up .filter-pop { top: auto; bottom: calc(100% + 8px); }
.filter-pop-head { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); padding: 2px 4px 10px; }
.filter-pop .evidence-row { flex-direction: column; align-items: stretch; gap: 6px; }
.filter-pop .evidence-row .chip { justify-content: flex-start; width: 100%; }
.filter-clear {
  margin-top: 10px; width: 100%; cursor: pointer;
  font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--dim);
  padding: 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background .14s, color .14s;
}
.filter-clear:hover { background: var(--surface-3); color: var(--ink); }
.chip {
  cursor: pointer; user-select: none;
  font-size: 12px; font-weight: 500; color: var(--dim);
  padding: 6px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: color .14s, border-color .14s, background .14s;
  white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--faint); }
.chip-ico { margin-right: 5px; font-size: 11.5px; line-height: 1; }
.chip-ico:empty { display: none; margin: 0; }
.chip.active { color: #fff; font-weight: 600; background: var(--ink); border-color: var(--ink); }

.evidence-row .chip { display: inline-flex; align-items: center; gap: 7px; }
.ev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip[data-ev="strong"]      .ev-dot { background: var(--ev-strong); }
.chip[data-ev="moderate"]    .ev-dot { background: var(--ev-moderate); }
.chip[data-ev="preliminary"] .ev-dot { background: var(--ev-preliminary); }
.chip[data-ev="mixed"]       .ev-dot { background: var(--ev-mixed); }
.chip[data-ev="none"]        .ev-dot { background: var(--ev-none); }
.chip[data-ev="banned"]      .ev-dot { background: var(--ev-banned); }
.chip.active .ev-dot { box-shadow: 0 0 0 2px rgba(255,255,255,0.7); }

.sort-wrap { display: flex; align-items: center; gap: 9px; }
.sort-wrap label { font-size: 12.5px; color: var(--faint); }
#sort {
  font-family: var(--font); font-size: 12.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; cursor: pointer; outline: none;
}
#sort:focus { border-color: var(--accent); }

/* ---------- dex grid ---------- */
.dex {
  margin-top: 52px; padding-bottom: 72px;
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.card {
  position: relative; cursor: pointer;
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 26px 26px 20px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform .26s cubic-bezier(.2,.7,.3,1), border-color .26s, box-shadow .26s;
  /* skip layout/paint for off-screen cards — big win for a 100+ card grid */
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}
/* entrance stagger runs only on the first paint (parent .dex.intro), never on filter/search re-renders */
.dex.intro .card { animation: rise .4s both; animation-delay: calc(var(--i, 0) * 28ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.card > * { position: relative; z-index: 1; }
/* top rule is hidden by default (calm grid); only danger cards show a red marker */
.card::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--ev-banned); opacity: 0; }
.card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow-lift); }

/* ghosted glyph watermark */
.card-watermark {
  position: absolute; z-index: 0; top: -16px; right: -10px;
  font-size: 118px; line-height: 1; opacity: 0.045;
  filter: grayscale(1); pointer-events: none; user-select: none;
  transform: rotate(-6deg); transition: transform .4s cubic-bezier(.2,.7,.3,1), opacity .3s;
}
.card:hover .card-watermark { transform: rotate(-3deg) scale(1.05); opacity: 0.07; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-icon {
  font-size: 25px; line-height: 1; width: 50px; height: 50px; flex: none;
  display: grid; place-items: center; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .26s;
}
.card:hover .card-icon { border-color: var(--line-strong); }

/* FLAT evidence badge (no foil) */
.ev-badge {
  font: 700 10px/1 var(--font); letter-spacing: .9px; text-transform: uppercase;
  padding: 6px 11px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent;
}
.ev-badge .ev-dot { width: 7px; height: 7px; }
.ev-badge[data-ev="strong"]      { color: var(--ev-strong);      background: var(--ev-strong-bg);      border-color: rgba(31,122,82,0.22); }
.ev-badge[data-ev="strong"]      .ev-dot { background: var(--ev-strong); }
.ev-badge[data-ev="moderate"]    { color: var(--ev-moderate);    background: var(--ev-moderate-bg);    border-color: rgba(37,99,168,0.22); }
.ev-badge[data-ev="moderate"]    .ev-dot { background: var(--ev-moderate); }
.ev-badge[data-ev="preliminary"] { color: var(--ev-preliminary); background: var(--ev-preliminary-bg); border-color: rgba(154,107,21,0.24); }
.ev-badge[data-ev="preliminary"] .ev-dot { background: var(--ev-preliminary); }
.ev-badge[data-ev="mixed"]       { color: var(--ev-mixed);       background: var(--ev-mixed-bg);       border-color: rgba(177,69,61,0.24); }
.ev-badge[data-ev="mixed"]       .ev-dot { background: var(--ev-mixed); }
.ev-badge[data-ev="none"]        { color: var(--ev-none);        background: var(--ev-none-bg);        border-color: rgba(107,113,122,0.24); }
.ev-badge[data-ev="none"]        .ev-dot { background: var(--ev-none); }
.ev-badge[data-ev="banned"]      { color: var(--ev-banned);      background: var(--ev-banned-bg);      border-color: rgba(138,38,34,0.26); }
.ev-badge[data-ev="banned"]      .ev-dot { background: var(--ev-banned); }

.card-name { margin-top: 18px; font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: 0.2px; line-height: 1.1; color: var(--ink); }
.card-name::after { content: ""; display: block; width: 28px; height: 2px; margin-top: 10px; background: var(--line-strong); opacity: 1; border-radius: 2px; transition: width .3s ease; }
.card:hover .card-name::after { width: 52px; }
.card-latin { font-family: var(--display); font-style: italic; font-size: 15px; color: var(--faint); margin-top: 4px; }
.card-tagline { margin-top: 12px; font-size: 14px; color: var(--dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.card-cats { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--dim);
  padding: 4px 9px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.cat-ico { font-size: 11px; line-height: 1; }
.cat-ico:empty { display: none; }
.cat-tag.cat-more { color: var(--faint); font-weight: 600; }

/* key-benefit pills */
.card-keys { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.key-pill {
  font-size: 11.5px; font-weight: 500; color: var(--ink-2);
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.key-pill mark { background: #fbeeb0; }
.card-keys.is-flag { margin-top: 14px; }
.card-flag { font-size: 12.5px; font-weight: 700; line-height: 1.45; }
.card-flag.danger { color: var(--ev-banned); }
.card-flag.note { color: var(--ev-none); font-weight: 600; }

/* footer: strength meter + citation seal */
.card-foot {
  margin-top: auto; padding-top: 16px; margin-top: 18px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-foot { margin-top: auto; }
.card-strength { display: inline-flex; align-items: center; gap: 9px; }
.cs-bars { display: inline-flex; gap: 3px; }
.cs-bars i { width: 13px; height: 5px; border-radius: 2px; background: var(--line-strong); }
.cs-label { font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.card-strength.empty .cs-label { color: var(--ev-none); }
.card-sources { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); font-weight: 500; }
.card-sources svg { width: 13px; height: 13px; opacity: .7; }
.card-sources b { color: var(--ev-strong); font-weight: 800; }
.is-none .card-sources b, .is-danger .card-sources b { color: var(--dim); }

.card-strength[data-ev="strong"]      .cs-bars i.on { background: var(--ev-strong); }
.card-strength[data-ev="moderate"]    .cs-bars i.on { background: var(--ev-moderate); }
.card-strength[data-ev="preliminary"] .cs-bars i.on { background: var(--ev-preliminary); }
.card-strength[data-ev="mixed"]       .cs-bars i.on { background: var(--ev-mixed); }
.card-strength[data-ev="strong"]      .cs-label { color: var(--ev-strong); }
.card-strength[data-ev="moderate"]    .cs-label { color: var(--ev-moderate); }
.card-strength[data-ev="preliminary"] .cs-label { color: var(--ev-preliminary); }
.card-strength[data-ev="mixed"]       .cs-label { color: var(--ev-mixed); }

/* risk / no-evidence cards */
.card.is-danger { border-color: rgba(138,38,34,0.28); }
.card.is-danger::after { opacity: 0.9; }
.card.is-danger:hover { border-color: rgba(138,38,34,0.45); }
.card.is-none { background: var(--paper-2); }

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: 80px 0 100px; }
.empty-glyph { font-size: 48px; color: var(--faint); opacity: 0.6; }
.empty-state h3 { margin-top: 14px; font-size: 22px; font-family: var(--display); font-weight: 600; color: var(--ink); }
.empty-state p { color: var(--dim); margin-top: 6px; }
.ghost-btn {
  margin-top: 22px; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 600; color: #fff;
  padding: 11px 22px; border-radius: var(--radius-sm);
  background: var(--ink); border: 1px solid var(--ink);
  transition: background .15s;
}
.ghost-btn:hover { background: var(--ink-2); }

/* ---------- footer / about ---------- */
.footer { padding: 44px var(--gutter) 72px; border-top: 1px solid var(--line); margin-top: 24px; }
.footer-inner { max-width: var(--maxw); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.footer-about h4 { font-family: var(--display); font-size: 21px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.footer-about > p { max-width: 860px; font-size: 13.5px; color: var(--dim); line-height: 1.75; }
.footer-cred { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; max-width: 860px; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.cred-badge {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px; color: var(--accent-strong);
  background: var(--accent-weak); border: 1px solid rgba(14,124,107,0.22);
  border-radius: 999px; padding: 5px 11px;
}
.cred-badge svg { width: 13px; height: 13px; }
.footer-disclaimer { max-width: 860px; font-size: 12px; color: var(--faint); line-height: 1.7; padding-top: 16px; border-top: 1px dashed var(--line); }
.footer-disclaimer strong { color: var(--dim); }
.footer-method { margin-top: 14px; }
.footer-method a { font-size: 13.5px; font-weight: 700; color: var(--accent-strong); text-decoration: none; }
.footer-method a:hover { text-decoration: underline; }
/* "Why it exists" target — offset under sticky header + gentle highlight on arrival */
#why { scroll-margin-top: 96px; border-radius: 8px; }
@keyframes whyFlash { 0% { background: var(--accent-weak); box-shadow: 0 0 0 10px var(--accent-weak); } 100% { background: transparent; box-shadow: 0 0 0 10px transparent; } }
#why:target { animation: whyFlash 2.4s ease both; }
.footer-copyright { margin-top: 18px; font-size: 11.5px; color: var(--faint); }
.footer-copyright strong { color: var(--dim); font-weight: 700; }
.footer-pledge {
  max-width: 860px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--accent-weak); border: 1px solid rgba(14,124,107,0.22); border-left: 4px solid var(--accent);
}
.footer-pledge h4 { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--accent-strong); margin-bottom: 7px; }
.footer-pledge p { font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.footer-pledge strong { color: var(--ink); }

/* ============================================================
   MODAL — dossier
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 22, 26, 0.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  min-height: 100vh; min-height: 100dvh;
  animation: fade .2s both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: 0 40px 100px -40px rgba(20, 22, 26, 0.45);
  animation: zoomIn .36s cubic-bezier(.2,.8,.2,1) both;
  overflow: hidden;
}
@keyframes zoomIn {
  from { opacity: 0; transform: translate(var(--zx, 0px), var(--zy, 0px)) scale(.12); }
  to   { opacity: 1; transform: translate(0, 0) scale(1); }
}
.modal-close {
  position: absolute; top: 18px; right: 18px; z-index: 3;
  width: 38px; height: 38px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong);
  color: var(--dim); font-size: 22px; line-height: 1; transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }

.modal-body { padding: 0; }
.m-head { position: relative; padding: 40px 40px 28px; }
.m-head::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--m-accent, var(--accent)); }
.m-head-row { display: flex; align-items: center; gap: 18px; }
/* reference medallion — a large "specimen plate" for the substance */
.m-icon {
  font-size: 56px; width: 108px; height: 108px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2);
  background: radial-gradient(circle at 38% 30%, #ffffff 0%,
    color-mix(in srgb, var(--m-accent, var(--accent)) 12%, #ffffff) 62%,
    color-mix(in srgb, var(--m-accent, var(--accent)) 26%, #ffffff) 100%);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 2px 2px rgba(255,255,255,0.85), inset 0 -6px 14px rgba(27,30,35,0.06), 0 10px 24px -12px rgba(27,30,35,0.4);
}
.m-title h2 { font-family: var(--display); font-size: 36px; font-weight: 600; letter-spacing: 0.2px; line-height: 1.05; color: var(--ink); }
.m-title .m-latin { font-family: var(--display); font-style: italic; color: var(--dim); font-size: 17px; margin-top: 2px; }
.m-tagline { margin-top: 16px; font-family: var(--serif); font-size: 16.5px; color: var(--dim); line-height: 1.6; }
.m-badges { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* at-a-glance stat strip */
.m-glance {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin: 0 40px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2);
}
.glance-cell { padding: 15px 16px; border-right: 1px solid var(--line); }
.glance-cell:last-child { border-right: none; }
.glance-label { font-size: 9.5px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); }
.glance-val { margin-top: 8px; font-size: 16px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.glance-cat { font-family: var(--display); font-size: 19px; font-weight: 600; }
.glance-sub { color: var(--faint); font-weight: 500; font-size: 13px; }
.glance-na { font-size: 13px; font-weight: 600; color: var(--ev-none); }
.glance-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.glance-dot[data-ev="strong"]      { background: var(--ev-strong); }
.glance-dot[data-ev="moderate"]    { background: var(--ev-moderate); }
.glance-dot[data-ev="preliminary"] { background: var(--ev-preliminary); }
.glance-dot[data-ev="mixed"]       { background: var(--ev-mixed); }
.glance-dot[data-ev="none"]        { background: var(--ev-none); }
.glance-dot[data-ev="banned"]      { background: var(--ev-banned); }
.glance-bars { display: inline-flex; gap: 3px; }
.glance-bars i { width: 12px; height: 7px; border-radius: 2px; background: var(--line-strong); }
.glance-bars[data-ev="strong"]      i.on { background: var(--ev-strong); }
.glance-bars[data-ev="moderate"]    i.on { background: var(--ev-moderate); }
.glance-bars[data-ev="preliminary"] i.on { background: var(--ev-preliminary); }
.glance-bars[data-ev="mixed"]       i.on { background: var(--ev-mixed); }

/* takeaway callout */
.m-takeaway {
  display: flex; gap: 14px; align-items: flex-start;
  margin: 20px 40px 0; padding: 16px 18px;
  border-radius: var(--radius); font-size: 14.5px; line-height: 1.65; color: var(--ink);
  background: var(--accent-weak); border: 1px solid var(--line); border-left: 3px solid var(--accent);
}
.m-takeaway strong { color: var(--accent-strong); }
.m-takeaway-ico { font-size: 20px; line-height: 1.2; color: var(--accent); flex: none; }
.m-takeaway[data-ev="strong"]   { background: var(--ev-strong-bg); border-left-color: var(--ev-strong); }
.m-takeaway[data-ev="strong"] strong, .m-takeaway[data-ev="strong"] .m-takeaway-ico { color: var(--ev-strong); }
.m-takeaway[data-ev="moderate"] { background: var(--ev-moderate-bg); border-left-color: var(--ev-moderate); }
.m-takeaway[data-ev="moderate"] strong, .m-takeaway[data-ev="moderate"] .m-takeaway-ico { color: var(--ev-moderate); }
.m-takeaway[data-ev="preliminary"] { background: var(--ev-preliminary-bg); border-left-color: var(--ev-preliminary); }
.m-takeaway[data-ev="preliminary"] strong, .m-takeaway[data-ev="preliminary"] .m-takeaway-ico { color: var(--ev-preliminary); }
.m-takeaway[data-ev="mixed"]    { background: var(--ev-mixed-bg); border-left-color: var(--ev-mixed); }
.m-takeaway[data-ev="mixed"] strong, .m-takeaway[data-ev="mixed"] .m-takeaway-ico { color: var(--ev-mixed); }
.m-takeaway[data-ev="none"], .m-takeaway[data-ev="banned"] { background: var(--ev-none-bg); border-left-color: var(--ev-none); }
.m-takeaway[data-ev="none"] strong, .m-takeaway[data-ev="banned"] strong,
.m-takeaway[data-ev="none"] .m-takeaway-ico, .m-takeaway[data-ev="banned"] .m-takeaway-ico { color: var(--dim); }

.m-sections { padding: 28px 40px 40px; display: flex; flex-direction: column; gap: 28px; }
.m-block h3 {
  font-size: 11px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--ink); margin-bottom: 14px; display: flex; align-items: center; gap: 12px;
}
.m-block h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.m-summary { font-family: var(--serif); font-size: 16px; color: var(--ink-2); line-height: 1.74; }

/* danger & no-evidence banners */
.m-danger, .m-note { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); font-size: 14px; line-height: 1.6; }
.m-danger { background: var(--ev-banned-bg); border: 1px solid rgba(138,38,34,0.28); border-left: 4px solid var(--ev-banned); color: #6e201d; }
.m-danger strong { color: var(--ev-banned); }
.m-danger-ico { font-size: 22px; line-height: 1.1; flex: none; }
.m-note { background: var(--ev-none-bg); border: 1px solid rgba(107,113,122,0.28); border-left: 4px solid var(--ev-none); color: #474c54; }
.m-note strong { color: #3a3f47; }
.m-note-ico { font-size: 20px; line-height: 1.1; flex: none; color: var(--ev-none); }

.benefit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.benefit-item {
  display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink);
  padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
}
.benefit-item .tick { width: 18px; height: 18px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--ev-strong-bg); color: var(--ev-strong); }
.benefit-item.unproven { background: var(--ev-mixed-bg); border-color: rgba(177,69,61,0.20); color: var(--dim); }
.benefit-item.unproven .tick { background: rgba(177,69,61,0.14); color: var(--ev-mixed); }

.research-list { display: flex; flex-direction: column; gap: 10px; }
.research-item {
  display: block; text-decoration: none;
  padding: 13px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--m-accent, var(--accent));
  transition: background .15s, box-shadow .15s, transform .15s, border-color .15s;
}
.research-item:hover { background: var(--surface); box-shadow: var(--shadow-soft); transform: translateX(2px); }
.research-item.verified { border-left-color: var(--ev-strong); }
.r-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.r-type { flex: none; font-size: 9.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: var(--dim); background: var(--surface-3); border: 1px solid var(--line); }
.research-item .r-cite { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.r-link { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--faint); white-space: nowrap; }
.research-item.verified .r-link { color: var(--ev-strong); font-weight: 800; }
.research-item:hover .r-link { color: var(--accent); }
.research-item .r-find { font-size: 14px; color: var(--dim); margin-top: 5px; line-height: 1.55; }

.r-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 13px; border-top: 1px dashed var(--line-strong); font-size: 12px; color: var(--faint); }
.r-footer a { color: var(--accent); font-weight: 600; text-decoration: none; }
.r-footer a:hover { text-decoration: underline; }

.kv-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.kv { padding: 15px 17px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.kv .kv-label { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); font-weight: 800; }
.kv .kv-val { margin-top: 6px; font-size: 14.5px; color: var(--ink); }
.kv.warn { border-color: rgba(177,69,61,0.28); background: var(--ev-mixed-bg); }
.kv.warn .kv-label { color: var(--ev-mixed); }

.compound-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.compound-tags span { font-size: 12.5px; color: var(--accent-strong); padding: 5px 11px; border-radius: 7px; background: var(--accent-weak); border: 1px solid rgba(14,124,107,0.20); }

body.modal-open { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 980px) { :root { --gutter: 28px; } }
@media (max-width: 820px) {
  .m-glance { grid-template-columns: 1fr 1fr; }
  .glance-cell:nth-child(2) { border-right: none; }
  .glance-cell:nth-child(1), .glance-cell:nth-child(2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  :root { --gutter: 18px; }
  .hero { padding-top: 64px; }
  .topbar { flex-direction: column; gap: 12px; align-items: flex-start; padding: 14px 18px; }
  .hide-sm { display: none; }
  .topbar-meta { width: 100%; flex-wrap: wrap; }
  .topbar-search { width: 100%; order: -1; }
  .toolbar-secondary { flex-direction: column; align-items: stretch; }
  .sort-wrap { justify-content: center; }
  .benefit-grid { grid-template-columns: 1fr; }
  .hint-kbd { display: none; }
  .m-head, .m-sections { padding-left: 22px; padding-right: 22px; }
  .m-glance, .m-takeaway { margin-left: 22px; margin-right: 22px; }
  .m-icon { width: 84px; height: 84px; font-size: 44px; }
}

/* ============================================================
   MOBILE HARDENING — cross-OS (iOS Safari / Android Chrome / iPad / touch)
   ============================================================ */

/* keyboard / pointer accessibility */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.card:focus-visible { outline-offset: -2px; }

/* prevent long chemical tokens overflowing their cells */
.compound-tags span, .kv .kv-val, .r-find, .key-pill { overflow-wrap: anywhere; }
.suggest, .chip-scroller, .filter-pop { overscroll-behavior: contain; }

/* custom select caret (Android renders #sort inconsistently) */
#sort {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235a5f67' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}

/* safe-area insets for notched / gesture devices */
@supports (padding: env(safe-area-inset-top)) {
  .topbar {
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-left: calc(var(--gutter) + env(safe-area-inset-left));
    padding-right: calc(var(--gutter) + env(safe-area-inset-right));
  }
  .hero-inner, .dex { padding-left: calc(var(--gutter) + env(safe-area-inset-left)); padding-right: calc(var(--gutter) + env(safe-area-inset-right)); }
  .footer {
    padding-left: calc(var(--gutter) + env(safe-area-inset-left));
    padding-right: calc(var(--gutter) + env(safe-area-inset-right));
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
  .modal-backdrop { padding-top: calc(48px + env(safe-area-inset-top)); padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
}

/* touch devices: bigger hit targets, no sticky hover */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow-soft); border-color: var(--line); }
  .card:hover .card-watermark { transform: rotate(-6deg); opacity: .045; }
  .card:hover .card-name::after { width: 30px; }
  .card:active { transform: scale(0.992); }
  .chip:hover { color: var(--dim); border-color: var(--line-strong); }
  .research-item:hover { transform: none; background: var(--surface-2); box-shadow: none; }
  .filter-btn:hover, .header-btn:hover, .mic-btn:hover { border-color: var(--line-strong); }
}
@media (pointer: coarse) {
  .chip { min-height: 42px; padding-top: 9px; padding-bottom: 9px; display: inline-flex; align-items: center; }
  .chip-scroller .chip-row { gap: 9px; }
  .filter-btn, #sort, .header-btn { min-height: 44px; }
  .mic-btn, .clear-btn, .modal-close { width: 44px; height: 44px; }
  .ts-close { width: 38px; height: 38px; }
  .research-item { padding: 15px 16px; }
}

/* phones: 16px inputs (kills iOS focus-zoom), tighter modal, reachable close */
@media (max-width: 640px) {
  #search, #headerSearch, .topbar-search input, #sort { font-size: 16px; }
  .header-btn kbd { display: none; }
  .modal-backdrop { padding: 14px 12px; align-items: flex-start; }
  .modal { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .modal-close { top: calc(12px + env(safe-area-inset-top)); }
  .hero-fig-cap { left: 12px; }
}
@media (max-width: 820px) {
  .topbar-search input, #sort { font-size: 16px; }
}

/* ---------- well-cited sign + curated citation list ---------- */
.card-sources.well svg { width: 13px; height: 13px; color: var(--accent); opacity: 1; }
.card-sources.well b { color: var(--accent-strong); }
.r-wellcited {
  margin-left: 10px; font: 700 10px/1 var(--font); letter-spacing: .3px; text-transform: none;
  color: var(--accent-strong); background: var(--accent-weak);
  border: 1px solid rgba(14,124,107,0.22); border-radius: 999px; padding: 4px 9px; white-space: nowrap;
}
.research-extra { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.r-showmore {
  margin-top: 10px; width: 100%; cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--accent-strong);
  padding: 9px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  transition: background .14s, border-color .14s;
}
.r-showmore:hover { background: var(--accent-weak); border-color: var(--accent); }
.r-legend { margin-top: 10px; font-size: 11.5px; line-height: 1.55; color: var(--faint); }
.r-legend b { color: var(--dim); font-weight: 700; }

/* ---------- animated logo badge (header) + animated hero ---------- */
.brand-anim {
  width: 46px; height: 46px; flex: none; display: block; position: relative;
  border-radius: 50%; overflow: hidden; background: #0f2a2c;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow:
    0 9px 20px -6px rgba(0,0,0,0.6),
    0 0 24px -4px rgba(122,232,205,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.08);
}
/* full-frame logo video, positioned so the emblem fills the circular badge */
.brand-logo-vid {
  position: absolute; width: 142.7px; height: 80px; left: -50.5px; top: -13.1px;
  object-fit: cover; display: block; pointer-events: none;
}
/* animated hero video reuses .hero-photo layout */
video.hero-photo { object-fit: cover; background: #0f2a2c; }
.hero-vid { z-index: 0; }
