:root {
  color-scheme: light dark;
  --bg: #fbfbf9;
  --surface: #ffffff;
  --sunken: #f2f2ee;
  --ink: #16191d;
  --ink-2: #565c63;
  --line: #e2e2dc;
  --line-strong: #8d9299;
  --accent: #0b6265;
  --accent-ink: #ffffff;
  --ok: #0f6b3f;       --ok-bg: #e7f4ec;
  --stop: #b3171f;     --stop-bg: #fcebea;
  --warn: #8a5300;     --warn-bg: #fdf2dc;
  --none: #434950;     --none-bg: #eceded;
  --dot-red: #d3302f;
  --dot-yellow: #d99a06;
  --dot-blue: #1f7ac4;
  --dot-purple: #7d4cc2;
  --dot-green: #1c9259;
  --radius: 12px;
  --tap: 48px;
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Leelawadee UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --surface: #1a1d20;
    --sunken: #22262a;
    --ink: #eef0f1;
    --ink-2: #a5abb2;
    --line: #2e3338;
    --line-strong: #6f767d;
    --accent: #5fc4c6;
    --accent-ink: #0a2223;
    --ok: #6fd6a0;       --ok-bg: #12291e;
    --stop: #ff9c96;     --stop-bg: #331615;
    --warn: #f0c063;     --warn-bg: #2e2410;
    --none: #c3c8cd;     --none-bg: #24282c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
h1 { font-size: 1.65rem; font-weight: 600; line-height: 1.3; text-wrap: balance; }
h2 { font-size: 1rem; font-weight: 600; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button, a, input, select { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }
.muted { color: var(--ink-2); }
.small { font-size: .88rem; }
.pre { white-space: pre-line; }

.skip {
  position: absolute; left: 12px; top: -60px;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 8px; z-index: 30;
}
.skip:focus { top: 8px; }
.noscript { padding: 24px; text-align: center; }

/* Header and navigation */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px max(20px, calc((100% - 760px) / 2));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; min-height: 44px; }
.nav { display: flex; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: .94rem;
  transition: background-color 120ms, color 120ms;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current='page'] { color: var(--ink); background: var(--sunken); font-weight: 500; }
.nav svg { display: none; }

main {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 32px 20px 48px;
  scroll-margin-top: 80px;
}
.foot {
  max-width: 760px; width: 100%; margin: 0 auto;
  padding: 20px; color: var(--ink-2); font-size: .82rem;
  border-top: 1px solid var(--line);
}
.foot p + p { margin-top: 2px; }

.page-head { margin-bottom: 24px; }
.page-head p { margin-top: 4px; color: var(--ink-2); }

/* Fields */
.field label, .label { display: block; font-size: .9rem; font-weight: 500; margin-bottom: 6px; }
.input, select.input {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color 120ms;
}
.input:hover { border-color: var(--ink-2); }
.input::placeholder { color: var(--ink-2); }

/* Drug picker */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.combo { position: relative; }
.combo .input { padding-right: 44px; text-overflow: ellipsis; }
.combo-clear {
  position: absolute; right: 2px; bottom: 2px;
  width: 44px; height: 44px; border: 0; background: none; border-radius: 10px;
  display: grid; place-items: center; color: var(--ink-2); cursor: pointer;
}
.combo-clear:hover { color: var(--ink); background: var(--sunken); }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 19rem; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .14);
  padding: 4px;
}
.combo-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.combo-opt[aria-selected='true'], .combo-opt:hover { background: var(--sunken); }
.combo-opt-name { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.combo-empty { padding: 12px 10px; color: var(--ink-2); }

.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dot-red { background: var(--dot-red); }
.dot-yellow { background: var(--dot-yellow); }
.dot-blue { background: var(--dot-blue); }
.dot-purple { background: var(--dot-purple); }
.dot-green { background: var(--dot-green); }

/* Status text, always paired with an icon or a word so color is never the only signal */
.tag { flex: none; font-size: .82rem; font-weight: 500; white-space: nowrap; }
.tone-ok { color: var(--ok); }
.tone-stop { color: var(--stop); }
.tone-warn { color: var(--warn); }
.tone-none { color: var(--none); }

/* Verdict */
.result { margin-top: 24px; min-height: 8rem; }
.verdict { border-radius: 16px; padding: 24px; animation: rise 160ms ease-out; }
.verdict.ok { background: var(--ok-bg); }
.verdict.stop { background: var(--stop-bg); }
.verdict.warn { background: var(--warn-bg); }
.verdict.none { background: var(--none-bg); }
.verdict-head { display: flex; align-items: center; gap: 12px; }
.verdict-head svg { flex: none; }
.verdict-title { font-size: 1.75rem; font-weight: 600; line-height: 1.25; }
.verdict-en { font-size: .88rem; font-weight: 500; }
.verdict-pair { margin-top: 12px; font-weight: 500; overflow-wrap: anywhere; }
.verdict-note { margin-top: 2px; }
.verdict-action { margin-top: 12px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.verdict-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.link { color: var(--accent); text-underline-offset: 3px; padding: 6px 0; }
.link:hover { text-decoration-thickness: 2px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: .9rem; cursor: pointer; text-decoration: none;
  transition: border-color 120ms, background-color 120ms;
}
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.section-label { font-size: .88rem; color: var(--ink-2); margin-bottom: 10px; }

/* Lists */
.rows { border-top: 1px solid var(--line); }
.rows > li { border-bottom: 1px solid var(--line); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; min-height: 56px; padding: 10px 4px;
  background: none; border: 0; text-align: left; text-decoration: none; cursor: pointer;
  transition: background-color 120ms;
}
a.row:hover, button.row:hover { background: var(--sunken); }
.row-main { min-width: 0; overflow-wrap: anywhere; }
.row-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.row-sub { color: var(--ink-2); font-size: .88rem; padding-left: 17px; }
.drug-tools { display: grid; gap: 12px; margin-bottom: 16px; }
.count { color: var(--ink-2); font-size: .88rem; margin-bottom: 8px; }
.rows-virtual > li { content-visibility: auto; contain-intrinsic-size: auto 64px; }

/* Drug detail */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--ink-2); text-decoration: none; margin: -8px 0 8px; }
.back:hover { color: var(--ink); }
.group-line { display: flex; align-items: center; gap: 8px; color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere; }
.alert { background: var(--stop-bg); color: var(--stop); border-radius: var(--radius); padding: 14px 16px; margin-top: 20px; }
.alert h2 { margin-bottom: 2px; }
.timing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.timing div { background: var(--sunken); border-radius: var(--radius); padding: 12px 14px; }
.timing dt { font-size: .82rem; color: var(--ink-2); }
.timing dd { font-weight: 500; overflow-wrap: anywhere; font-size: .94rem; }
.info { margin-top: 8px; }
.info > div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.info dt { font-size: .88rem; color: var(--ink-2); margin-bottom: 2px; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: var(--radius); font-weight: 500; text-decoration: none; cursor: pointer;
  transition: opacity 120ms;
}
.primary:hover { opacity: .9; }
.secondary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 20px;
  background: none; border: 1px solid var(--line-strong); border-radius: var(--radius);
  cursor: pointer; transition: background-color 120ms;
}
.secondary:hover { background: var(--sunken); }
.danger-link { background: none; border: 0; color: var(--stop); min-height: 44px; padding: 0 8px; cursor: pointer; border-radius: 8px; }
.danger-link:hover { background: var(--stop-bg); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* Antidotes */
.antidote { padding: 20px 0; border-bottom: 1px solid var(--line); }
.antidote:first-child { border-top: 1px solid var(--line); }
.antidote h2 { font-size: 1.1rem; }
.antidote-dose { font-weight: 500; margin-top: 8px; }

/* Log */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.notice { background: var(--sunken); border-radius: var(--radius); padding: 12px 16px; font-size: .9rem; margin-bottom: 24px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 32px 0 8px; }
.stats div { background: var(--sunken); border-radius: var(--radius); padding: 12px 14px; }
.stats dt { font-size: .82rem; color: var(--ink-2); }
.stats dd { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.block { margin-top: 32px; }
.block h2 { margin-bottom: 10px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.block-head h2 { margin: 0; }
.bar-row { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.empty { color: var(--ink-2); padding: 12px 0; }
.error-text { color: var(--stop); font-size: .88rem; margin-top: 4px; }

/* Toast */
.toast-region { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; width: min(92vw, 440px); }
.toast {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--bg);
  border-radius: var(--radius); padding: 8px 8px 8px 16px;
  animation: rise 160ms ease-out;
}
.toast button { background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; min-height: 40px; padding: 0 10px; cursor: pointer; }

@media (max-width: 640px) {
  html { font-size: 16px; }
  .top { padding: 6px 16px; }
  main { padding: 20px 16px 32px; }
  .foot { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.4rem; }
  .pair, .form-grid { grid-template-columns: 1fr; }
  .result { margin-top: 20px; }
  .verdict { padding: 20px; }
  .verdict-title { font-size: 1.5rem; }
  .timing, .stats { gap: 8px; }
  .timing div, .stats div { padding: 10px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; gap: 0;
    background: var(--bg); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav a {
    flex: 1; flex-direction: column; justify-content: center; gap: 0;
    min-height: 60px; padding: 4px 0; border-radius: 0; font-size: .76rem;
  }
  .nav a[aria-current='page'] { background: none; color: var(--accent); }
  .nav svg { display: block; }
  .toast-region { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .timing { grid-template-columns: 1fr; }
  .timing div { display: flex; justify-content: space-between; gap: 16px; }
  .timing dd { text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .top, .nav, .foot, .toast-region, .actions { display: none; }
}
.coverage { margin-top: 20px; }

/* ---------- Layout across devices ---------- */
:root { --page: 1080px; --gutter: clamp(16px, 4vw, 32px); }
.top { padding-inline: max(var(--gutter), calc((100% - var(--page)) / 2)); }
main { max-width: calc(var(--page) + var(--gutter) * 2); padding-inline: var(--gutter); }
.foot { max-width: calc(var(--page) + var(--gutter) * 2); padding-inline: var(--gutter); }
.narrow { max-width: 760px; margin-inline: auto; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.3vw, 1.9rem); }
.foot a { color: inherit; text-underline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Motion: compositor-only, short, and interruptible ---------- */
main { view-transition-name: page; }
::view-transition-old(page) { animation: page-out 110ms ease-in both; }
::view-transition-new(page) { animation: page-in 200ms cubic-bezier(.2, .8, .2, 1) both; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.combo-list { animation: rise 130ms cubic-bezier(.2, .8, .2, 1); transform-origin: top; }
.chip, .primary, .secondary, .seg-btn { transition: transform 120ms, background-color 140ms, border-color 140ms, color 140ms; }
.chip:active, .primary:active, .secondary:active { transform: scale(.97); }
a.row:active { background: var(--sunken); }
html { scroll-behavior: smooth; }
.rows-virtual > li { contain-intrinsic-size: auto 60px; }

/* ---------- Filter panel ---------- */
.filters {
  display: grid; gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px;
  margin-bottom: 16px;
}
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); display: grid; color: var(--ink-2); pointer-events: none; }
.input-search { padding-left: 42px; background: var(--bg); border-color: var(--line); }
.input-search::-webkit-search-cancel-button { cursor: pointer; }

.rail {
  display: flex; gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: none;
  margin-inline: -16px; padding-inline: 16px;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: none; scroll-snap-align: start; }
.rail.wrap { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; }
.chip { background: var(--bg); white-space: nowrap; font-weight: 500; color: var(--ink); }
.chip-mark { display: grid; }
.count-badge {
  font-size: .76rem; font-weight: 500; font-variant-numeric: tabular-nums;
  color: var(--ink-2); min-width: 1.2em; text-align: center;
}
.count-badge:empty { display: none; }
.chip[aria-pressed='true'] .count-badge { color: inherit; opacity: .75; }
.chip[aria-pressed='true'] .dot { box-shadow: 0 0 0 2px var(--bg); }

.filter-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.filter-field { min-width: 0; }
.filter-label { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: 6px; }
.seg-scroll { overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg-scroll .seg { min-width: 430px; }

.seg {
  --i: 0; --n: 4;
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  background: var(--sunken); border-radius: 12px; padding: 3px;
}
.seg-pill {
  position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--n));
  background: var(--surface); border-radius: 9px;
  box-shadow: 0 1px 3px rgb(0 0 0 / .14);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}
.seg-btn {
  min-height: 40px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: none; border: 0; border-radius: 9px; cursor: pointer;
  color: var(--ink-2); font-size: .9rem; font-weight: 500; white-space: nowrap;
}
.seg-btn[aria-checked='true'] { color: var(--ink); }

.filter-foot { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: .92rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none; position: relative; width: 40px; height: 24px; border-radius: 12px;
  background: var(--line-strong); transition: background-color 160ms;
}
.switch-track::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3);
  transition: transform 200ms cubic-bezier(.2, .8, .2, 1);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.list-head .count { margin: 0; }
.text-btn { background: none; border: 0; color: var(--accent); min-height: 40px; padding: 0 8px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.partners { display: grid; gap: 12px; }

/* ---------- Verdict details ---------- */
.verdict-flag { margin-top: 10px; font-weight: 500; }
.verdict-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent); }
.verdict-block h2 { font-size: .86rem; margin-bottom: 2px; }
.sources { margin-top: 14px; font-size: .92rem; }
.sources summary { cursor: pointer; font-weight: 500; min-height: 32px; }
.sources ul { display: grid; gap: 8px; margin-top: 8px; }
.source-status { display: block; font-size: .82rem; font-weight: 500; }
.sources .link { padding: 0; }

/* ---------- Drug detail ---------- */
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.fact { font-size: .8rem; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); }
.detail { display: grid; gap: 28px; margin-top: 8px; min-width: 0; }
.detail-main, .detail-side { min-width: 0; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.side-head .link { padding: 0; }
.book-ref { margin-top: 16px; }

/* ---------- Guide ---------- */
.guide-section { margin-top: 28px; }
.guide-section h2 { font-size: 1.1rem; margin-bottom: 8px; }
.bullets { display: grid; gap: 6px; padding-left: 1.2em; list-style: disc; }
.source-list { display: grid; gap: 12px; }
.source-list .link { padding: 0; }

.log-layout { display: grid; gap: 8px; }
.block-head { flex-wrap: wrap; }

/* ---------- Touch targets on hover-less devices, hover only where a mouse exists ---------- */
@media (hover: none) {
  .chip:hover { border-color: var(--line); }
  .nav a:hover { background: none; }
  a.row:hover, button.row:hover { background: none; }
}

/* Small tablets and up: more room for filters */
@media (min-width: 641px) {
  .rail { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; }
  .filter-grid { grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); }
  .seg-scroll { overflow: visible; margin-inline: 0; padding-inline: 0; }
  .seg-scroll .seg { min-width: 0; }
  .filters { padding: 20px; }
}

/* Tablets */
@media (min-width: 768px) {
  .antidotes { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .antidote:nth-child(2) { border-top: 1px solid var(--line); }
  .drug-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; border-top: 0; }
  .drug-grid > li:nth-child(-n + 2) { border-top: 1px solid var(--line); }
  .drug-grid > .empty { grid-column: 1 / -1; }
}

/* Laptops and desktops */
@media (min-width: 1024px) {
  .detail { grid-template-columns: minmax(0, 1fr) 380px; gap: 48px; align-items: start; }
  .detail-side { position: sticky; top: 84px; max-height: calc(100dvh - 104px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
  .log-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 48px; align-items: start; }
  .log-layout .stats { margin-top: 0; }
  .drug-grid { grid-template-columns: repeat(3, 1fr); }
  .drug-grid > li:nth-child(3) { border-top: 1px solid var(--line); }
}

/* Phones held sideways: keep content visible by not pinning bars */
@media (max-height: 480px) and (orientation: landscape) {
  .top { position: static; }
  .nav a { min-height: 44px; }
  .nav svg { display: none; }
  .detail-side { position: static; max-height: none; }
}
@media (max-height: 480px) and (orientation: landscape) and (max-width: 640px) {
  .nav { position: static; }
  .foot { padding-bottom: 16px; }
}

/* Very narrow phones */
@media (max-width: 360px) {
  .seg-btn { font-size: .84rem; padding: 0 4px; }
  .brand span { font-size: .94rem; }
  .verdict { padding: 16px; }
  .stats dd { font-size: 1.25rem; }
}

/* ---------- Drug interactions ---------- */
.interaction { margin-top: 14px; padding: 18px 20px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); animation: rise 160ms ease-out; }
.interaction p + p { margin-top: 6px; }
.interaction-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.interaction-effect { font-weight: 500; }
.interaction-list { margin-top: 20px; }
.interaction-list summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.interaction-list .row-sub { padding-left: 0; display: block; }
.detail-main .interaction-list { margin-top: 16px; }

/* ---------- Secondary filters fold away on phones ---------- */
.more-filters summary {
  display: flex; align-items: center; min-height: 44px; cursor: pointer;
  font-size: .92rem; font-weight: 500; color: var(--accent);
}
.more-filters-body { display: grid; gap: 14px; padding-top: 6px; }
@media (min-width: 641px) {
  .more-filters summary { display: none; }
  .more-filters-body { padding-top: 0; }
}
