/* Kawai Pharma — translucent chrome, spring-driven sheets, size-specific type.
   Dark by default; light mode respected. */

:root {
  --bg: #0a0b0d;
  --bg-elev: #14161a;
  --surface: 255 255 255;
  --surface-a: 0.055;
  --text: #f2f3f5;
  --text-dim: #a4a9b4;
  --text-faint: #6e7483;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #7c9cff;
  --accent-ink: #0a0b0d;
  --warn: #ffb959;
  --danger: #ff7a7a;
  --good: #6fd39a;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.75), 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.35);
  --gutter: 16px;
}

:root:not([data-theme="dark"]) {
  @media (prefers-color-scheme: light) {
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --surface: 0 0 0;
    --surface-a: 0.04;
    --text: #15171c;
    --text-dim: #5a616e;
    --text-faint: #8a909d;
    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.16);
    --accent: #3a63e0;
    --accent-ink: #ffffff;
    --warn: #a35c00;
    --danger: #c0352f;
    --good: #19764a;
    --shadow-lg: 0 30px 70px -24px rgba(16, 20, 32, 0.28), 0 2px 10px rgba(16, 20, 32, 0.08);
    --shadow-sm: 0 1px 8px rgba(16, 20, 32, 0.08);
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute is only `display: none` in the UA stylesheet, so ANY
   author rule that sets display (.sheet{flex}, .gate{grid}, .work{grid}…)
   silently defeats it. Make it win, or JS that toggles `.hidden` does nothing. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 100%/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis-weight: none;
  overflow-wrap: break-word;
}

body.locked { overflow: hidden; }

/* Ambient field — static, no looping animation (vestibular safety) */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(60% 60% at 20% 0%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(50% 50% at 85% 10%, color-mix(in oklab, var(--good) 14%, transparent), transparent 70%);
  filter: blur(40px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Chrome: translucent layer, content scrolls under ---------- */
.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid var(--line);
}

.chrome-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Scroll edge effect instead of a hard divider */
.scroll-edge {
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 22px;
  background: linear-gradient(color-mix(in srgb, var(--bg) 70%, transparent), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease-out;
}
.chrome.scrolled .scroll-edge { opacity: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.015em;
  font-size: 1.05rem;
  flex: none;
}
.brand-mark { font-size: 1.25rem; line-height: 1; }
.brand em { font-style: normal; color: var(--text-dim); font-weight: 500; }
@media (max-width: 620px) { .brand-text { display: none; } }

.search-wrap { position: relative; flex: 1 1 auto; min-width: 0; }

#search {
  width: 100%;
  padding: 10px 34px 10px 13px;
  font-size: 0.94rem;
  font-family: inherit;
  color: var(--text);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color 140ms ease-out, background-color 140ms ease-out;
  -webkit-appearance: none;
}
#search::placeholder { color: var(--text-faint); }
#search:focus-visible {
  border-color: color-mix(in oklab, var(--accent) 60%, transparent);
  background: rgb(var(--surface) / calc(var(--surface-a) * 1.8));
}

.search-hint {
  position: absolute;
  right: 9px; top: 50%;
  transform: translateY(-50%);
  font: 600 0.7rem/1 ui-monospace, monospace;
  color: var(--text-faint);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 5px;
  pointer-events: none;
}
@media (max-width: 760px) { .search-hint { display: none; } }

.chrome-actions { display: flex; gap: 8px; flex: none; }

.pill {
  font: 600 0.86rem/1 inherit;
  letter-spacing: -0.005em;
  /* Pills are buttons. An <a class="pill"> was inheriting the UA underline —
     visible on the "Sign in" and "Create account" links in the header. */
  text-decoration: none;
  color: var(--text);
  background: rgb(var(--surface) / calc(var(--surface-a) * 1.6));
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 110ms ease-out, background-color 140ms ease-out;
  touch-action: manipulation;
}
.pill:hover { background: rgb(var(--surface) / calc(var(--surface-a) * 2.6)); }
.pill:active { transform: scale(0.96); }
.pill-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.pill-accent:hover { background: color-mix(in oklab, var(--accent) 88%, white); }

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 0.7rem/18px ui-monospace, monospace;
  text-align: center;
}
.pill-accent .badge { background: var(--accent-ink); color: var(--accent); }

