:root {
  --sec-expand-ms: 260;

  --bg:          #edf2f7; 
  --surface:     #ffffff;
  --surface2:    #f4f7fb;
  --ink:         #0f172a;
  --ink2:        #334155;
  --ink3:        #4d6080;
  --muted:       #627590;
  --rule:        #dce4ee;
  --rule-soft:   rgba(0, 0, 0, 0.04);
  --rule2:       #f1f5f9;
  --glass-rim:   rgba(255, 255, 255, 0.8);

  --accent:      #4338ca;
  --accent-wash: rgba(67,56,202,0.045);

  --sb-bg:       #0f172a;
  --sb-b:        #1e293b;
  --sb-muted:    #64748b;
  --sb-hover:    rgba(255,255,255,0.04);
  --sb-active:   rgba(255,255,255,0.08);
  --sb-cat:      #334155;

  /* Universal Semantic Section Theming — Rich jewel-tone palette */
  --summary-bg:#e7edff; --summary-rule:#a5b4fc; --summary-head:#c7d2fe; --summary-acc:#3730a3;
  --summary-head-grad: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #6366f1 100%);
  --summary-key-tint: rgba(55, 48, 163, 0.12);

  --form-bg:#e3f8f4;   --form-rule:#6ee7d0;   --form-head:#99f6e4;   --form-acc:#0f766e;
  --form-head-grad: linear-gradient(135deg, #0f766e 0%, #0d9488 55%, #14b8a6 100%);
  --form-key-tint: rgba(15, 118, 110, 0.12);

  --ind-bg:#f7ebff;    --ind-rule:#e9d5ff;    --ind-head:#d8b4fe;    --ind-acc:#7e22ce;
  --ind-head-grad: linear-gradient(135deg, #6b21a8 0%, #9333ea 55%, #a855f7 100%);
  --ind-key-tint: rgba(126, 34, 206, 0.12);

  --evid-bg:#e1fbfe;   --evid-rule:#67e8f9;   --evid-head:#a5f3fc;   --evid-acc:#0e7490;
  --evid-head-grad: linear-gradient(135deg, #0c4a6e 0%, #0e7490 55%, #0891b2 100%);
  --evid-key-tint: rgba(14, 116, 144, 0.12);

  --risk-bg:#fff2e3;   --risk-rule:#fdba74;   --risk-head:#fed7aa;   --risk-acc:#c2410c;
  --risk-head-grad: linear-gradient(135deg, #9a3412 0%, #c2410c 55%, #ea580c 100%);
  --risk-key-tint: rgba(194, 65, 12, 0.12);

  --contra-bg:#ffe7ea; --contra-rule:#fda4af; --contra-head:#fecdd3; --contra-acc:#9f1239;
  --contra-head-grad: linear-gradient(135deg, #881337 0%, #9f1239 55%, #be123c 100%);
  --contra-key-tint: rgba(159, 18, 57, 0.12);

  --inter-bg:#fef8dc;  --inter-rule:#fde047;  --inter-head:#fef08a;  --inter-acc:#a16207;
  --inter-head-grad: linear-gradient(135deg, #78350f 0%, #92400e 55%, #b45309 100%);
  --inter-key-tint: rgba(161, 98, 7, 0.12);

  --mon-bg:#e6fdf0;    --mon-rule:#86efac;    --mon-head:#bbf7d0;    --mon-acc:#166534;
  --mon-head-grad: linear-gradient(135deg, #14532d 0%, #166534 55%, #16a34a 100%);
  --mon-key-tint: rgba(22, 101, 52, 0.12);

  --pearl-bg:#fae7f6;  --pearl-rule:#f0abfc;  --pearl-head:#f5d0fe;  --pearl-acc:#86198f;
  --pearl-head-grad: linear-gradient(135deg, #701a75 0%, #86198f 55%, #a21caf 100%);
  --pearl-key-tint: rgba(134, 25, 143, 0.12);

  --spec-bg:#e2f5ff;  --spec-rule:#7dd3fc;  --spec-head:#bae6fd;  --spec-acc:#0369a1; --spec-head-grad:linear-gradient(135deg,#0c4a6e 0%,#0369a1 55%,#0ea5e9 100%); --spec-key-tint:rgba(14, 116, 144, 0.12);

  --sel-bg:#effde5;   --sel-rule:#86efac;   --sel-head:#bbf7d0;   --sel-acc:#3d6b21;
  --sel-head-grad: linear-gradient(135deg, #2d5a1b 0%, #3d6b21 55%, #4d7c0f 100%);
  --sel-key-tint: rgba(61, 107, 33, 0.12);

  --comp-bg:#fce7f3;  --comp-rule:#f9a8d4;  --comp-head:#fbcfe8;  --comp-acc:#9d174d;
  --comp-head-grad: linear-gradient(135deg, #831843 0%, #9d174d 55%, #be185d 100%);
  --comp-key-tint: rgba(157, 23, 77, 0.12);

  --safe-bg:#fef2f2;  --safe-rule:#fca5a5;  --safe-head:#fecaca;  --safe-acc:#991b1b;
  --safe-head-grad: linear-gradient(135deg, #7f1d1d 0%, #991b1b 55%, #b91c1c 100%);
  --safe-key-tint: rgba(153, 27, 27, 0.12);

  --dose-bg:#e8f0fe;  --dose-rule:#93c5fd;  --dose-head:#bfdbfe;  --dose-acc:#1d4ed8;
  --dose-head-grad: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 55%, #3b82f6 100%);
  --dose-key-tint: rgba(29, 78, 216, 0.12);

  --src-bg:#f1f5f9;  --src-rule:#94a3b8;  --src-head:#cbd5e1;  --src-acc:#475569;
  --src-head-grad: linear-gradient(135deg, #334155 0%, #475569 55%, #64748b 100%);
  --src-key-tint: rgba(71, 85, 105, 0.12);

  /* Risk Level Badges */
  --rc-bg:rgba(159,18,57,0.18); --rc-fg:#be123c; --rc-b:rgba(159,18,57,0.4); /* Red - Critical/Absolute — filled for visual differentiation */
  --rp-bg:#fdf2f8; --rp-fg:#d926a9; --rp-b:#fbcfe8; /* Hot Pink - Populations/Demographics */
  --rh-bg:#fff7ed; --rh-fg:#b45309; --rh-b:rgba(180,83,9,0.35); /* Orange - High/Mandatory/Caution — slightly increased border opacity */
  --rm-bg:#fefce8; --rm-fg:#a16207; --rm-b:#fef08a; /* Yellow - Moderate */
  --rl-bg:#f0fdf4; --rl-fg:#15803d; --rl-b:#bbf7d0; /* Green - Low/Minimal */
  --rn-bg:#eff6ff; --rn-fg:#1d4ed8; --rn-b:#bfdbfe; /* Blue - Safe/None/Beneficial */
  --rd-bg:#f8fafc; --rd-fg:#64748b; --rd-b:#cbd5e1; /* Neutral - Unknown / unclassified */
}



*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color-scheme: light; }

body {
  display: flex; flex-direction: column;
  min-width: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(59, 130, 246, 0.25); color: var(--ink); }

b, strong { font-weight: 700; color: var(--ink); }
.text-rose-600 { color: #e11d48 !important; font-weight: 600; }

/* Global Accessibility Focus & Tap Target Safeties */
:focus-visible { outline: 2px solid var(--summary-acc); outline-offset: 2px; border-radius: 4px; }
button:focus-visible,
a:focus-visible,
.nav-item:focus-visible,
.sec-nav-chip:focus-visible {
  outline: 2px solid var(--summary-acc);
  outline-offset: 2px;
}
button, a, .nav-item, .search-clear { -webkit-tap-highlight-color: transparent; }
button { background: none; border: none; cursor: pointer; outline: none; font-family: inherit; }

/* ══════════════════════════════════════════════════
   TOP APP BAR
══════════════════════════════════════════════════ */

#appBar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 0 max(1.25rem, env(safe-area-inset-right)) 0 max(1.25rem, env(safe-area-inset-left)); flex-shrink: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: none; box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 4px 16px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  position: sticky; top: 0; z-index: 50;
  gap: 1rem;
}
.appbar-wordmark {
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1rem; font-weight: 700;
  color: #ffffff; letter-spacing: -0.02em; white-space: nowrap; flex-shrink: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
#currentDrugChip {
  font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 500;
  color: rgba(148,163,184,0.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; text-align: center; min-width: 0;
}
#currentDrugChip.has-drug { color: #e2e8f0; }
#currentDrugChip .chip-class { opacity: 0.75; font-weight: 400; }
#paletteBtn {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 0.4rem 0.75rem;
  font-family: 'Inter', sans-serif; font-size: 0.8rem; font-weight: 500;
  color: #cbd5e1; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
#paletteBtn:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.25); }
.palette-btn-kbd { font-family: 'Geist Mono', monospace; font-size: 0.65rem; color: rgba(148,163,184,0.7); border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; padding: 0.1rem 0.35rem; background: rgba(255,255,255,0.06); }
.empty-state-add-link {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.25rem;
  font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 500;
  color: rgba(148,163,184,0.7); text-decoration: none;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 20px;
  padding: 0.3rem 0.75rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.empty-state-add-link:hover { color: #cbd5e1; border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
.empty-state-add-link:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.empty-state-add-link svg { flex-shrink: 0; opacity: 0.7; }

/* ══════════════════════════════════════════════════
   COMMAND PALETTE OVERLAY
══════════════════════════════════════════════════ */
#palette {
  position: fixed; inset: 0; z-index: 200;
  visibility: hidden; opacity: 0;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
#palette.open { visibility: visible; opacity: 1; }

#paletteBackdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

#palettePanel {
  position: absolute; top: max(1rem, calc(10vh + env(safe-area-inset-top))); left: 50%; transform: translateX(-50%) scale(0.96);
  width: min(620px, calc(100vw - 2rem)); max-width: calc(100vw - 2rem);
  background: var(--surface); border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1);
  border: 1px solid var(--rule); overflow: hidden;
  display: flex; flex-direction: column; max-height: min(76vh, calc(100dvh - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.18s ease;
  opacity: 0;
}
#palette.open #palettePanel { transform: translateX(-50%) scale(1); opacity: 1; }

.palette-search-wrap {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--rule);
  flex-shrink: 0; min-width: 0;
}
.palette-search-icon { color: var(--muted); flex-shrink: 0; }
#paletteInput {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: 'Inter', sans-serif; font-size: 1rem; color: var(--ink);
  min-width: 0;
}
#paletteInput::placeholder { color: var(--muted); }
.palette-esc-hint { font-family: 'Geist Mono', monospace; font-size: 0.65rem; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0.1rem 0.4rem; background: var(--surface2); flex-shrink: 0; }

#paletteList {
  flex: 1; overflow-y: auto; padding: 0.4rem 0;
  scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.12) transparent;
  overscroll-behavior: contain;
}
#paletteList::-webkit-scrollbar { width: 6px; }
#paletteList::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }

#paletteList .cat-label {
  font-family: 'Geist Mono', monospace; font-size: 0.6rem; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--muted); padding: 1.2rem 1.1rem 0.5rem;
  font-weight: 700;
}
#paletteList .cat-group + .cat-group .cat-label {
  padding-top: 2rem;
}
#indicationGroup .cat-label.ind-search-label {
  display: flex; align-items: center; gap: 0.4rem;
  color: #0891b2; border-top: 1px solid var(--rule); padding-top: 1.1rem;
}
#indicationGroup .cat-label.ind-search-label svg { flex-shrink: 0; opacity: 0.8; }
#mechanismGroup .cat-label.mech-search-label {
  display: flex; align-items: center; gap: 0.4rem;
  color: #7c3aed; border-top: 1px solid var(--rule); padding-top: 1.1rem;
}
#mechanismGroup .cat-label.mech-search-label svg { flex-shrink: 0; opacity: 0.8; }
#paletteFooter {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 1.1rem; border-top: 1px solid var(--rule);
  font-family: 'Geist Mono', monospace; font-size: 0.6rem; color: var(--muted);
  flex-shrink: 0; background: var(--surface2);
}
#paletteList .nav-item {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.6rem 1rem; cursor: pointer;
  border-radius: 8px; margin: 0.1rem 0.6rem; width: calc(100% - 1.2rem);
  text-align: left; border: 1px solid transparent;
  transition: background-color 0.12s ease;
  background: none;
}
#paletteList .nav-item:hover { background: var(--surface2); border-color: var(--rule); }
#paletteList .nav-item.focused { background: var(--surface2); border-color: var(--rule); border-left: 2px solid var(--item-acc, var(--summary-acc)); padding-left: calc(1rem - 2px); }
#paletteList .nav-item.active { background: var(--surface2); border-color: var(--rule); border-left: 2px solid var(--item-acc, var(--summary-acc)); padding-left: calc(1rem - 2px); }
#paletteList .nav-dot { width: 8px; height: 8px; border-radius: 50%; opacity: 0.7; flex-shrink: 0; margin-top: 4px; }
#paletteList .nav-name { font-family: 'Inter', sans-serif; font-size: 0.9rem; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; line-height: 1.3; }
#paletteList .nav-name-wrap { flex: 1; min-width: 0; }
#paletteList .nav-sub { font-family: 'Inter', sans-serif; font-size: 0.7rem; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.1rem; }
#paletteList .nav-tag { font-family: 'Geist Mono', monospace; font-size: 0.6rem; letter-spacing: 0.05em; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 4px; background: var(--surface2); white-space: nowrap; border: 1px solid var(--rule); }
#paletteList .nav-variant { color: var(--ink3); font-weight: 500; }
#paletteList .nav-ind-snippet { font-family: 'Inter', sans-serif; font-size: 0.68rem; color: var(--ink3); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.15rem; opacity: 0.85; }
#paletteList .nav-ind-snippet mark.ind-hl,
#paletteList .nav-name mark.ind-hl { background: rgba(251,191,36,0.22); color: inherit; font-style: inherit; border-radius: 2px; padding: 0 1px; }
.ind-show-more-btn { display: block; width: 100%; padding: 0.45rem 1rem; font-family: 'Inter', sans-serif; font-size: 0.72rem; font-weight: 500; color: var(--ink3); background: none; border: none; border-top: 1px solid var(--rule); cursor: pointer; text-align: left; letter-spacing: 0.01em; transition: color 0.12s ease, background-color 0.12s ease; }
.ind-show-more-btn:hover { color: var(--ink); background: var(--surface2); }

#paletteChips {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding: 0.6rem 1rem 0.5rem;
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
#paletteChips::-webkit-scrollbar { display: none; }
.palette-chip {
  font-family: 'Geist Mono', monospace; font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.22rem 0.65rem; border-radius: 100px;
  border: 1px solid var(--rule); background: transparent; color: var(--ink3);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.palette-chip:hover { background: var(--surface2); color: var(--ink); }
.palette-chip.active { background: var(--accent, #4f46e5); color: #fff; border-color: var(--accent, #4f46e5); }

#paletteClassChips {
  display: none; flex-wrap: wrap; gap: 0.3rem;
  padding: 0 1rem 0.55rem; border-bottom: 1px solid var(--rule);
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
#paletteClassChips::-webkit-scrollbar { display: none; }
.palette-class-chip {
  font-family: 'Geist Mono', monospace; font-size: 0.55rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: none;
  padding: 0.18rem 0.55rem; border-radius: 100px;
  border: 1px solid var(--rule); background: transparent; color: var(--ink3);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.palette-class-chip:hover { background: var(--surface2); color: var(--ink); }
.palette-class-chip.active {
  background: rgba(79, 70, 229, 0.1); color: var(--accent, #4f46e5);
  border-color: rgba(79, 70, 229, 0.3);
}
.chip-count {
  display: inline-block; font-size: 0.5rem; font-weight: 700;
  padding: 0.06rem 0.3rem; border-radius: 100px;
  background: var(--surface2); color: var(--ink3);
  margin-left: 0.2rem; vertical-align: middle;
  line-height: 1.4; letter-spacing: 0;
}
.palette-class-chip.active .chip-count {
  background: rgba(79, 70, 229, 0.15); color: var(--accent, #4f46e5);
}

.fav-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--rule); color: var(--ink3); cursor: pointer; transition: color 0.15s, background-color 0.15s; background: none; }
.fav-btn:hover { background: var(--surface2); color: var(--ink); }
.fav-btn.active { color: #d97706; border-color: #fde68a; background: #fefce8; }
.fav-btn.pop { animation: favPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes favPop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 70% { transform: scale(0.88); } 100% { transform: scale(1); } }

.section-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows calc(var(--sec-expand-ms) * 1ms) cubic-bezier(0.16,1,0.3,1); }
.section[data-collapsed] .section-body { grid-template-rows: 0fr; }
.section-body > table, .section-body > .sec-grid { overflow: hidden; min-height: 0; }
.section-chevron { margin-left: auto; color: var(--sec-acc, var(--muted)); opacity: 0.6; transition: transform 0.26s cubic-bezier(0.16,1,0.3,1), opacity 0.15s ease; flex-shrink: 0; }
.section[data-collapsed] .section-chevron { transform: rotate(-90deg); opacity: 1; }
.section-head { cursor: pointer; user-select: none; width: 100%; text-align: left; border: none; background: transparent; font: inherit; color: inherit; }
.section-head:hover .section-chevron { opacity: 1; }

/* Section icon pop/tuck on expand/collapse */
@keyframes sec-icon-pop  { 0% { transform: scale(1); filter: brightness(1); } 45% { transform: scale(1.14); filter: brightness(1.25); } 100% { transform: scale(1); filter: brightness(1); } }
@keyframes sec-icon-tuck { 0% { transform: scale(1.06); filter: brightness(1.12); } 100% { transform: scale(1); filter: brightness(1); } }
.section-head[aria-expanded="true"]  .sec-icon { animation: sec-icon-pop  180ms cubic-bezier(0.16,1,0.3,1) both; }
.section-head[aria-expanded="false"] .sec-icon { animation: sec-icon-tuck 150ms ease-out both; }
/* Breathing Empty State */
@keyframes gentleBreathe { 0%, 100% { opacity: 0.4; transform: scale(0.98); } 50% { opacity: 0.8; transform: scale(1.02); } }
.empty-state { display: none; padding: 3rem 1.5rem; font-size: 0.95rem; color: var(--muted); text-align: center; }
.empty-state.visible { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; }
.empty-icon { animation: gentleBreathe 3.5s infinite ease-in-out; color: var(--ink3); }

/* ══════════════════════════════════════════════════
   MAIN CONTENT AREA & SCROLLBAR
══════════════════════════════════════════════════ */
#main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; background: var(--bg); height: 100%; position: relative; scroll-padding-top: 96px; scrollbar-width: auto; scrollbar-color: rgba(15,23,42,0.15) transparent; overscroll-behavior: contain; }
#main::-webkit-scrollbar { width: 8px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.15); border-radius: 10px; border: 2px solid var(--bg); }
#main::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,0.25); }

#content-wrapper { width: 100%; min-width: 0; display: flex; flex-direction: column; position: relative; }
#content { flex: 0 0 auto; min-width: 0; }

#scroll-sentinel { position: absolute; top: 0; left: 0; right: 0; height: 1px; visibility: hidden; pointer-events: none; }

.clinical-footer { padding: 1.75rem 2.5rem 2.25rem; text-align: center; border-top: 1px solid var(--rule-soft); margin-top: 2rem; flex-shrink: 0; max-width: 1100px; width: 100%; align-self: center; }
.clinical-footer-title { font-family: 'Geist Mono', monospace; font-size: 0.75rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.8rem; font-weight: 600; }
.clinical-footer-text { font-family: 'Inter', sans-serif; font-size: 0.85rem; color: var(--muted); line-height: 1.6; }

/* Entrance Animations */
.drug-page { padding-bottom: 4rem; opacity: 0; animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.hero-inner, .stats-bar, .sections { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.stats-bar { animation-delay: 0.05s; }
.sections { animation-delay: 0.1s; }

@keyframes fadeUp { to { opacity: 1; } }
@keyframes slideUp { 0% { opacity: 0; transform: translateY(15px); } 100% { opacity: 1; transform: none; } }

/* ══════════════════════════════════════════════════
   STICKY HEADER & AMBIENT MESH GLOW
══════════════════════════════════════════════════ */
.sticky-header { position: sticky; top: 0; z-index: 41; display: flex; flex-direction: column; transition: box-shadow 0.4s ease; }
.sticky-header.scrolled { box-shadow: 0 4px 20px rgba(0,0,0,0.03), 0 10px 30px var(--accent-wash, rgba(0,0,0,0.02)); }

.hero { 
  padding: clamp(1.5rem, 3vw, 2.5rem) clamp(1.5rem, 4vw, 3rem); 
  background: var(--surface); border-bottom: 1px solid var(--rule-soft); 
  position: relative; overflow: hidden; 
  transition: padding 0.4s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.4s ease;
}
.sticky-header.scrolled .hero {
  padding: 0.85rem clamp(1.5rem, 4vw, 3rem);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
}

/* Beautiful Offset Mesh Glow behind the title */
.hero::before {
  display: block; content: '';
  position: absolute; top: -40%; left: -5%; width: 55%; height: 220%;
  background: radial-gradient(ellipse, var(--accent-wash, rgba(99,102,241,0.05)) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
.hero::after { display: none; }
.hero-inner { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; gap: 1.5rem; max-width: 1100px; margin: 0 auto; min-width: 0; }

.hero-left { min-width: 0; flex: 1 1 auto; }
.hero-eyebrow { font-family: 'Geist Mono', monospace; font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.4rem; font-weight: 700; transition: font-size 0.4s cubic-bezier(0.16, 1, 0.3, 1), margin-bottom 0.4s ease; }
.hero-name { font-family: 'Plus Jakarta Sans', sans-serif; font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; color: var(--ink); letter-spacing: -0.025em; line-height: 1.1; margin-bottom: 0.6rem; text-wrap: balance; transition: font-size 0.4s cubic-bezier(0.16, 1, 0.3, 1), margin-bottom 0.4s ease; }
.hero-class { font-family: 'Inter', sans-serif; font-size: 0.95rem; color: #475569; font-weight: 400; line-height: 1.5; transition: font-size 0.4s ease; }
.hero-class b { color: var(--accent); font-weight: 600; }

.sticky-header.scrolled .hero-name { font-size: 1.35rem; margin-bottom: 0.2rem; }
.sticky-header.scrolled .hero-eyebrow { font-size: 0.65rem; margin-bottom: 0.2rem; }
.sticky-header.scrolled .hero-class { font-size: 0.85rem; }

.hero-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.sticky-header.scrolled .hero-right { transform: scale(0.9); transform-origin: right; }

.hero-badge, .hero-schedule { font-family: 'Geist Mono', monospace; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 0.35rem 0.65rem; border-radius: 8px; border: 1px solid var(--rule-soft); white-space: nowrap; box-shadow: 0 1px 2px rgba(15,23,42,0.04); transition: font-size 0.4s cubic-bezier(0.16, 1, 0.3, 1), padding 0.4s ease, border-radius 0.4s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; cursor: default; pointer-events: none; position: relative; display: inline-flex; align-items: center; justify-content: center; line-height: 1.2; }
.hero-badge { color: var(--accent); background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.hero-schedule { color: #334155; background: #f1f5f9; border: 1px solid rgba(15,23,42,0.06); }

/* Schedule explainer tooltip — anchored to its parent .hero-schedule button.
   On mobile (≤768px) we centre it under the 2-col grid cell rather than
   pinning to the right so it never overflows the viewport. */
.hero-tooltip {
  position: absolute; top: calc(100% + 0.5rem); right: 0;
  background: #0f172a; color: #f8fafc;
  padding: 0.65rem 0.8rem; border-radius: 8px;
  width: max-content; max-width: min(260px, calc(100vw - 2rem));
  font-family: 'Inter', sans-serif; font-size: 0.72rem; font-weight: 400;
  text-transform: none; letter-spacing: 0;
  line-height: 1.45; text-align: left; white-space: normal;
  box-shadow: 0 8px 24px rgba(15,23,42,0.22), 0 2px 6px rgba(15,23,42,0.12);
  z-index: 60;
  display: flex; flex-direction: column; gap: 0.2rem;
  animation: heroTooltipFade 0.14s ease-out;
}
.hero-tooltip[hidden] { display: none; }
.hero-tooltip-title { font-family: 'Geist Mono', monospace; font-size: 0.68rem; letter-spacing: 0.06em; color: #93c5fd; font-weight: 700; }
.hero-tooltip-body { color: #e2e8f0; }
@keyframes heroTooltipFade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ══════════════════════════════════════════════════
   HIGH-DENSITY STATS RIBBON & ECG PULSE (COMPACT 4-GRID)
══════════════════════════════════════════════════ */
.stats-bar { 
  background: linear-gradient(to bottom, rgba(67,56,202,0.018) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--rule-soft);
  border-top: 1px solid transparent;
  transition: background-color 0.4s ease;
}
.stats-inner {
  display: flex;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

.stat-item { 
  padding: 0.6rem 1rem; 
  border-right: 1px solid var(--rule-soft); 
  flex: 1 1 22%; 
  min-width: 110px;
  position: relative; 
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  animation: fadeRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.stat-item:last-child {
  border-right: none;
}

.stat-item:nth-child(1) { animation-delay: 0.05s; }
.stat-item:nth-child(2) { animation-delay: 0.10s; }
.stat-item:nth-child(3) { animation-delay: 0.15s; }
.stat-item:nth-child(4) { animation-delay: 0.20s; }
@keyframes fadeRight { 0% { opacity: 0; transform: translateX(-10px); } 100% { opacity: 1; transform: none; } }

.stat-item::before { content: ''; position: absolute; left: 0; top: 25%; bottom: 25%; width: 3px; background: var(--accent); opacity: 0.22; border-radius: 0 3px 3px 0; }
.stat-item.flagged::before { background: #e11d48; opacity: 0.5; }

.stat-label { 
  font-family: 'Geist Mono', monospace; font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.2rem; font-weight: 600; 
  white-space: normal; 
  line-height: 1.3;
  transition: font-size 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat-value { 
  font-family: 'Inter', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--ink); 
  white-space: normal; 
  overflow-wrap: break-word; 
  line-height: 1.2; 
  min-height: 1em; 
  transition: font-size 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Refined ECG / Double-Beat Pulse for Flags */
@keyframes ecgPulse { 0% { background-color: rgba(225, 29, 72, 0); } 10% { background-color: rgba(225, 29, 72, 0.08); } 20% { background-color: rgba(225, 29, 72, 0); } 30% { background-color: rgba(225, 29, 72, 0.08); } 100% { background-color: rgba(225, 29, 72, 0); } }
.stat-item.flagged { animation: ecgPulse 3.5s infinite ease-in-out; }
.stat-item.flagged .stat-value { color: #e11d48; }

.stat-value.hi { color: #e11d48; } 
.stat-value.warn { color: #d97706; } 
.stat-value.good { color: #16a34a; } 

/* ══════════════════════════════════════════════════
   HIGH-DENSITY CLINICAL TABLES & ROW TRACKING
══════════════════════════════════════════════════ */
.sections { padding: 1.75rem clamp(1.5rem, 4vw, 3rem); display: flex; flex-direction: column; gap: 1.5rem; align-items: stretch; max-width: 1100px; margin: 0 auto; width: 100%; }

/* Refined section cards */
.section { 
  background: var(--surface); border: 1px solid rgba(15, 23, 42, 0.06); border-left-width: 1px; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.035);
  display: flex; flex-direction: column; min-width: 0;
  animation: sectionFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: box-shadow 0.2s ease, border-left-color 0.2s ease, transform 0.2s ease;
}
.section:hover {
  box-shadow: 0 2px 6px rgba(15,23,42,0.05), 0 8px 24px rgba(15,23,42,0.06);
}
.section[data-collapsed] {
  box-shadow: 0 1px 2px rgba(15,23,42,0.03), 0 2px 6px rgba(15,23,42,0.025);
}
.section[data-collapsed]:hover {
  box-shadow: 0 2px 4px rgba(15,23,42,0.05), 0 6px 18px rgba(15,23,42,0.06);
  transform: translateY(-1px);
}
@keyframes sectionFadeIn { 0% { opacity: 0; transform: translateY(15px); } 100% { opacity: 1; transform: none; } }

.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.10s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.20s; }
.section:nth-child(5) { animation-delay: 0.25s; }
.section:nth-child(6) { animation-delay: 0.30s; }
.section:nth-child(7)  { animation-delay: 0.35s; }
.section:nth-child(8)  { animation-delay: 0.40s; }
.section:nth-child(9)  { animation-delay: 0.45s; }
.section:nth-child(10) { animation-delay: 0.50s; }
.section:nth-child(11) { animation-delay: 0.55s; }
.section:nth-child(12) { animation-delay: 0.60s; }

/* Per-section card borders — accent variable injection for header tints */
.section.summary { border-color: var(--summary-rule); --sec-acc: var(--summary-acc); --sec-bg: rgba(55,48,163,0.07);  --sec-bg-h: rgba(55,48,163,0.08); }
.section.form    { border-color: var(--form-rule);    --sec-acc: var(--form-acc);    --sec-bg: rgba(15,118,110,0.07);  --sec-bg-h: rgba(15,118,110,0.08); }
.section.ind     { border-color: var(--ind-rule);     --sec-acc: var(--ind-acc);     --sec-bg: rgba(126,34,206,0.07);  --sec-bg-h: rgba(126,34,206,0.08); }
.section.evid    { border-color: var(--evid-rule);    --sec-acc: var(--evid-acc);    --sec-bg: rgba(14,116,144,0.07);  --sec-bg-h: rgba(14,116,144,0.08); }
.section.risk    { border-color: var(--risk-rule);    --sec-acc: var(--risk-acc);    --sec-bg: rgba(194,65,12,0.07);   --sec-bg-h: rgba(194,65,12,0.08); }
.section.contra  { border-color: var(--contra-rule);  --sec-acc: var(--contra-acc);  --sec-bg: rgba(159,18,57,0.07);   --sec-bg-h: rgba(159,18,57,0.08); }
.section.inter   { border-color: var(--inter-rule);   --sec-acc: var(--inter-acc);   --sec-bg: rgba(161,98,7,0.07);    --sec-bg-h: rgba(161,98,7,0.08); }
.section.mon     { border-color: var(--mon-rule);     --sec-acc: var(--mon-acc);     --sec-bg: rgba(22,101,52,0.07);   --sec-bg-h: rgba(22,101,52,0.08); }
.section.pearl   { border-color: var(--pearl-rule);   --sec-acc: var(--pearl-acc);   --sec-bg: rgba(134,25,143,0.07);  --sec-bg-h: rgba(134,25,143,0.08); }
.section.sel     { border-color: var(--sel-rule);     --sec-acc: var(--sel-acc);     --sec-bg: rgba(61,107,33,0.07);   --sec-bg-h: rgba(61,107,33,0.08); }
.section.comp    { border-color: var(--comp-rule);    --sec-acc: var(--comp-acc);    --sec-bg: rgba(157,23,77,0.07);   --sec-bg-h: rgba(157,23,77,0.08); }
.section.safe    { border-color: var(--safe-rule);    --sec-acc: var(--safe-acc);    --sec-bg: rgba(153,27,27,0.07);   --sec-bg-h: rgba(153,27,27,0.08); }
.section.spec    { border-color: var(--spec-rule);    --sec-acc: var(--spec-acc);    --sec-bg: rgba(3,105,161,0.07);   --sec-bg-h: rgba(3,105,161,0.08); }
.section.dose    { border-color: var(--dose-rule);    --sec-acc: var(--dose-acc);    --sec-bg: rgba(29,78,216,0.07);   --sec-bg-h: rgba(29,78,216,0.08); }
.section.src     { border-color: var(--src-rule);     --sec-acc: var(--src-acc);     --sec-bg: rgba(71,85,105,0.07);   --sec-bg-h: rgba(71,85,105,0.08); }
.section.default { border-color: rgba(30,73,118,0.28); --sec-acc: #1e4976;           --sec-bg: rgba(30,73,118,0.07);   --sec-bg-h: rgba(30,73,118,0.08); }

/* Collapsed state: prominent accent left-border strip + stronger type-label badge for instant section-type recognition */
.section[data-collapsed] { border-left-width: 4px; border-left-color: var(--sec-acc); }
.section[data-collapsed] .sec-type-label {
  background: color-mix(in srgb, var(--sec-acc, var(--accent)) 16%, transparent);
  border-color: color-mix(in srgb, var(--sec-acc, var(--accent)) 35%, transparent);
}

/* Clean modern section headings — softer, less-competing band */
.section-head { padding: clamp(0.5rem, calc(0.41rem + 0.38vw), 0.75rem) clamp(1.1rem, calc(0.99rem + 0.45vw), 1.4rem); display: flex; align-items: center; gap: 0.75rem; background: linear-gradient(180deg, color-mix(in srgb, var(--sec-acc, var(--accent)) 6%, var(--surface)) 0%, color-mix(in srgb, var(--sec-acc, var(--accent)) 3%, var(--surface)) 100%); border-bottom: 1px solid rgba(0,0,0,0.06); transition: background 0.15s ease, border-bottom-color 0.15s ease; }
.section-head:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--sec-acc, var(--accent)) 10%, var(--surface)) 0%, color-mix(in srgb, var(--sec-acc, var(--accent)) 6%, var(--surface)) 100%); }
.section[data-collapsed] .section-head { border-bottom-color: transparent; background: linear-gradient(180deg, color-mix(in srgb, var(--sec-acc, var(--accent)) 4%, var(--surface)) 0%, var(--surface) 100%); }
.sec-type-label { font-family: 'Geist Mono', monospace; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--sec-acc, var(--accent)); background: color-mix(in srgb, var(--sec-acc, var(--accent)) 10%, transparent); border: 1px solid color-mix(in srgb, var(--sec-acc, var(--accent)) 28%, transparent); border-radius: 100px; padding: 0.2rem 0.65rem; white-space: nowrap; flex-shrink: 0; display: flex; align-items: center; gap: 0.3rem; box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 1px 2px rgba(15,23,42,0.04); }
.sec-icon { color: var(--sec-acc, var(--accent)); flex-shrink: 0; display: block; width: 16px; height: 16px; }
.section-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: clamp(0.78rem, calc(0.566rem + 0.535vw), 0.9rem); font-weight: 700; letter-spacing: 0.03em; color: var(--ink); text-wrap: balance; flex: 1; }

/* ── Structured 2-col grid section body ──────────────────────────────────────── */
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; }
.sec-cell { padding: 0 1.5rem 1.1rem; border-bottom: 1px solid var(--rule-soft); display: flex; flex-direction: column; gap: 0; background: var(--surface); transition: background-color 0.12s ease; box-shadow: inset 0 1px 0 rgba(255,255,255,0.55); }
.sec-cell:nth-child(odd) { border-right: 1px solid var(--rule-soft); }
.sec-cell:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: none; }
.sec-cell:nth-last-child(-n+2) { border-bottom: none; }
.sec-cell:last-child:nth-child(odd) { border-bottom: none; }
.sec-cell:hover { background: color-mix(in srgb, var(--sec-acc, var(--accent)) 5%, var(--surface)) !important; }
.sec-cell-label { font-family: 'Geist Mono', monospace; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.11em; color: var(--sec-acc, var(--accent)); line-height: 1.2; padding: 0.45rem 1.5rem 0.4rem; margin: 0 -1.5rem; background: color-mix(in srgb, var(--sec-acc, var(--accent)) 6%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--sec-acc, var(--accent)) 16%, transparent); }
.sec-cell-value { font-family: 'Inter', sans-serif; font-size: 0.875rem; font-weight: 400; color: var(--ink); line-height: 1.6; overflow-wrap: break-word; padding-top: 0.6rem; }

/* Per-section cell background tints — gentle washes (3.5–4% alpha), not pastels */
.section.summary .sec-cell { background: rgba(67,56,202,0.035); }
.section.dose .sec-cell    { background: rgba(29,78,216,0.035); }
.section.form .sec-cell    { background: rgba(15,118,110,0.035); }
.section.ind .sec-cell     { background: rgba(126,34,206,0.035); }
.section.evid .sec-cell    { background: rgba(14,116,144,0.035); }
.section.risk .sec-cell    { background: rgba(194,65,12,0.038); }
.section.contra .sec-cell  { background: rgba(159,18,57,0.038); }
.section.inter .sec-cell   { background: rgba(161,98,7,0.04); }
.section.mon .sec-cell     { background: rgba(22,101,52,0.035); }
.section.pearl .sec-cell   { background: rgba(134,25,143,0.035); }
.section.sel .sec-cell     { background: rgba(61,107,33,0.035); }
.section.comp .sec-cell    { background: rgba(157,23,77,0.035); }
.section.safe .sec-cell    { background: rgba(153,27,27,0.038); }
.section.spec .sec-cell    { background: rgba(3,105,161,0.035); }
.section.src .sec-cell     { background: rgba(71,85,105,0.04); }
.section.default .sec-cell { background: rgba(30,73,118,0.035); }

/* ══════════════════════════════════════════════════
   SECTION JUMP NAVIGATION STRIP
══════════════════════════════════════════════════ */
.section-nav-wrap {
  background: rgba(246,247,251,0.85);
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid rgba(15,23,42,0.06);
  border-top: 1px solid rgba(255,255,255,0.7);
  position: sticky;
  top: 0;
  z-index: 40;
  transition: box-shadow 0.4s ease;
  min-width: 0;
}
.section-nav-wrap.scrolled {
  box-shadow: 0 4px 18px rgba(0,0,0,0.06), 0 1px 0 rgba(0,0,0,0.04);
}
.sec-nav-strip {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.15rem;
  padding: 0.22rem clamp(1rem, 3vw, 2.5rem);
  max-width: 1100px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}
.sec-nav-strip::-webkit-scrollbar { display: none; }
.sec-nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink3);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.chip-label-short { display: none; }
.chip-label-full  { display: inline; }
.sec-nav-chip .sec-icon {
  flex-shrink: 0;
  color: var(--sec-acc, var(--ink3));
  opacity: 0.65;
}
.sec-nav-chip[aria-current="true"] .sec-icon {
  color: rgba(255,255,255,0.9);
  opacity: 1;
}
.sec-nav-chip[data-sec-type="summary"] { --sec-acc: var(--summary-acc); }
.sec-nav-chip[data-sec-type="dose"]    { --sec-acc: var(--dose-acc); }
.sec-nav-chip[data-sec-type="form"]    { --sec-acc: var(--form-acc); }
.sec-nav-chip[data-sec-type="ind"]     { --sec-acc: var(--ind-acc); }
.sec-nav-chip[data-sec-type="evid"]    { --sec-acc: var(--evid-acc); }
.sec-nav-chip[data-sec-type="risk"]    { --sec-acc: var(--risk-acc); }
.sec-nav-chip[data-sec-type="contra"]  { --sec-acc: var(--contra-acc); }
.sec-nav-chip[data-sec-type="inter"]   { --sec-acc: var(--inter-acc); }
.sec-nav-chip[data-sec-type="mon"]     { --sec-acc: var(--mon-acc); }
.sec-nav-chip[data-sec-type="pearl"]   { --sec-acc: var(--pearl-acc); }
.sec-nav-chip[data-sec-type="sel"]     { --sec-acc: var(--sel-acc); }
.sec-nav-chip[data-sec-type="comp"]    { --sec-acc: var(--comp-acc); }
.sec-nav-chip[data-sec-type="spec"]    { --sec-acc: var(--spec-acc); }
.sec-nav-chip[data-sec-type="safe"]    { --sec-acc: var(--safe-acc); }
.sec-nav-chip[data-sec-type="src"]     { --sec-acc: var(--src-acc); }
.sec-nav-chip:hover {
  background: color-mix(in srgb, var(--sec-acc, var(--accent)) 10%, transparent);
  color: var(--sec-acc, var(--accent));
  border-color: transparent;
}
.sec-nav-chip:hover .sec-icon {
  color: var(--sec-acc, var(--accent));
  opacity: 1;
}
.sec-nav-chip[aria-current="true"] {
  background: var(--sec-acc, var(--accent));
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--sec-acc, var(--accent)) 35%, transparent), inset 0 1px 0 rgba(255,255,255,0.18);
}
@keyframes secFlash {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #4f46e5) 35%, transparent); }
  50%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent, #4f46e5) 0%, transparent); }
  100% { box-shadow: none; }
}
.section.sec-flash {
  animation: secFlash 0.9s ease-out forwards;
}
/* Collapse-all action button in section nav strip */
.sec-collapse-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink3);
  cursor: pointer;
  margin-left: 0.4rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sec-collapse-all-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.sec-collapse-all-btn:hover {
  background: rgba(0,0,0,0.04);
  color: var(--ink2);
  border-color: transparent;
}
.sec-collapse-all-btn:active {
  background: rgba(0,0,0,0.1);
}

/* ══════════════════════════════════════════════════
   QUICK PRESCRIBING CARD
   Lives inside .sections — shares its container,
   padding, and gap. Chrome matches .section exactly.
══════════════════════════════════════════════════ */
.quick-card {
  animation: sectionFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.03s;
}
/* Matches .section border/shadow/radius — refined indigo accent */
.quick-card-inner {
  background: var(--surface);
  border: 1px solid rgba(15,23,42,0.06);
  border-left-width: 4px;
  border-left-color: var(--accent, #4338ca);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 6px 24px rgba(67,56,202,0.06);
  transition: box-shadow 0.2s ease;
}
.quick-card-inner:hover {
  box-shadow: 0 2px 6px rgba(15,23,42,0.06), 0 10px 30px rgba(67,56,202,0.08);
}
/* Matches .section-head gradient + border */
.quick-card-head {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent, #4338ca) 9%, var(--surface)) 0%,
    color-mix(in srgb, var(--accent, #4338ca) 4%, var(--surface)) 100%);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  transition: background 0.15s ease;
}
.quick-card-head:hover {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent, #4338ca) 13%, var(--surface)) 0%,
    color-mix(in srgb, var(--accent, #4338ca) 7%, var(--surface)) 100%);
}
/* Solid accent icon square */
.quick-card-head-icon {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent, #4338ca);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(67,56,202,0.4);
}
/* Matches .section-title */
.quick-card-head-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.92rem; font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  flex: 1;
}
/* Matches .sec-type-label pill */
.quick-card-head-badge {
  font-family: 'Geist Mono', monospace;
  font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--accent, #4338ca);
  background: color-mix(in srgb, var(--accent, #4338ca) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #4338ca) 28%, transparent);
  border-radius: 100px;
  padding: 0.18rem 0.6rem;
  white-space: nowrap;
}
.quick-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
/* Matches .sec-cell exactly */
.quick-card-row {
  display: flex; flex-direction: column;
  padding: 0 1.5rem 1.1rem;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--surface);
  transition: background-color 0.12s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}
.quick-card-row:nth-child(odd)        { border-right: 1px solid var(--rule-soft); }
.quick-card-row:nth-last-child(-n+2)  { border-bottom: none; }
.quick-card-row:last-child            { border-bottom: none !important; }
.quick-card-row:nth-child(odd):last-child { grid-column: 1 / -1; border-right: none; }
/* Alternating pair tint — pairs of rows lightly washed for ledger feel */
.quick-card-row:nth-child(4n+1),
.quick-card-row:nth-child(4n+2) { background: rgba(67,56,202,0.018); }
.quick-card-row:hover { background: color-mix(in srgb, var(--accent, #4338ca) 5%, var(--surface)) !important; }
/* Matches .sec-cell-label full-bleed band */
.quick-card-row-label {
  font-family: 'Geist Mono', monospace;
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.11em;
  color: var(--accent, #4338ca);
  line-height: 1.2;
  padding: 0.45rem 1.5rem 0.4rem;
  margin: 0 -1.5rem;
  background: color-mix(in srgb, var(--accent, #4338ca) 7%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #4338ca) 16%, transparent);
}
/* Matches .sec-cell-value */
.quick-card-row-value {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem; font-weight: 400;
  color: var(--ink);
  line-height: 1.6;
  overflow-wrap: break-word;
  padding-top: 0.55rem;
}
.quick-card-row-value b { font-weight: 600; }

/* ══════════════════════════════════════════════════
   ENHANCED RAPID SUMMARY — "Start Here" treatment
══════════════════════════════════════════════════ */
.section.summary {
  box-shadow: 0 1px 5px rgba(55,48,163,0.08), 0 4px 18px rgba(55,48,163,0.07), inset 0 1px 0 rgba(255,255,255,0.9);
  position: relative;
}
.section.summary::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.12);
  pointer-events: none;
  z-index: 1;
}
.section.summary .section-head {
  --sec-bg: rgba(55,48,163,0.09);
  --sec-bg-h: rgba(55,48,163,0.12);
}
.section.summary .section-title {
  font-size: 0.9rem;
}
.section.summary .section-head .summary-start-badge {
  font-family: 'Geist Mono', monospace;
  font-size: 0.6rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--summary-acc);
  background: color-mix(in srgb, var(--summary-acc) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--summary-acc) 22%, transparent);
  border-radius: 100px;
  padding: 0.12rem 0.55rem;
  flex-shrink: 0;
}

/* Warning rows — critical/absolute contraindications */
.sec-cell.warn-row { background: rgba(225,29,72,0.04) !important; border-left: 3px solid #e11d48; }
.sec-cell.warn-row .sec-cell-label { color: #9f1239 !important; border-bottom-color: rgba(159, 18, 57, 0.25) !important; }
.pearl-icon { display: inline-block; width: 16px; height: 16px; color: var(--pearl-acc); vertical-align: middle; margin-right: 0.5rem; margin-top: -2px; opacity: 0.9; }

/* ══════════════════════════════════════════════════
   MODERN GLOSSY BADGES & ICONS
══════════════════════════════════════════════════ */
.dose-amt, .dose-max, .time-badge, .route-badge, .lab-badge, .mech-badge, .pop-badge { 
  display: inline-flex; align-items: center; justify-content: center; 
  font-family: 'Geist Mono', monospace; font-size: 0.75rem; font-weight: 600; 
  padding: 0.14rem 0.48rem; border-radius: 5px; margin: 0.1rem 0.25rem; 
  vertical-align: middle; line-height: 1.2; white-space: nowrap; 
  letter-spacing: 0.02em; 
}
.dose-amt { background-color: rgba(37,99,235,0.08); color: #1d4ed8; border: 1px solid rgba(37,99,235,0.2); }
/* Max Dose is now Pink to prevent "Red Over-saturation" */
.dose-max { background-color: rgba(225,29,72,0.13); color: #be123c; border: 1px solid rgba(225,29,72,0.28); }
.time-badge { background-color: rgba(22,163,74,0.08); color: #15803d; border: 1px solid rgba(22,163,74,0.25); }
.route-badge { background-color: rgba(147,51,234,0.08); color: #9333ea; border: 1px solid rgba(147,51,234,0.25); }
.lab-badge { background-color: rgba(8,145,178,0.08); color: #0891b2; border: 1px solid rgba(8,145,178,0.25); }
.mech-badge { background-color: rgba(217,119,6,0.08); color: #d97706; border: 1px solid rgba(217,119,6,0.25); } 
.pop-badge { background-color: rgba(217,38,169,0.08); color: #d926a9; border: 1px solid rgba(217,38,169,0.25); } /* Distinct Hot Pink for High-Risk Populations */

/* .dose-freq — frequency words (OD, BD, TDS, QID, PRN…) are intentionally
   rendered as bold prose rather than a pill badge. These tokens appear inline
   multiple times per row and turning them into pills would create severe visual
   clutter. Bold weight alone gives sufficient salience. */
.dose-freq { font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 600; color: var(--ink); margin-left: 0.12rem; margin-right: 0.28rem; vertical-align: middle; }

/* Pill Shapes */
.risk-pill, .ind-tag { 
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; 
  padding: 0.22rem 0.6rem; border-radius: 100px; border: 1px solid; 
  font-family: 'Geist Mono', monospace; font-size: 0.73rem; font-weight: 700; 
  letter-spacing: 0.07em; white-space: nowrap; line-height: 1.2; margin-right: 0.5rem; 
  vertical-align: middle; margin-bottom: 0.15rem; 
}

/* Ensure tags perfectly match table sizing */
.risk-detail, .ind-detail { display: inline; font-family: 'Inter', sans-serif; font-size: inherit; font-weight: 400; color: var(--ink); line-height: inherit; }

/* ind-pbs / ind-tga / ind-off use a smaller font-size (0.65rem) and tighter
   padding (0.18rem 0.5rem) than the base .ind-tag rule intentionally — these
   are compact regulatory-status pills that sit inline before the indication
   detail text, and the reduced sizing keeps them visually subordinate to the
   clinical content. */
.ind-pbs { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; cursor: help; font-size: 0.65rem; padding: 0.18rem 0.5rem; }
.ind-tga { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; cursor: help; font-size: 0.65rem; padding: 0.18rem 0.5rem; }
.ind-off { background: #fefce8; color: #a16207; border: 1px solid #fde047; cursor: help; font-size: 0.65rem; padding: 0.18rem 0.5rem; }
/* ind-unknown — neutral grey fallback for unrecognised tag values; avoids
   falsely implying TGA approval status (which ind-tga green would suggest). */
.ind-unknown { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; cursor: default; font-size: 0.65rem; padding: 0.18rem 0.5rem; }

/* ══════════════════════════════════════════════════
   RESPONSIVE & PRINT MEDIA (CARD LAYOUT ON MOBILE)
══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hero { padding: 0.85rem 1.1rem 0.8rem; }
  .sticky-header.scrolled .hero { padding: 0.55rem 1.1rem; }
  /* Mobile hero: keep the original row layout — drug name on the left,
     a slim cluster of badges + icon buttons pinned to the top-right
     edge, just like desktop.  No full-width grid takeover, no oversized
     tap targets — the badges are non-interactive labels (see below)
     and the icon buttons are intentionally compact. */
  .hero-inner { flex-direction: row; align-items: flex-start; gap: 0.6rem; }
  .hero-left { min-width: 0; flex: 1 1 auto; }
  .hero-right {
    display: flex; flex-direction: row; align-items: center;
    gap: 0.35rem; flex-shrink: 0; flex-wrap: nowrap;
    margin-top: 0.1rem; width: auto;
  }
  .hero-right > .hero-compare-btn,
  .hero-right > .fav-btn {
    width: 28px; min-width: 28px; height: 28px; min-height: 28px;
    padding: 0; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .hero-eyebrow { font-size: 0.58rem; letter-spacing: 0.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; margin-bottom: 0.15rem; }
  .hero-name { font-size: clamp(1.45rem, 6vw, 1.75rem); margin-bottom: 0.2rem; }
  .hero-class { font-size: 0.8rem; }
  /* Slim, decorative pills (no min-height, no large padding).  Pill
     click handlers are disabled globally — see the .hero-badge /
     .hero-schedule rule near the desktop styles. */
  .hero-badge, .hero-schedule { font-size: 0.62rem; padding: 0.18rem 0.45rem; border-radius: 6px; min-height: 0; }
  /* Sticky scrolled state stays compact (no need for full 44px when only the
     small condensed badges are shown alongside drug name). */
  .sticky-header.scrolled .hero-badge,
  .sticky-header.scrolled .hero-schedule { min-height: 0; padding: 0.12rem 0.4rem; }
  .sticky-header.scrolled .hero-name { font-size: 1.05rem; margin-bottom: 0.05rem; }
  .sticky-header.scrolled .hero-eyebrow { display: none; }
  .sticky-header.scrolled .hero-class { display: block; font-size: 0.72rem; line-height: 1.3; margin-top: 0; color: var(--ink3); }
  .sticky-header.scrolled .hero-right { display: flex; flex-direction: row; gap: 0.35rem; align-items: center; margin-top: 0; }
  .sticky-header.scrolled .hero-schedule { font-size: 0.62rem; padding: 0.12rem 0.4rem; border-radius: 5px; }
  .sticky-header.scrolled .hero-badge { font-size: 0.62rem; padding: 0.12rem 0.4rem; border-radius: 5px; }

  .hero-name,
  .hero-eyebrow,
  .hero-class {
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .stats-inner { flex-wrap: wrap; }
  .stat-item {
    flex: 1 1 45%;
    border-right: none;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 0.5rem 0.9rem;
  }
  .stat-item:nth-last-child(-n+2) { border-bottom: none; }
  .stat-label { font-size: 0.62rem; }
  .stat-value { font-size: 0.95rem; }

  .sections { padding: 1.1rem 0.9rem; gap: 1.1rem; }

  /* Mobile: single-column grid */
  .section, .section-body, .sec-grid, .sec-cell { min-width: 0; }
  .sec-grid { grid-template-columns: 1fr; }
  .sec-cell:nth-child(odd) { border-right: none; }
  .sec-cell:last-child:nth-child(odd) { grid-column: auto; }
  .sec-cell:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule-soft); }
  .sec-cell:last-child { border-bottom: none !important; }
  .sec-cell { padding: 0 1.1rem 0.8rem; box-shadow: none; }
  .sec-cell-label { font-size: 0.67rem; letter-spacing: 0.09em; padding: 0.4rem 1.1rem 0.35rem; margin: 0 -1.1rem; }
  .sec-cell-value { font-size: 0.9rem; overflow-wrap: anywhere; padding-top: 0.5rem; }

  /* Mobile warning rows */
  .sec-cell.warn-row { background: rgba(225,29,72,0.04) !important; border-left: 3px solid #e11d48; }

  /* QPC inside .sections — no extra padding override needed */
  .quick-card-grid { grid-template-columns: 1fr; }
  .quick-card-row { border-right: none !important; padding: 0 1.1rem 0.8rem; box-shadow: none; }
  .quick-card-row:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule-soft); }
  .quick-card-row:last-child { border-bottom: none !important; }
  .quick-card-row:nth-child(odd):last-child { grid-column: auto; }
  .quick-card-head { padding: 0.8rem 1.1rem; gap: 0.5rem; }
  .quick-card-head-title { font-size: 0.85rem; }
  .quick-card-row-label { font-size: 0.67rem; letter-spacing: 0.09em; padding: 0.4rem 1.1rem 0.35rem; margin: 0 -1.1rem; }
  .quick-card-row-value { font-size: 0.9rem; overflow-wrap: anywhere; padding-top: 0.5rem; }

  #appBar .appbar-wordmark { font-size: 0.9rem; }
  #currentDrugChip { font-size: 0.78rem; max-width: 45%; }
  #paletteBtn .palette-btn-text { display: none; }
  .palette-btn-kbd { display: none; }
  #paletteBtn { padding: 0.55rem 0.75rem; min-height: 44px; min-width: 44px; display: flex; align-items: center; justify-content: center; }
  #paletteChips { flex-wrap: nowrap; }

  /* Section nav strip: scroll-fade edge + comfortable touch targets */
  .section-nav-wrap::after {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 2.5rem;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
    pointer-events: none;
    z-index: 1;
  }
  .sec-nav-chip {
    min-height: 36px;
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
  }
  .sec-collapse-all-btn {
    min-height: 36px;
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
  }

  /* Siblings panel */
  .siblings-panel { padding: 1rem 1.1rem 2rem; }
  .sibling-card { min-width: 140px; max-width: 170px; }
  .sibling-card-name { font-size: 0.82rem; }
  .sibling-card-sub { font-size: 0.68rem; }

  /* ── Compare bar: stack into two rows ───────────────────────────── */
  .compare-bar { padding-bottom: env(safe-area-inset-bottom); }
  .compare-bar-inner {
    flex-direction: column; align-items: stretch;
    padding: 0.5rem 1rem 0.45rem; gap: 0.35rem;
  }
  /* chips row scrolls horizontally instead of wrapping */
  .compare-bar-drugs {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .compare-bar-drugs::-webkit-scrollbar { display: none; }
  /* prevent chips from shrinking — they must force the row to scroll instead */
  .compare-bar-chip { flex-shrink: 0; }
  .compare-bar-hint { display: none; }
  /* actions row: Compare fills width, Clear is fixed-size */
  .compare-bar-actions { display: grid; grid-template-columns: 1fr auto; gap: 0.4rem; }
  .compare-bar-btn-primary { min-height: 44px; }
  .compare-bar-btn-secondary { min-height: 44px; min-width: 68px; }
  /* chip remove ×: visually 28×28 but hit area expanded to 44×44 via ::after */
  .compare-bar-chip-remove {
    position: relative; width: 28px; height: 28px;
    font-size: 1.05rem; margin-right: -0.15rem;
  }
  .compare-bar-chip-remove::after {
    content: ''; position: absolute; inset: -8px;
  }

  /* ── Compare overlay: safe-area insets on both ends ─────────────── */
  #compareView {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .cv-header {
    height: auto; min-height: 48px;
    padding: 0.6rem 1rem; gap: 0.5rem; flex-wrap: wrap;
  }
  .cv-title { font-size: 0.82rem; }
  /* Close button: full 44px touch target */
  .cv-close { padding: 0.6rem 1rem; min-height: 44px; min-width: 44px; }
}

@media (max-width: 600px) {
  .hero-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.48rem;
  }
  .hero-left {
    width: 100%;
    flex: 0 1 auto;
  }
  .hero-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-self: flex-start;
    margin-top: 0;
  }
  .hero-eyebrow {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .hero-name,
  .hero-class {
    max-width: 100%;
  }
  .sticky-header.scrolled .hero-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.36rem;
  }
  .sticky-header.scrolled .hero-right {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ══════════════════════════════════════════════════
   NARROW MOBILE (≤640px) — icon-only section type badges, compact chevron
══════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Hide badge text label on smallest screens — the SVG icon + pill border still
     communicates section type at a glance; text restores automatically at ≥641px */
  .sec-type-label { font-size: 0; letter-spacing: 0; padding: 0.1rem 0.25rem; gap: 0; }
  /* Chevron slightly smaller to match the more compact heading height */
  .section-chevron { width: 14px; height: 14px; }
  /* Slightly reduced letter-spacing on section titles for narrow screens */
  .section-title { letter-spacing: 0.01em; }
  /* Softer radius so collapsed sections read as sleek pill-like rows */
  .section { border-radius: 8px; }
}

/* ══════════════════════════════════════════════════
   SMALL PHONES (≤480px) — short chip labels, icon-only collapse-all
══════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Switch to abbreviated labels — saves ~40% chip width on narrow screens */
  .chip-label-full  { display: none; }
  .chip-label-short { display: inline; }
  /* Collapse-all button: show only the chevron icon, hide "Collapse all" text */
  .sec-collapse-all-btn > span { display: none; }
  /* Compact 36px touch targets on small phones */
  .sec-nav-chip      { min-height: 36px; padding-top: 0.18rem; padding-bottom: 0.18rem; font-size: 0.69rem; }
  .sec-collapse-all-btn { min-height: 36px; padding-top: 0.18rem; padding-bottom: 0.18rem; }
  /* Tighter strip padding and gaps */
  .sec-nav-strip { padding: 0.18rem 0.75rem; gap: 0.12rem; }
}

/* ══════════════════════════════════════════════════
   EXTRA-SMALL PHONES (<375px) — iPhone SE, small Android
   Ensures the section nav strip never wraps to a second line even
   on the narrowest viewports, keeping it a single scrollable row.
══════════════════════════════════════════════════ */
@media (max-width: 374px) {
  /* Defensive guard: keep nav strip as a single scrollable row.
     flex-wrap: nowrap is already set globally on .sec-nav-strip but this
     explicit override prevents any future regression at extra-small widths. */
  .sec-nav-strip {
    flex-wrap: nowrap;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    gap: 0.1rem;
  }
  /* Narrower chips so more fit within the visible viewport */
  .sec-nav-chip {
    font-size: 0.66rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }
  .sec-collapse-all-btn {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }
}

/* ══════════════════════════════════════════════════
   TABLET BREAKPOINT — iPad portrait / large phones landscape
   769px–900px: single-column grid with tablet-appropriate spacing
══════════════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 900px) {
  /* Hero header: stack right-side badges vertically, add breathing room */
  .hero { padding: 1rem 1.25rem 0.9rem; }
  .hero-inner { align-items: flex-start; gap: 1rem; }
  .hero-right { flex-direction: row; align-items: center; gap: 0.4rem; flex-shrink: 0; margin-top: 0.1rem; flex-wrap: wrap; justify-content: flex-end; }
  /* Smooth badge/pill: 0.65rem (mob @768px) → 0.75rem (desk @901px).
     Interpolate: 0.063rem + 0.0763vw gives 0.65rem @769px and 0.75rem @900px. */
  .hero-badge, .hero-schedule { font-size: clamp(0.65rem, calc(0.063rem + 0.0763vw), 0.75rem); padding: 0.25rem 0.52rem; }
  .hero-name { font-size: clamp(1.75rem, calc(-1.19rem + 6.1vw), 2.25rem); }
  /* Smooth eyebrow: no tablet override previously → 0.58rem→0.75rem jump at 769px.
     Interpolate from mobile end (0.58rem @769px) → desktop base (0.75rem @900px). */
  .hero-eyebrow { font-size: clamp(0.58rem, calc(-0.42rem + 2.08vw), 0.75rem); }
  /* Smooth class: 0.80rem (mob) → 0.92rem → 1rem (desk) had +0.12 and +0.08rem jumps.
     Single clamp covers both boundaries: 0.80rem @769px → 1rem @900px. */
  .hero-class { font-size: clamp(0.8rem, calc(-0.37rem + 2.44vw), 1rem); }

  /* Stats ribbon: shrink padding and allow items to wrap at tablet width */
  .stats-inner { flex-wrap: wrap; }
  .stat-item {
    flex: 1 1 40%;
    padding: 0.55rem 1rem;
    border-right: 1px solid var(--rule-soft);
    border-bottom: 1px solid rgba(0,0,0,0.06);
  }
  .stat-item:nth-child(2n) { border-right: none; }
  .stat-item:nth-last-child(-n+2) { border-bottom: none; }
  .stat-label { font-size: 0.63rem; }
  /* Smooth stat-value: 0.95rem (mob) → 1rem → 1.05rem (desk) had ±0.05rem jumps.
     Interpolate from 0.95rem @769px → 1.05rem @900px. */
  .stat-value { font-size: clamp(0.95rem, calc(0.36rem + 1.22vw), 1.05rem); }

  /* Section grid: switch to single-column with tablet padding */
  .section, .section-body, .sec-grid, .sec-cell { min-width: 0; }
  .sec-grid { grid-template-columns: 1fr; }
  .sec-cell:nth-child(odd) { border-right: none; }
  .sec-cell:last-child:nth-child(odd) { grid-column: auto; }
  .sec-cell:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule-soft); }
  .sec-cell:last-child { border-bottom: none !important; }
  .sec-cell { padding: 0 1.25rem 1rem; }
  .sec-cell-label { font-size: 0.68rem; letter-spacing: 0.095em; padding: 0.42rem 1.25rem 0.38rem; margin: 0 -1.25rem; }
  .sec-cell-value { font-size: 0.9rem; overflow-wrap: break-word; padding-top: 0.55rem; }

  /* Section head and typography tuned for tablet */
  .sections { padding: 1.25rem 1.1rem; gap: 1.2rem; }
  .sec-type-label { font-size: 0.58rem; }
  /* section-head padding and section-title size are handled by clamp() on the base rules */

  /* Tablet warning rows */
  .sec-cell.warn-row { background: rgba(225,29,72,0.04) !important; border-left: 3px solid #e11d48; }

  /* QPC tablet: single-column with tablet-appropriate spacing */
  .quick-card-grid { grid-template-columns: 1fr; }
  .quick-card-row { border-right: none !important; padding: 0 1.25rem 1rem; box-shadow: none; }
  .quick-card-row:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule-soft); }
  .quick-card-row:last-child { border-bottom: none !important; }
  .quick-card-row:nth-child(odd):last-child { grid-column: auto; }
  .quick-card-head { padding: 0.82rem 1.25rem; gap: 0.5rem; }
  .quick-card-head-title { font-size: 0.87rem; }
  .quick-card-row-label { font-size: 0.68rem; letter-spacing: 0.095em; padding: 0.42rem 1.25rem 0.38rem; margin: 0 -1.25rem; }
  .quick-card-row-value { font-size: 0.9rem; overflow-wrap: break-word; padding-top: 0.55rem; }
}


/* ══════════════════════════════════════════════════
   WIDE SCREEN — ≥1400px
   At large monitor widths the .sections container
   (capped at 1100px) leaves the QPC with the same
   column widths as a 1000px viewport. Expanding the
   container cap to 1340px gives each 2-col cell ~50%
   more horizontal space — reducing line-wrap and
   improving at-a-glance readability without narrowing
   any column. Section cards benefit equally.
══════════════════════════════════════════════════ */
@media (min-width: 1400px) {
  /* Widen all 1100px-capped containers so the full page aligns consistently.
     Each 2-col QPC cell grows from ~540px to ~650px, reducing line-wrap on
     long prescribing text without narrowing any column. */
  .hero-inner,
  .stats-inner,
  .sections,
  .sec-nav-strip,
  .patient-alert-region,
  .clinical-footer { max-width: 1340px; }

  /* More lateral breathing room in QPC cells to match the wider container */
  .quick-card-row { padding: 0 1.75rem 1.25rem; }
  .quick-card-row-label { font-size: 0.72rem; letter-spacing: 0.11em; padding: 0.5rem 1.75rem 0.45rem; margin: 0 -1.75rem; }
  .quick-card-row-value { font-size: 0.95rem; padding-top: 0.65rem; }
  .quick-card-head { padding: 1.1rem 1.6rem; }
  .quick-card-head-title { font-size: 0.95rem; }

  /* Section card type bump — matches QPC treatment at wide widths */
  .sec-cell-value { font-size: 0.95rem; }
  .sec-cell-label { font-size: 0.72rem; letter-spacing: 0.10em; }
  .section-title { font-size: 0.95rem; }
  .sec-type-label { font-size: 0.63rem; }

  /* Stats ribbon — marginal size lift for large monitors */
  .stat-value { font-size: 1.1rem; }
  .stat-label { font-size: 0.65rem; }
}


/* ══════════════════════════════════════════════════
   ALSO IN THIS CLASS — SIBLINGS PANEL
══════════════════════════════════════════════════ */
.siblings-panel {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem clamp(1.5rem, 4vw, 3rem) 2.5rem;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.15s;
}

.siblings-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.siblings-panel-icon {
  color: var(--accent, #4f46e5);
  opacity: 0.7;
  flex-shrink: 0;
}

.siblings-panel-title {
  font-family: 'Geist Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.siblings-panel-class {
  font-family: 'Geist Mono', monospace;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent, #4f46e5);
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 100px;
  padding: 0.12rem 0.55rem;
  margin-left: auto;
  white-space: nowrap;
}
.siblings-panel-class-btn {
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  display: inline-flex; align-items: center; gap: 0.3em;
}
.siblings-panel-class-btn::after {
  content: '';
  display: inline-block;
  width: 0.5em; height: 0.5em;
  border: 1.5px solid currentColor;
  border-left: none; border-bottom: none;
  transform: rotate(45deg);
  opacity: 0.6;
  margin-left: 0.05em;
}
.siblings-panel-class-btn:hover {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}
.siblings-panel-class-btn:focus-visible {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 2px;
}

.siblings-cards {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
  scroll-padding-left: 0;
}
.siblings-cards::-webkit-scrollbar { height: 4px; }
.siblings-cards::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }

.sibling-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-width: 160px;
  max-width: 200px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.8);
}
.sibling-card:hover {
  background: var(--surface2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1), 0 4px 16px rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.sibling-card:active { transform: translateY(0); }
.sibling-card:focus-visible {
  outline: 2px solid var(--sib-accent, var(--summary-acc));
  outline-offset: 2px;
}

.sibling-card-bar {
  width: 4px;
  flex-shrink: 0;
  border-radius: 0;
}

.sibling-card-body {
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}

.sibling-card-name {
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sibling-card-tag {
  font-family: 'Geist Mono', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}

.sibling-card-sub {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Drug loading state */
.drug-loading { display:flex; flex-direction:column; align-items:center; justify-content:center; height:60vh; gap:1rem; }
.drug-loading-spinner { width:38px; height:38px; border:3px solid rgba(0,0,0,0.08); border-top-color:var(--accent,#6366f1); border-radius:50%; animation:spin 0.7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.drug-loading-name { font-family:'Inter',sans-serif; font-size:0.9rem; color:var(--muted); }
.drug-index-loading { display:flex; align-items:center; justify-content:center; height:100%; color:var(--muted); font-family:'Inter',sans-serif; font-size:0.9rem; }

/* ══════════════════════════════════════════════════
   CLEAR SEARCH BUTTON
══════════════════════════════════════════════════ */
.search-clear {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--rule);
  color: var(--muted); cursor: pointer; flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s;
}
.search-clear:hover { background: var(--rule); color: var(--ink); }

/* ══════════════════════════════════════════════════
   SCROLL-TO-TOP BUTTON
══════════════════════════════════════════════════ */
.scroll-top-btn {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--ink); color: #fff;
  border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 1px 4px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease, background-color 0.15s;
}
.scroll-top-btn.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-top-btn:hover { background: #1e293b; }
.scroll-top-btn.compare-bar-visible { bottom: 100px; }
/* ══════════════════════════════════════════════════
   REDUCED MOTION — WCAG 2.3 compliance
══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stat-item.flagged {
    animation: none !important;
    background-color: rgba(225, 29, 72, 0.06) !important;
  }
  .empty-icon { animation: none !important; opacity: 0.6; }
  .scroll-top-btn { transition: none; }
}

/* ═══════════════════════════════════════════════════════════════
   PATIENT CONTEXT PANEL
═══════════════════════════════════════════════════════════════ */
#patientBtn {
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 0.38rem 0.7rem;
  font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 500;
  color: #94a3b8; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  max-width: 200px; overflow: hidden;
}
#patientBtn:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.24); color: #e2e8f0; }
#patientBtn.has-context { background: rgba(16,185,129,0.14); border-color: rgba(16,185,129,0.38); color: #6ee7b7; }
#patientBtn.has-context:hover { background: rgba(16,185,129,0.22); }
#patientBtnText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

#patientPanel {
  position: fixed; inset: 0; z-index: 200;
  visibility: hidden; opacity: 0;
  transition: opacity 0.18s ease, visibility 0s 0.18s;
}
#patientPanel.open { visibility: visible; opacity: 1; transition: opacity 0.18s ease; }
#patientPanelBackdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#patientPanelContent {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(360px, 100dvw); max-width: 100%;
  background: var(--surface); box-shadow: -8px 0 40px rgba(0,0,0,0.22);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
#patientPanel.open #patientPanelContent { transform: translateX(0); }
.pp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem 0.85rem; border-bottom: 1px solid var(--rule); flex-shrink: 0;
}
.pp-title {
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.9rem; font-weight: 700;
  color: var(--ink); letter-spacing: -0.01em;
}
.pp-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--rule);
  color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.pp-close:hover { background: var(--rule); color: var(--ink); }
.pp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 0.9rem; overscroll-behavior: contain; }
.pp-intro { font-family: 'Inter', sans-serif; font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.pp-field { display: flex; flex-direction: column; gap: 0.3rem; }
.pp-field label { font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 600; color: var(--ink2); }
.pp-field input, .pp-field select {
  width: 100%; padding: 0.45rem 0.7rem; border: 1px solid var(--rule); border-radius: 7px;
  background: var(--surface2); color: var(--ink); font-family: 'Inter', sans-serif; font-size: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.pp-field input:focus, .pp-field select:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.pp-field input::placeholder { color: var(--muted); font-size: 0.82rem; }
.pp-egfr-hint { font-family: 'Geist Mono', monospace; font-size: 0.64rem; color: #059669; min-height: 0.9rem; font-weight: 600; }
.pp-actions { display: flex; gap: 0.5rem; padding-top: 0.1rem; }
.pp-btn-primary {
  flex: 1; padding: 0.5rem 0.9rem; background: #4f46e5; color: #fff; border: none; border-radius: 7px;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.pp-btn-primary:hover { background: #4338ca; }
.pp-btn-secondary {
  padding: 0.5rem 0.9rem; background: var(--surface2); color: var(--ink3);
  border: 1px solid var(--rule); border-radius: 7px;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; cursor: pointer; transition: background 0.15s;
}
.pp-btn-secondary:hover { background: var(--rule); color: var(--ink); }
.pp-disclaimer {
  padding: 0.7rem 1.2rem 1rem; border-top: 1px solid var(--rule); flex-shrink: 0;
  font-family: 'Inter', sans-serif; font-size: 0.7rem; color: var(--muted); line-height: 1.55;
}
.sec-cell.pc-row-egfr   { background: rgba(245,158,11,0.05) !important; border-left: 3px solid #f59e0b !important; }
.sec-cell.pc-row-preg   { background: rgba(217,38,169,0.05) !important; border-left: 3px solid #d926a9 !important; }
.sec-cell.pc-row-hep    { background: rgba(180,83,9,0.05)   !important; border-left: 3px solid #b45309 !important; }
.pc-tag {
  display: inline-flex; align-items: center; font-family: 'Geist Mono', monospace;
  font-size: 0.59rem; font-weight: 700; padding: 0.08rem 0.35rem; border-radius: 4px;
  margin-right: 0.35rem; margin-bottom: 0.1rem;
  background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.3);
  color: #b45309; vertical-align: middle; letter-spacing: 0.04em; white-space: nowrap;
}
.pc-tag.pc-tag-preg { background: rgba(217,38,169,0.1); border-color: rgba(217,38,169,0.3); color: #be185d; }
.pc-tag.pc-tag-hep { background: rgba(180,83,9,0.1); border-color: rgba(180,83,9,0.3); color: #92400e; }
.pc-tag.pc-tag-elderly { background: rgba(234,88,12,0.1); border-color: rgba(234,88,12,0.3); color: #c2410c; }
.pc-tag.pc-tag-paeds { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.3); color: #4338ca; }
.pc-tag.pc-tag-allergy { background: rgba(225,29,72,0.1); border-color: rgba(225,29,72,0.3); color: #be123c; }
.sec-cell.pc-row-age    { background: rgba(234,88,12,0.05)  !important; border-left: 3px solid #ea580c !important; }
.sec-cell.pc-row-allergy { background: rgba(225,29,72,0.05) !important; border-left: 3px solid #e11d48 !important; }
.pp-age-hint { font-family: 'Geist Mono', monospace; font-size: 0.64rem; color: #ea580c; min-height: 0.9rem; font-weight: 600; }
.pp-allergy-group { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.1rem 0; }
.pp-checkbox-row {
  display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; color: var(--ink2);
  padding: 0.22rem 0.4rem; border-radius: 5px; transition: background 0.12s;
}
.pp-checkbox-row:hover { background: var(--surface2); }
.pp-checkbox-row input[type="checkbox"] { width: 14px; height: 14px; accent-color: #e11d48; cursor: pointer; flex-shrink: 0; }
.pc-calc {
  display: inline; font-family: 'Geist Mono', monospace; font-size: 0.68rem;
  color: #059669; margin-left: 0.3rem; font-weight: 600; white-space: nowrap;
}
.sec-cell.pc-row-qtc { background: rgba(251,146,60,0.06) !important; border-left: 3px solid #f97316 !important; }
.pc-tag.pc-tag-qtc { background: rgba(251,146,60,0.12); border-color: rgba(251,146,60,0.35); color: #c2410c; }

/* ── Patient panel: section headers & dividers ── */
.pp-section-header {
  font-family: 'Geist Mono', monospace; font-size: 0.62rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em;
  padding: 0.05rem 0; margin-bottom: -0.3rem;
}
.pp-divider { height: 1px; background: var(--rule); margin: 0.1rem 0; }

/* ── Sex pill-toggle ── */
.pp-sex-toggle { display: flex; gap: 0.28rem; }
.pp-sex-btn {
  flex: 1; padding: 0.38rem 0.4rem;
  border: 1px solid var(--rule); border-radius: 6px;
  background: var(--surface2); color: var(--ink3);
  font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 500;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap; text-align: center;
}
.pp-sex-btn:hover { background: var(--rule); color: var(--ink); }
.pp-sex-btn.active { background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.4); color: #4f46e5; font-weight: 600; }

/* ── SCr / QTc hints ── */
.pp-scr-hint { font-family: 'Geist Mono', monospace; font-size: 0.64rem; color: #059669; min-height: 0.9rem; font-weight: 600; line-height: 1.4; }
.pp-qtc-hint { font-family: 'Geist Mono', monospace; font-size: 0.64rem; min-height: 0.9rem; font-weight: 600; }
.pp-qtc-hint.qtc-normal { color: #059669; }
.pp-qtc-hint.qtc-borderline { color: #d97706; }
.pp-qtc-hint.qtc-prolonged { color: #dc2626; }

/* ── Allergy 2-column grid ── */
.pp-allergy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.12rem 0.3rem; padding: 0.05rem 0; }

/* ── Match count pill ── */
.pp-match-count {
  display: inline-block; font-family: 'Geist Mono', monospace;
  font-size: 0.63rem; color: var(--muted); background: var(--surface2);
  border: 1px solid var(--rule); border-radius: 100px;
  padding: 0.16rem 0.65rem; margin-bottom: 0.05rem;
}
.pp-match-count.has-matches { color: #059669; border-color: rgba(5,150,105,0.35); background: rgba(5,150,105,0.06); }
.pp-active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  min-height: 1.2rem;
}
.pp-active-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(99,102,241,0.28);
  background: rgba(99,102,241,0.08);
  color: #4338ca;
  border-radius: 999px;
  padding: 0.14rem 0.48rem;
  font-family: 'Geist Mono', monospace;
  font-size: 0.62rem;
  font-weight: 650;
  white-space: nowrap;
}
.pp-active-empty {
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
}
.pp-validation {
  border: 1px solid rgba(220,38,38,0.28);
  background: rgba(220,38,38,0.06);
  color: #b91c1c;
  border-radius: 7px;
  padding: 0.45rem 0.6rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  line-height: 1.35;
}
.pp-validation[hidden] { display: none; }
.pp-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════════
   PATIENT ALERT BANNER
═══════════════════════════════════════════════════════════════ */
.patient-alert-region {
  width: calc(100% - clamp(1.5rem, 4vw, 3rem));
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.78rem 0;
  box-sizing: border-box;
}
.patient-alert-region[hidden] { display: none; }
.patient-alert-banner {
  width: 100%;
  margin: 0;
  border-radius: 8px;
  padding: 0.66rem 0.86rem 0.66rem 0.72rem;
  font-family: 'Inter', sans-serif;
  border: 1px solid;
  border-left-width: 4px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem 0.85rem;
  box-shadow: none;
}
.patient-alert-banner[hidden] { display: none; }
.patient-alert-banner.pa-danger {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.078), rgba(255, 255, 255, 0.62));
  border-color: rgba(220, 38, 38, 0.32);
}
.patient-alert-banner.pa-caution {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.078), rgba(255, 255, 255, 0.62));
  border-color: rgba(217, 119, 6, 0.32);
}
.patient-alert-banner.pa-info {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.078), rgba(255, 255, 255, 0.62));
  border-color: rgba(14, 165, 233, 0.28);
}
.pa-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.pa-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-width: 0;
}
.pa-marker {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist Mono', monospace;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}
.pa-danger .pa-marker {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.12);
}
.pa-caution .pa-marker {
  color: #92400e;
  background: rgba(217, 119, 6, 0.12);
}
.pa-info .pa-marker {
  color: #0369a1;
  background: rgba(14, 165, 233, 0.12);
}
.pa-headline {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}
.pa-danger .pa-headline { color: #b91c1c; }
.pa-caution .pa-headline { color: #b45309; }
.pa-info .pa-headline { color: #0369a1; }
.pa-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem 0.44rem;
  min-width: 0;
  padding-left: 1.42rem;
}
.pa-summary-item {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.34rem;
  font-size: 0.78rem;
  line-height: 1.3;
}
.pa-item-danger { color: #991b1b; }
.pa-item-caution { color: #92400e; }
.pa-item-info { color: #075985; }
.pa-factor {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  font-family: 'Geist Mono', monospace;
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0;
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.72);
}
.pa-summary-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.pa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  align-items: center;
  align-self: center;
  min-width: 0;
}
.pa-section-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 30px;
  padding: 0.24rem 0.42rem;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.pa-danger .pa-section-link {
  color: #b91c1c;
  background: transparent;
  border: 1px solid transparent;
}
.pa-danger .pa-section-link:hover { background: rgba(220, 38, 38, 0.08); border-color: rgba(220, 38, 38, 0.18); }
.pa-caution .pa-section-link {
  color: #92400e;
  background: transparent;
  border: 1px solid transparent;
}
.pa-caution .pa-section-link:hover { background: rgba(217, 119, 6, 0.08); border-color: rgba(217, 119, 6, 0.18); }
.pa-info .pa-section-link {
  color: #0369a1;
  background: transparent;
  border: 1px solid transparent;
}
.pa-info .pa-section-link:hover { background: rgba(14, 165, 233, 0.08); border-color: rgba(14, 165, 233, 0.18); }
.pa-section-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.75);
}

@media (max-width: 700px) {
  .patient-alert-region {
    width: calc(100% - 1.5rem);
  }
  .patient-alert-banner {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.55rem;
  }
  .pa-actions {
    grid-column: 1;
    justify-content: flex-start;
    align-self: start;
    min-width: 0;
  }
  .pa-section-link {
    flex: 0 1 auto;
    max-width: 100%;
  }
}

@media (max-width: 620px) {
  .patient-alert-banner {
    padding: 0.72rem 0.78rem 0.74rem 0.68rem;
  }
  .pa-actions {
    width: auto;
  }
  .pa-section-link {
    width: auto;
    max-width: 100%;
    white-space: normal;
    justify-content: flex-start;
    text-align: left;
  }
}

@media (max-width: 390px) {
  .patient-alert-region {
    padding: 0.7rem 0;
  }
  .patient-alert-banner {
    padding: 0.7rem;
    border-radius: 8px;
  }
  .pa-summary {
    flex-direction: column;
    align-items: flex-start;
    padding-left: 0;
    gap: 0.28rem;
  }
  .pa-summary-item {
    align-items: flex-start;
  }
  .pa-headline {
    font-size: 0.84rem;
  }
}

@media (min-width: 1400px) {
  .patient-alert-region {
    max-width: 1340px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DRUG COMPARISON
═══════════════════════════════════════════════════════════════ */
.hero-compare-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--rule); color: var(--ink3);
  cursor: pointer; transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  background: none; flex-shrink: 0;
}
.hero-compare-btn:hover { background: var(--surface2); color: var(--ink); }
.hero-compare-btn.active { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.4); color: #4f46e5; }

/* ── Compare bar: floating frosted-glass pill island ── */
.compare-bar {
  position: fixed; bottom: 16px; left: 50%; right: auto; z-index: 150;
  width: auto; max-width: min(720px, calc(100vw - 24px));
  transform: translateX(-50%) translateY(calc(100% + 24px));
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.compare-bar.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.compare-bar-inner {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.55rem 0.45rem 0.85rem;
  background: rgba(13, 18, 32, 0.9);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.07) inset;
}
/* Slot indicators: empty circles for unchosen slots */
.compare-bar-slots { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.compare-bar-slot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.22);
  transition: background 0.2s, border-color 0.2s;
}
.compare-bar-slot.filled { border-width: 0; }
.compare-bar-drugs { display: flex; flex: 1; align-items: center; gap: 0.4rem; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.compare-bar-chip {
  display: flex; align-items: center; gap: 0.3rem;
  border-radius: 100px; padding: 0.28rem 0.32rem 0.28rem 0.65rem;
  font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 600; color: #fff;
  max-width: 175px; min-width: 0; flex-shrink: 0;
}
.compare-bar-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.compare-bar-chip-dot { display: none; } /* replaced by accent pill background */
.compare-bar-chip-remove {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.2); border: none; color: rgba(255,255,255,0.75);
  cursor: pointer; font-size: 0.85rem; transition: background 0.12s;
}
/* Expand touch target to ≥44×44px via ::after */
.compare-bar-chip-remove::after {
  content: ''; position: absolute; inset: -12px;
}
.compare-bar-chip-remove:hover { background: rgba(255,255,255,0.38); color: #fff; }
/* Hint text is kept in the DOM for screen-reader aria-live announcements only.
   Slot circles are the sole visual capacity cue — hide the text visually. */
.compare-bar-hint {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.compare-bar-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.compare-bar-btn-primary {
  padding: 0.42rem 1rem; background: #4f46e5; color: #fff; border: none; border-radius: 999px;
  font-family: 'Inter', sans-serif; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s; white-space: nowrap;
}
.compare-bar-btn-primary:hover { background: #4338ca; }
.compare-bar-btn-primary:disabled { background: rgba(79,70,229,0.32); cursor: not-allowed; border: 1px dashed rgba(99,102,241,0.4); }
.compare-bar-btn-secondary {
  padding: 0.4rem 0.75rem; background: rgba(255,255,255,0.07); color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.11); border-radius: 999px;
  font-family: 'Inter', sans-serif; font-size: 0.8rem; cursor: pointer; transition: background 0.15s;
}
.compare-bar-btn-secondary:hover { background: rgba(255,255,255,0.14); color: #e2e8f0; }

#compareView {
  position: fixed; inset: 0; z-index: 175; background: var(--bg);
  display: flex; flex-direction: column;
  visibility: hidden; opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.2s ease, visibility 0s 0.2s, transform 0.2s ease;
  overflow: hidden;
  max-width: 100dvw;
}
#compareView.open {
  visibility: visible; opacity: 1; transform: scale(1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.cv-header {
  display: flex; align-items: center; gap: 0.65rem; padding: 0 1.25rem; height: 48px; flex-shrink: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1a2540 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.07), 0 4px 20px rgba(0,0,0,0.3);
}
.cv-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.86rem; font-weight: 700; color: #fff; letter-spacing: -0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-count { font-family: 'Geist Mono', monospace; font-size: 0.62rem; font-weight: 700; color: #c7d2fe; background: rgba(99,102,241,0.28); border: 1px solid rgba(99,102,241,0.4); border-radius: 100px; padding: 0.1rem 0.55rem; }
.cv-close {
  margin-left: auto; display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; width: 44px; height: 44px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: #94a3b8; cursor: pointer; transition: background 0.15s;
  font-size: 1rem;
}
.cv-close:hover { background: rgba(255,255,255,0.14); color: #e2e8f0; }
.cv-body { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.15) transparent; overscroll-behavior: contain; }
.cv-table-wrap { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem 5rem; min-width: 0; }
/* ── Mobile drug tabs (hidden on desktop) ── */
.cv-mobile-tabs {
  display: none;
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--rule);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.cv-mobile-tabs::-webkit-scrollbar { display: none; }
.cv-mobile-tab {
  padding: 0.6rem 1rem; white-space: nowrap; flex-shrink: 0;
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.8rem; font-weight: 700;
  color: var(--muted); border: none; border-bottom: 2px solid transparent;
  background: none; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cv-mobile-tab.active { color: var(--ink); }
/* Drug headers */
.cv-drug-headers { display: grid; gap: 1px; background: var(--rule); border-radius: 10px; overflow: hidden; margin-bottom: 1.25rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.cv-sticky-headers { position: sticky; top: 0; z-index: 2; border-radius: 0 0 10px 10px; background: var(--bg); box-shadow: 0 4px 18px rgba(0,0,0,0.13), 0 1px 0 var(--rule); }
.cv-drug-header { padding: 1rem 1.15rem; position: relative; display: flex; flex-direction: column; gap: 0.3rem; }
.cv-drug-accent-bar { position: absolute; top: 0; left: 0; right: 0; height: 8px; }
.cv-drug-tag { font-family: 'Geist Mono', monospace; font-size: 0.62rem; font-weight: 700; padding: 0.12rem 0.45rem; border-radius: 5px; border: 1.5px solid; width: fit-content; margin-top: 0.25rem; }
.cv-drug-name { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.15rem; font-weight: 800; color: var(--ink); letter-spacing: -0.025em; line-height: 1.15; margin-top: 0.15rem; }
.cv-drug-sub { font-family: 'Geist Mono', monospace; font-size: 0.68rem; color: var(--ink3); letter-spacing: 0.01em; }
.cv-drug-remove-btn {
  position: absolute; top: 0.5rem; right: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.1); color: var(--ink3);
  cursor: pointer; font-size: 0.9rem; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
/* Extend touch target without visually enlarging the button */
.cv-drug-remove-btn::before { content: ''; position: absolute; inset: -8px; }
.cv-drug-remove-btn:hover { background: #fecaca; border-color: #f87171; color: #be123c; }
.cv-section-heading {
  font-family: 'Geist Mono', monospace; font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  padding: 0.5rem 0 0.35rem; border-bottom: 1px solid var(--rule); margin-bottom: 0.6rem;
}
/* Stats grid — two-tone rows */
.cv-stats-grid { display: flex; flex-direction: column; gap: 1px; background: var(--rule); border-radius: 8px; overflow: hidden; margin-bottom: 1.25rem; box-shadow: 0 1px 6px rgba(0,0,0,0.05); }
.cv-stat-row { display: grid; background: var(--surface); }
.cv-stat-row:hover { filter: brightness(0.975); }
.cv-stat-row.has-diff { box-shadow: inset 3px 0 0 rgba(217,119,6,0.55); }
.cv-stat-row.is-same .cv-stat-value { color: var(--ink2); }
.cv-stat-label { padding: 0.45rem 0.8rem; font-family: 'Geist Mono', monospace; font-size: 0.61rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); background: var(--surface2); display: flex; align-items: center; }
.cv-stat-value { padding: 0.45rem 0.85rem; font-family: 'Inter', sans-serif; font-size: 0.83rem; font-weight: 500; color: var(--ink); display: flex; align-items: center; border-left: 3px solid transparent; }
.cv-stat-value.hi { color: #e11d48; } .cv-stat-value.warn { color: #d97706; } .cv-stat-value.good { color: #16a34a; }
/* Numeric conditional formatting: best = faint green tint, worst = faint red */
.cv-stat-value.num-best { background: rgba(22,163,74,0.07); color: #15803d; }
.cv-stat-value.num-worst { background: rgba(225,29,72,0.07); color: #be123c; }
/* Section grid */
.cv-sections-grid { display: flex; flex-direction: column; gap: 0.75rem; }
.cv-section-row { background: var(--surface); border: 1px solid var(--rule); border-radius: 9px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
/* Difference indicator: amber left border when cells differ. Matching rows stay quieter. */
.cv-section-row.has-diff { border-left: 3px solid #d97706; }
.cv-section-row.is-same { border-left-color: rgba(148,163,184,0.28); }
.cv-section-title-row { display: block; }
.cv-section-title-cell { padding: 0.42rem 1rem; background: #1e293b; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.67rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #94a3b8; display: flex; align-items: center; gap: 0.4rem; }
.cv-section-title-cell .cv-diff-badge,
.cv-section-title-cell .cv-same-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 0.08rem 0.38rem;
  font-size: 0.52rem;
  line-height: 1.25;
  letter-spacing: 0.08em;
  color: #fbbf24;
  background: rgba(251,191,36,0.12);
  border: 1px solid rgba(251,191,36,0.25);
}
.cv-section-title-cell .cv-same-badge {
  color: #cbd5e1;
  background: rgba(148,163,184,0.1);
  border-color: rgba(148,163,184,0.18);
}
.cv-section-cells { display: grid; gap: 1px; background: var(--rule); }
.cv-section-cell { background: var(--surface); padding: 0.8rem 1rem; min-height: 52px; }
/* Definition list layout (replaces table) */
.cv-cell-dl { margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.cv-cell-entry { display: flex; flex-direction: column; padding: 0.22rem 0; border-bottom: 1px solid rgba(0,0,0,0.04); }
.cv-cell-entry:last-child { border-bottom: none; }
.cv-cell-dt { font-family: 'Geist Mono', monospace; font-size: 0.63rem; font-weight: 700; color: var(--ink3); letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.3; }
.cv-cell-dd { font-family: 'Inter', sans-serif; font-size: 0.8rem; color: var(--ink2); margin: 0; line-height: 1.55; }
/* Keep legacy table styles for fallback */
.cv-cell-table { width: 100%; border-collapse: collapse; font-family: 'Inter', sans-serif; font-size: 0.8rem; }
.cv-cell-table td { padding: 0.2rem 0; vertical-align: top; color: var(--ink2); }
.cv-cell-table td:first-child { font-weight: 600; color: var(--ink3); padding-right: 0.6rem; min-width: 72px; max-width: 110px; font-size: 0.74rem; word-break: normal; overflow-wrap: break-word; vertical-align: top; }
.cv-empty-cell { font-family: 'Inter', sans-serif; font-size: 0.78rem; color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0; }
.cv-empty-cell::before { content: '—'; font-style: normal; font-weight: 600; opacity: 0.4; }
.cv-loading { display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 4rem 2rem; flex-direction: column; }
.cv-loading-spinner { width: 28px; height: 28px; border: 3px solid rgba(0,0,0,0.08); border-top-color: #4f46e5; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ═══ TABLET (≤ 900px) ══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .cv-drug-name { font-size: 0.98rem; }
  .cv-drug-header { padding: 0.9rem 1rem; }
  .cv-stat-label { padding: 0.4rem 0.7rem; font-size: 0.6rem; }
  .cv-stat-value { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
  .cv-section-cell { padding: 0.65rem 0.85rem; }
  .cv-cell-table { font-size: 0.77rem; }
  .cv-cell-dt { font-size: 0.6rem; }
  .cv-cell-dd { font-size: 0.78rem; }
}

/* ═══ MOBILE — comparison table (≤ 600px) ══════════════════════════════════ */
@media (max-width: 600px) {
  /* ── App bar ──────────────────────────────────────────────────────── */
  #patientBtn { padding: 0.5rem 0.6rem; min-height: 44px; }
  #patientBtnText { display: none; }
  #patientPanelContent {
    width: 100dvw;
    border-radius: 0;
  }
  .pp-header {
    padding: 0.85rem 1rem 0.75rem;
  }
  .pp-body {
    padding: 0.85rem 1rem;
    gap: 0.8rem;
  }
  .pp-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding: 0.65rem 0 0;
    background: linear-gradient(to top, var(--surface) 78%, rgba(255,255,255,0));
  }
  .pp-btn-primary,
  .pp-btn-secondary {
    min-height: 44px;
  }
  .pp-allergy-grid {
    grid-template-columns: 1fr;
  }

  .cv-table-wrap { padding: 0 0.6rem 5rem; }

  /* ── Mobile drug tabs: show at this breakpoint ── */
  .cv-mobile-tabs { display: flex; }
  /* When mobile tabs active, sticky headers already handled by tabs */
  .cv-mobile-tabs ~ .cv-drug-headers.cv-sticky-headers { position: static; box-shadow: none; }

  /* ── Drug header strip: allow off-screen columns to expand into cv-body ─ */
  /* overflow:hidden clips drug columns that overflow the grid width; replacing it
     with clip-path lets the grid expand naturally so cv-body can scroll.        */
  .cv-drug-headers { overflow: visible; clip-path: inset(0 round 10px); }
  /* sticky state has flat top corners */
  .cv-sticky-headers { clip-path: inset(0 round 0 0 10px 10px); }

  /* ── Drug header cards: min-width forces cv-body horizontal scroll ── */
  .cv-drug-header { min-width: 155px; padding: 0.75rem 0.85rem; }
  .cv-drug-name { font-size: 0.88rem; overflow-wrap: break-word; word-break: break-word; }
  .cv-drug-sub { font-size: 0.68rem; overflow-wrap: break-word; word-break: break-word; }
  .cv-drug-tag { font-size: 0.57rem; padding: 0.1rem 0.35rem; overflow-wrap: break-word; }
  /* remove button: full 44×44 touch target */
  .cv-drug-remove-btn {
    width: 44px; height: 44px; top: 0; right: 0;
    border-radius: 0 0 0 8px; font-size: 1.1rem;
  }

  /* ── Stats grid: enable sticky label column ─────────────────────── */
  /* overflow:hidden blocks position:sticky on descendants.
     clip-path preserves visual rounding without creating a scroll boundary. */
  .cv-stats-grid { overflow: visible; clip-path: inset(0 round 8px); }
  .cv-stat-label {
    position: sticky; left: 0; z-index: 1;
    min-width: 90px; max-width: 90px;
    font-size: 0.58rem; padding: 0.4rem 0.65rem;
    border-right: 1px solid var(--rule);
  }
  .cv-stat-value { min-width: 130px; font-size: 0.78rem; padding: 0.4rem 0.65rem; overflow-wrap: break-word; }

  /* ── Clinical section rows: same overflow fix as drug headers ────── */
  /* overflow:hidden on cv-section-row clips off-screen drug columns.
     clip-path preserves rounded corners while letting columns overflow. */
  .cv-section-row { overflow: visible; clip-path: inset(0 round 9px); }
  .cv-section-cell { min-width: 155px; padding: 0.6rem 0.75rem; }
  .cv-section-title-cell {
    position: sticky; left: 0; z-index: 2;
    width: fit-content;
    font-size: 0.63rem; padding: 0.4rem 0.85rem;
  }
  .cv-cell-table { font-size: 0.76rem; }
  .cv-cell-table td { overflow-wrap: break-word; }
  .cv-cell-table td:first-child { max-width: 72px; word-break: normal; overflow-wrap: break-word; }
  .cv-empty-cell { overflow-wrap: break-word; }
  .cv-section-heading { font-size: 0.57rem; }

  /* Stacked-view toggle button — visible at this width */
  .cv-stacked-toggle { display: flex; }
}

/* ═══ VERY SMALL (≤ 400px) ═════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .cv-drug-header { min-width: 138px; }
  .cv-section-cell { min-width: 138px; }
  .cv-stat-value { min-width: 115px; }
  .cv-stat-label { min-width: 78px; max-width: 78px; font-size: 0.55rem; }
  .compare-bar-inner { padding: 0.4rem 0.5rem 0.4rem 0.7rem; }
}

/* ═══ STACKED CARDS (≤ 360px) ══════════════════════════════════════════════ */
/* At this width the horizontal-scroll grid becomes cramped even at 138px     */
/* columns. Switch to a fully vertical stacked card layout instead.           */

/* ── Mobile compare bar: collapsed state (icon-only pill on ≤600px) ── */
@media (max-width: 600px) {
  /* Collapsed: hide chips, actions, hint — show only slots + tap cue */
  .compare-bar:not(.expanded) .compare-bar-drugs { display: none; }
  .compare-bar:not(.expanded) .compare-bar-actions { display: none; }
  .compare-bar:not(.expanded) .compare-bar-hint { display: none; }
  .compare-bar:not(.expanded) { cursor: pointer; }
  /* Expanded: show everything */
  .compare-bar.expanded .compare-bar-inner { flex-wrap: wrap; }
}

/* ═══ STACKED VIEW TOGGLE BUTTON (≤ 600px) ════════════════════════════════ */
.cv-stacked-toggle {
  display: none;
  align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; width: 44px; height: 44px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  color: #94a3b8; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cv-stacked-toggle:hover { background: rgba(255,255,255,0.14); color: #e2e8f0; }
.cv-stacked-toggle[aria-pressed="true"] {
  background: rgba(99,102,241,0.25); border-color: rgba(99,102,241,0.5); color: #c7d2fe;
}
/* Hidden by default; shown only in the stacked breakpoint or via .cv-stacked */
.cv-stack-drug-label { display: none; }

@media (max-width: 360px) {
  /* Toggle is redundant at this width — JS syncForceStack always forces
     .cv-stacked via the narrowMQ listener, so the button would have no effect. */
  .cv-stacked-toggle { display: none !important; }
  /* All stacked-layout rules live in the #compareView.cv-stacked block below;
     JS adds that class via narrowMQ, so no duplicated layout declarations here. */
}

/* ═══ STACKED CARDS — forced via .cv-stacked toggle ════════════════════════ */
/* Mirrors all ≤360px breakpoint rules but activated by class instead so     */
/* mobile users on wider phones can opt in (e.g. 375px + large text mode).   */
#compareView.cv-stacked .cv-stack-drug-label {
  display: block;
  font-family: 'Geist Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}
#compareView.cv-stacked .cv-drug-headers {
  display: flex !important;
  flex-direction: column;
  gap: 1px;
  overflow: visible;
  clip-path: inset(0 round 10px);
}
#compareView.cv-stacked .cv-sticky-headers {
  clip-path: inset(0 round 0 0 10px 10px);
}
#compareView.cv-stacked .cv-drug-header {
  min-width: 0 !important;
  width: 100%;
  padding: 0.8rem 1rem;
}
#compareView.cv-stacked .cv-drug-name { font-size: 0.95rem; }
#compareView.cv-stacked .cv-drug-sub  { font-size: 0.72rem; }
#compareView.cv-stacked .cv-drug-tag  { font-size: 0.6rem; }
#compareView.cv-stacked .cv-drug-remove-btn {
  width: 44px; height: 44px;
  top: 0; right: 0;
  border-radius: 0 0 0 8px; font-size: 1.1rem;
}
#compareView.cv-stacked .cv-stats-grid { overflow: visible; clip-path: inset(0 round 8px); }
#compareView.cv-stacked .cv-stat-row {
  display: flex !important;
  flex-direction: column;
  padding: 0.55rem 0.85rem;
  gap: 0;
}
#compareView.cv-stacked .cv-stat-label {
  position: static !important;
  min-width: 0 !important;
  max-width: none !important;
  width: 100%;
  border-right: none;
  border-bottom: 1px solid var(--rule);
  padding: 0 0 0.3rem;
  font-size: 0.58rem;
  background: transparent;
}
#compareView.cv-stacked .cv-stat-value {
  min-width: 0 !important;
  width: 100%;
  border-left: none !important;
  padding: 0.28rem 0;
  font-size: 0.85rem;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}
#compareView.cv-stacked .cv-stat-value::before {
  content: attr(data-drug);
  font-family: 'Geist Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink3);
  white-space: nowrap;
  flex-shrink: 0;
}
#compareView.cv-stacked .cv-section-row { overflow: visible; clip-path: inset(0 round 9px); }
#compareView.cv-stacked .cv-section-title-cell {
  position: static !important;
  width: 100%;
}
#compareView.cv-stacked .cv-section-cells {
  display: flex !important;
  flex-direction: column;
  gap: 0;
  background: var(--rule);
}
#compareView.cv-stacked .cv-section-cell {
  min-width: 0 !important;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--rule);
}
#compareView.cv-stacked .cv-cell-table { font-size: 0.78rem; }

/* ═══ MOBILE-TAB MODE: suppress stacked-mode repeated drug labels ═══════════
   When the mobile tab bar is active (JS adds .cv-mobile-tab-mode), the single-
   column tab view already scopes each column to one drug — so the per-cell
   drug name prefix injected by cv-stacked layout would be redundant noise. */
#compareView.cv-mobile-tab-mode.cv-stacked .cv-stack-drug-label { display: none !important; }
#compareView.cv-mobile-tab-mode.cv-stacked .cv-stat-value::before { content: none !important; }

/* ══════════════════════════════════════════════════
   PRINT — Clinical reference output
   ──────────────────────────────────────────────────
   Doctors and pharmacists frequently print individual drug pages for
   ward rounds, hand-over notes, or to leave bedside.  This stylesheet
   strips the chrome (sticky bars, palette, FAB, compare overlay) and
   forces a print-friendly layout so all section content is visible
   without horizontal-scroll truncation, links print without colour
   noise, and pages break cleanly between section cards.
══════════════════════════════════════════════════ */
@media print {
  /* Reset page margins and remove screen background */
  @page { margin: 14mm 12mm; }
  html, body { background: #fff !important; color: #000 !important; }

  /* Hide all interactive / out-of-flow chrome that has no print value.
     Note: `.sticky-header` is intentionally NOT hidden — it wraps `.hero`
     (drug name + class + badges), which is the print page identity. We
     unstick it below instead. */
  #appBar,
  .top-app-bar,
  .palette-overlay,
  .scroll-top-btn,
  #compareView,
  .compare-fab,
  .compare-bar,
  .patient-overlay,
  .pp-overlay,
  .sec-nav-strip,
  .hero-compare-btn,
  .fav-btn,
  .siblings-panel,
  .show-more-btn,
  .toast,
  .empty-state,
  [aria-hidden="true"][role="dialog"] { display: none !important; }

  /* Restore content to the natural document flow */
  .sticky-header { position: static !important; box-shadow: none !important; }
  .hero, .stats, .quick-card, .section, .summary-section { box-shadow: none !important; }
  #main { padding: 0 !important; max-width: none !important; }
  .hero { padding: 0 0 0.4cm 0 !important; }

  /* Force every section to its expanded state — collapsed cards must
     print all rows, otherwise the printed page is useless. The animated
     `grid-template-rows: 0fr` collapse is overridden so contents render. */
  .section[data-collapsed] .section-body,
  .section .section-body { grid-template-rows: 1fr !important; display: grid !important; }
  .section-body > .sec-grid,
  .section-body > table { overflow: visible !important; }
  .section { break-inside: avoid; page-break-inside: avoid; margin-bottom: 0.4cm !important; }
  .quick-card, .summary-section { break-inside: avoid; page-break-inside: avoid; }

  /* Two-column section bodies become single-column for narrower print width */
  .sec-grid, .quick-grid { grid-template-columns: 1fr !important; }

  /* Type sizing tuned for print legibility */
  .hero-name { font-size: 22pt !important; }
  .hero-eyebrow { font-size: 8pt !important; }
  .hero-class { font-size: 10pt !important; }
  .stat-label, .sec-cell-label, .quick-label { font-size: 7.5pt !important; }
  .stat-value, .sec-cell-value, .quick-value { font-size: 10pt !important; }

  /* Strip subtle background tints — they read as muddy grey on most
     office printers.  Keep the coloured accent bar so section identity
     remains visible. */
  .sec-cell, .quick-cell { background: transparent !important; }
  .section, .quick-card, .summary-section { background: #fff !important; border: 1px solid #ccc !important; }

  /* Print URLs after links so paper readers can follow them */
  a[href]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
  a[href^="#"]::after, a[href^="javascript:"]::after { content: ""; }

  /* Ensure colour-coded accent strips actually render in print */
  *, *::before, *::after { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