/* ---------- Main ---------- */
#main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter) 64px; }

.hero { padding: 54px 0 30px; max-width: 46rem; }
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 5.2vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: -0.028em;   /* negative tracking grows with size */
  font-weight: 680;
}
.hero p { margin: 0 0 20px; font-size: clamp(1rem, 2vw, 1.12rem); line-height: 1.6; color: var(--text-dim); letter-spacing: -0.004em; }

.hero-note {
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-dim);
  letter-spacing: 0.002em;    /* small text wants a touch of positive tracking */
  background: color-mix(in oklab, var(--warn) 11%, transparent);
  border: 1px solid color-mix(in oklab, var(--warn) 32%, transparent);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.hero-note strong { color: var(--text); font-weight: 640; }

/* ---------- Filters ---------- */
/* The category row wraps. It used to be a single nowrap row with
   `overflow-x: auto` and the scrollbar hidden — fine to swipe on a phone, but
   with 20 categories the row is ~2800px inside a ~1150px column, so with a
   mouse the later categories were off-screen with no scrollbar to reach them
   and no wheel axis that scrolls horizontally. Wrapping shows all of them. */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 14px;
}

@media (max-width: 640px) {
  /* On a narrow touch screen, five wrapped rows would push the grid below the
     fold; a swipeable row costs one row and needs no visible scrollbar. */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
  }
  .filters::-webkit-scrollbar { display: none; }
}

.chip {
  flex: none;
  scroll-snap-align: start;
  font: 550 0.84rem/1 inherit;
  letter-spacing: 0.002em;
  color: var(--text-dim);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 110ms ease-out, color 140ms ease-out, background-color 140ms ease-out;
  touch-action: manipulation;
}
.chip:active { transform: scale(0.95); }
.chip[aria-selected="true"] {
  color: var(--text);
  background: rgb(var(--surface) / calc(var(--surface-a) * 3.4));
  border-color: var(--line-strong);
}

/* ---------- Cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 13px;
}

.card {
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  /* No backdrop-filter here: with ~50 cards on screen it costs far more than
     it gives. Blur is for the large chrome surfaces, not for every card. */
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.card:active { transform: scale(0.985); }

.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card h3 {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 640;
  letter-spacing: -0.013em;
  line-height: 1.25;
}
.card-class { font-size: 0.78rem; color: var(--text-faint); letter-spacing: 0.004em; }
.card p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.52;
  color: var(--text-dim);
  letter-spacing: 0.001em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot { display: flex; align-items: center; gap: 7px; margin-top: auto; padding-top: 3px; flex-wrap: wrap; }

.tag {
  font: 600 0.69rem/1 ui-monospace, monospace;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--text-faint);
  background: rgb(var(--surface) / var(--surface-a));
}
.tag-ev-strong, .tag-ev-strong-clinical { color: var(--good); border-color: color-mix(in oklab, var(--good) 36%, transparent); background: color-mix(in oklab, var(--good) 11%, transparent); }
.tag-ev-moderate, .tag-ev-moderate-mixed, .tag-ev-weak-moderate, .tag-ev-preclinical-strong { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 36%, transparent); background: color-mix(in oklab, var(--warn) 11%, transparent); }
.tag-ev-weak, .tag-ev-weak-human, .tag-ev-weak-mixed, .tag-ev-preclinical, .tag-ev-preclinical-only, .tag-ev-preclinical-negative, .tag-ev-harm-documented { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 36%, transparent); background: color-mix(in oklab, var(--danger) 11%, transparent); }

.add-btn {
  margin-left: auto;
  font: 600 0.78rem/1 inherit;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 11px;
  cursor: pointer;
  transition: transform 110ms ease-out, color 140ms ease-out, border-color 140ms ease-out;
  touch-action: manipulation;
}
.add-btn:hover { color: var(--text); border-color: var(--accent); }
.add-btn:active { transform: scale(0.93); }
.add-btn[data-in="1"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

.empty { text-align: center; color: var(--text-faint); padding: 48px 0; }

.foot { margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--text-faint); font-size: 0.82rem; letter-spacing: 0.003em; }
.foot p { margin: 0 0 6px; }
.foot-small { max-width: 44rem; }

/* ---------- Scrim + sheet ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  will-change: opacity;
}

.sheet {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 0;
  width: min(760px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(30px) saturate(170%);
  -webkit-backdrop-filter: blur(30px) saturate(170%);
  border: 1px solid var(--line-strong);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  /* JS owns the Y transform; X centering is composed in by script */
  transform: translate(-50%, 100%);
  will-change: transform;
  touch-action: none;
}

.sheet-grabber { padding: 10px 0 4px; display: grid; place-items: center; cursor: grab; flex: none; }
.sheet-grabber span { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); }
.sheet-grabber:active { cursor: grabbing; }

.sheet-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 24px calc(28px + env(safe-area-inset-bottom));
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 560px) { .sheet-scroll { padding-left: var(--gutter); padding-right: var(--gutter); } }

.detail-head { display: flex; align-items: flex-start; gap: 12px; padding: 6px 0 4px; }
.detail-head h2 { margin: 0; font-size: clamp(1.45rem, 4vw, 1.95rem); line-height: 1.1; letter-spacing: -0.022em; font-weight: 670; }
.detail-aka { margin: 5px 0 0; font-size: 0.84rem; color: var(--text-faint); letter-spacing: 0.004em; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 13px 0 4px; }
.detail-status {
  margin: 14px 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-dim);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.detail h3 {
  margin: 26px 0 9px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.085em;   /* small caps-ish label: positive tracking */
  text-transform: uppercase;
  color: var(--text-faint);
}
.detail p { margin: 0 0 10px; font-size: 0.93rem; line-height: 1.62; color: var(--text-dim); }
.detail strong { color: var(--text); font-weight: 620; }

.detail ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.detail li {
  font-size: 0.9rem;
  line-height: 1.52;
  color: var(--text-dim);
  padding-left: 17px;
  position: relative;
}
.detail li::before {
  content: "";
  position: absolute;
  left: 3px; top: 0.6em;
  width: 5px; height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
}
.detail ul.risks li::before { background: var(--danger); }
.detail ul.effects li::before { background: var(--good); }

.studies { display: flex; flex-direction: column; gap: 9px; }
.study {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgb(var(--surface) / var(--surface-a));
  transition: transform 120ms ease-out, border-color 150ms ease-out;
}
.study:hover { border-color: var(--accent); }
.study:active { transform: scale(0.99); }
.study-title { font-size: 0.89rem; font-weight: 580; line-height: 1.42; letter-spacing: -0.003em; }
.study-note { font-size: 0.8rem; color: var(--text-faint); margin-top: 4px; line-height: 1.45; }
.study-link { font: 600 0.72rem/1 ui-monospace, monospace; color: var(--accent); margin-top: 7px; display: block; }

.detail-actions { display: flex; gap: 9px; margin: 26px 0 4px; flex-wrap: wrap; }

/* ---------- Side panels ---------- */
.panel {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  height: 100%;
  width: min(430px, 100%);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(30px) saturate(170%);
  -webkit-backdrop-filter: blur(30px) saturate(170%);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  will-change: transform;
}

.panel-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 18px 13px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 1.12rem; font-weight: 640; letter-spacing: -0.015em; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: 0.9rem;
  color: var(--text-dim);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 110ms ease-out, color 140ms ease-out;
  touch-action: manipulation;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:active { transform: scale(0.9); }

.panel-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px; }

/* Stack panel */
.stack-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.stack-item:last-of-type { border-bottom: none; }
.stack-item h4 { margin: 0 0 3px; font-size: 0.94rem; font-weight: 600; letter-spacing: -0.008em; }
.stack-item p { margin: 0; font-size: 0.79rem; color: var(--text-faint); line-height: 1.45; }
.stack-item button { flex: none; }

.stack-note {
  margin-top: 18px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: rgb(var(--surface) / var(--surface-a));
}
.stack-note h4 { margin: 0 0 7px; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.stack-note ul { margin: 0; padding-left: 16px; }
.stack-note li { margin-bottom: 5px; }
.stack-note.flag { border-color: color-mix(in oklab, var(--danger) 34%, transparent); background: color-mix(in oklab, var(--danger) 9%, transparent); }
.panel-empty { color: var(--text-faint); font-size: 0.89rem; line-height: 1.6; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 13px; }
.msg { max-width: 92%; font-size: 0.9rem; line-height: 1.6; }
.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 13px;
  border-radius: 16px 16px 5px 16px;
  font-weight: 500;
}
.msg-ai { align-self: flex-start; color: var(--text-dim); max-width: 100%; }
.msg-ai strong { color: var(--text); font-weight: 620; }
.msg-ai ul { margin: 8px 0; padding-left: 18px; }
.msg-ai li { margin-bottom: 5px; }
.msg-ai p { margin: 0 0 9px; }
.msg-ai p:last-child { margin-bottom: 0; }
.msg-err { align-self: flex-start; color: var(--danger); font-size: 0.86rem; }

.chat-seed { color: var(--text-faint); font-size: 0.87rem; line-height: 1.6; }
.chat-seed h4 { margin: 0 0 8px; color: var(--text); font-size: 0.95rem; font-weight: 620; letter-spacing: -0.01em; }
.seed-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.seed-chip {
  font: 500 0.8rem/1.3 inherit;
  text-align: left;
  color: var(--text-dim);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  transition: transform 110ms ease-out, border-color 140ms ease-out;
}
.seed-chip:hover { border-color: var(--accent); color: var(--text); }
.seed-chip:active { transform: scale(0.96); }

.cursor { display: inline-block; width: 7px; height: 1em; vertical-align: -0.15em; background: var(--accent); border-radius: 1px; }

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
#ai-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 160px;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  background: rgb(var(--surface) / var(--surface-a));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 140ms ease-out;
}
#ai-input:focus-visible { border-color: color-mix(in oklab, var(--accent) 60%, transparent); }
#ai-input::placeholder { color: var(--text-faint); }

.send {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 110ms ease-out, opacity 140ms ease-out;
  touch-action: manipulation;
}
.send:active { transform: scale(0.9); }
.send:disabled { opacity: 0.45; cursor: default; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
  .card:active, .pill:active, .chip:active, .add-btn:active, .icon-btn:active, .send:active, .study:active, .seed-chip:active { transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .chrome, .sheet, .panel, .card {
    background: var(--bg-elev);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .chrome { background: var(--bg); }
  body::before { display: none; }
  .scrim { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(0, 0, 0, 0.62); }
}

@media (prefers-contrast: more) {
  :root { --line: rgba(255, 255, 255, 0.3); --line-strong: rgba(255, 255, 255, 0.5); --text-dim: #d6d9e0; --text-faint: #b0b5c0; }
  .chrome, .sheet, .panel { background: var(--bg-elev); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .card { border-color: var(--line-strong); }
}

@media print {
  .chrome, .panel, .scrim, .filters, .sheet-grabber { display: none !important; }
  body { background: #fff; color: #000; }
}

.foot a { color: var(--text-dim); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.foot a:hover { color: var(--accent); }


/* ---------- Utilities ----------
   The CSP sets style-src 'self' with no 'unsafe-inline', so a style="" written
   into an HTML string is dropped by the browser. These replace the one-off
   inline styles; anything data-driven is set through CSSOM instead. */
.u-pad-page { padding: 40px 0; }
.u-pad-sm { padding: 14px; }
.u-mt-xs { margin-top: 8px; }
.u-mt-sm { margin-top: 12px; }
.u-mt-md { margin-top: 14px; }
.u-mt-lg { margin-top: 16px; }
.u-m0 { margin: 0; }
.u-grow { flex: 1 1 auto; min-width: 0; }
.u-row { display: flex; gap: 7px; }
.u-maxw { max-width: 340px; }
.u-minh { min-height: 120px; }
.u-field-tight { margin: 0; gap: 7px; }
.pill-sm { padding: 8px 13px; font-size: 0.8rem; }
.pill-xs { padding: 7px 12px; font-size: 0.8rem; }

/* ---------- Dosing block ----------
   Reported, never advised: an approved label dose, or an explicit statement
   that none exists. Colour follows that distinction. */
.dosing {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgb(var(--surface) / var(--surface-a));
  border-left: 3px solid var(--line-strong);
}
.dosing-label {
  display: block;
  font: 700 0.63rem/1 ui-monospace, monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.dosing-ind { display: block; font-size: 0.76rem; color: var(--text-faint); margin-top: 4px; font-style: italic; }
.dosing p { margin: 7px 0 0 !important; font-size: 0.87rem; line-height: 1.58; color: var(--text-dim); }

.dosing-approved { border-left-color: var(--good); }
.dosing-approved .dosing-label { color: var(--good); }
.dosing-prescription-only { border-left-color: var(--warn); }
.dosing-prescription-only .dosing-label { color: var(--warn); }
.dosing-none-established { border-left-color: var(--danger); }
.dosing-none-established .dosing-label { color: var(--danger); }

/* ---------- Social links ---------- */
.social { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.social a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-dim);
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(var(--surface) / var(--surface-a));
  transition: color 140ms ease-out, border-color 140ms ease-out, transform 100ms ease-out;
}
.social a:hover { color: var(--text); border-color: var(--accent); }
.social a:active { transform: scale(0.97); }


/* ====================================================================
   Touch & small screens
   --------------------------------------------------------------------
   Measured over CDP at 390x844 and 360x740. Three problems, all real:

   1. Tap targets. 25 controls on /browse and 15 on /account were under
      40px tall — chips and pills at 31-35px, and text inputs at 21px.
      Apple and Android both put the comfortable minimum at ~44px.
   2. Text under 12px in a dozen places, down to 9.9px, which is below
      what most people can read on a phone held at arm's length.
   3. Inputs with a font under 16px: iOS Safari zooms the whole page in
      when you focus one, and does not zoom back out.

   Scoped to coarse pointers so a mouse keeps the tighter desktop sizing.

   These use !important deliberately. They are floors, not preferences, and
   the component styles that set the too-small values are either more
   specific (.goal input, .chrome-actions .pill) or live in stylesheets
   loaded after this one (graph.css, account.css). Without it the rules
   silently lose the cascade — which is exactly what the first attempt did.
   ==================================================================== */

@media (pointer: coarse), (max-width: 860px) {
  /* --- Tap targets --- */
  /* `display` is forced too: min-height does nothing on a non-replaced
     inline element, and .chrome-actions .pill is inline — which is why the
     first pass left pills 17px tall on /account. */
  body .chip,
  body .pill,
  body .mode-btn,
  body .auth-tab,
  body .mech-chip,
  body .add-row,
  body .subnav-link,
  body summary,
  body button:not(.sheet-close):not(.icon-btn) {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Inputs were the worst offenders at 21px tall, and a sub-16px font makes
     iOS Safari zoom the page in on focus and never zoom back out. */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 44px !important;
    font-size: 16px !important;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 22px !important;
    height: 22px !important;
  }

  /* The logo measured 27x20 — a real hit area, without moving it. */
  .brand {
    min-height: 44px !important;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Small inline links ("editor", "Discord ↗") need a thumb-sized box too. */
  .foot a, .social a { min-height: 44px; display: inline-flex; align-items: center; }

  /* --- Legibility: 13px floor ---
     Prefixed with `body`. A plain `.sys-contrib { … !important }` loses to
     graph.css:336, which is also !important and loads later — between two
     !important rules of equal specificity the later one wins. The extra
     element bumps specificity so these hold wherever they are declared.
     Absolute px, not rem, so the floor can't drift with a root resize. */
  body .tag,
  body label,
  body .eyebrow,
  body .legend-title,
  body .legend-step,
  body .legend-note,
  body .pick-meta,
  body .pick-group,
  body .sys-contrib,
  body .field-hint,
  body .subnav-count,
  body .graph-stat,
  body .day-sets,
  body .metric-sub,
  body .ex-muscles,
  body .comp-ev,
  body .cat-n,
  body .overlap-pct span,
  body .pw-chip i,
  body .vol-name i,
  body .side-item small,
  body .data-table th,
  body .data-table td,
  body dt {
    font-size: 13px !important;
  }

  /* Graph and mindmap labels are SVG text, which the rules above don't reach. */
  body .graph-label,
  body .mind-label,
  body svg text {
    font-size: 13px;
  }

  /* --- Room to work --- */
  .graph-pane { height: 78vh; }
  .graph-host { min-height: 340px; }

  /* Wide tables scroll rather than losing their last column. */
  #table-host,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
