/* Elevated Self — shared styles for index + the three product pages.
   Tokens mirror the apps' own palette (see DrHerb/android/.../ui/Theme.kt). */

/* Light is the baseline. Explicit token overrides make the theme switch work in
   browsers that do not resolve light-dark() reliably after color-scheme changes. */
:root {
  color-scheme: light dark;
  --bg:        #f7f9fa;
  --surface:   #ffffff;
  --surface-2: #eef3f5;
  --divider:   #dde5e8;
  --text:      #142a30;
  --muted:     rgba(20, 42, 48, 0.68);
  --accent:    #127c84;
  --cta:       #f08c2e;
  --on-cta:    #2a1b00;
  --green:     #2e9e6b;
  --green-text: #1f7a4d;   /* the green as small text: 4.5:1 or better */
  --herbalrx-brand: #3a6bb8;
  --shadow-near: rgba(20, 42, 48, 0.04);
  --shadow-far:  rgba(20, 42, 48, 0.06);
  --shadow: 0 1px 2px var(--shadow-near), 0 8px 24px var(--shadow-far);
  --shadow-hover: 0 2px 4px var(--shadow-near), 0 18px 44px var(--shadow-far);
  --radius: 16px;
  /* Amber is fine on buttons behind dark text, but too light for small text on
     a white page. Text that carries the Dr.Peptide colour uses this instead. */
  --cta-text: #a85a0d;
}

/* assets/theme.js sets data-theme on <html>; absent = follow the system. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #10191c;
  --surface:   #18242a;
  --surface-2: #1e2c33;
  --divider:   #26343a;
  --text:      #e6eef0;
  --muted:     rgba(230, 238, 240, 0.62);
  --accent:    #35b6c0;
  --cta:       #ff9b45;
  --cta-text:  #ff9b45;
  --green:     #43c08a;
  --green-text: #43c08a;
  --herbalrx-brand: #7aa5e8;
  --shadow-near: rgba(0, 0, 0, 0.30);
  --shadow-far:  rgba(0, 0, 0, 0.28);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:        #10191c;
    --surface:   #18242a;
    --surface-2: #1e2c33;
    --divider:   #26343a;
    --text:      #e6eef0;
    --muted:     rgba(230, 238, 240, 0.62);
    --accent:    #35b6c0;
    --cta:       #ff9b45;
    --cta-text:  #ff9b45;
    --green:     #43c08a;
    --green-text: #43c08a;
    --herbalrx-brand: #7aa5e8;
    --shadow-near: rgba(0, 0, 0, 0.30);
    --shadow-far:  rgba(0, 0, 0, 0.28);
  }
}

/* Per-product accent. Dr.Herb leads with the green from its logo gradient,
   Dr.Peptide with the amber it uses for actions, Herbal RX with the steel blue
   from its mark — deliberately the coolest of the three, it's the clinical one. */
body.drherb,   .card.drherb   { --brand: var(--green); --brand-text: var(--green-text); }
body.drpeptide, .card.drpeptide { --brand: var(--cta); --brand-text: var(--cta-text); }
body.herbalrx, .card.herbalrx  { --brand: var(--herbalrx-brand); --brand-text: var(--herbalrx-brand); }
body { --brand: var(--accent); --brand-text: var(--accent); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; width: min(1040px, 92%); margin: 0 auto; }
a { color: var(--accent); }
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ── skip link ─────────────────────────────────────────────────────── */
.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
}
.skip:focus { top: 1rem; }

/* ── site header ───────────────────────────────────────────────────────
   Brand on the left, the app links in the middle, the theme switch (injected
   by assets/theme.js) on the right. On phones the links drop to a second row
   that scrolls sideways rather than wrapping into a block. */
.topbar {
  width: min(1040px, 92%);
  margin: 0 auto;
  padding: 1.1rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.6rem 1.5rem;
  /* Reserve the row height: theme.js injects the switch, and without this the
     page would jolt downward the moment it appears. */
  min-height: 3.1rem;
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  flex: none;
}
.topbar .brand img { width: 26px; height: 26px; }
.site-nav {
  display: flex;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
/* 1100px, not a phone width: eight links plus the brand and theme switch need
   about 1,000px on one row, so narrower windows give the links their own row. */
@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; }
  .theme-switch { order: 2; }
  .site-nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    /* Bleed to the screen edges. The topbar is 92% wide, so each gutter is 4/92 of it;
       percentages, unlike vw, leave out a desktop scrollbar and can't cause sideways scroll. */
    margin: 0 -4.348%;
    padding: 0.2rem 4.348% 0.3rem;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a:first-child { margin-left: -0.6rem; }
}

/* ── theme switch ──────────────────────────────────────────────────────
   Three-way, mirroring the System / Light / Dark control both apps have in
   their own Settings — a plain light/dark flip would leave no way back to
   following the system. Injected by assets/theme.js. */
.theme-switch {
  display: inline-flex;
  border: 1px solid var(--divider);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
  flex: none;
  margin-left: auto;   /* right-aligned whether or not a back link precedes it */
}
.theme-switch button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  line-height: 1.5;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

/* ── home hero ─────────────────────────────────────────────────────── */
header.home { text-align: center; padding: 3rem 0 3rem; }
header.home img { width: 120px; max-width: 36vw; }
.hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 1.8rem; }
.hero-cta .btn { width: auto; min-width: 10rem; padding: 0.75rem 1.4rem; }
.btn.drpeptide { background: var(--cta); color: var(--on-cta); }
.btn.drherb { background: #1f7a4d; color: #fff; }
h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-top: 1rem;
  line-height: 1.15;
}
h1 span.grad {
  background: linear-gradient(100deg, #4a7bc8, var(--accent), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { font-size: 1.15rem; color: var(--muted); max-width: 34em; margin: 0.9rem auto 0; }

/* ── product cards on the home page ────────────────────────────────── */
/* Flex rather than grid so an odd count (five apps) centres its last row
   instead of leaving a hole. Three across, then two, then one as it narrows. */
.products {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  padding: 0 0 3rem;
}
.card {
  flex: 0 1 calc((100% - 3rem) / 3);
  min-width: min(300px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: var(--shadow-hover); }

/* Two flagship cards side by side, then the rest in a quieter compact row. */
.products.flagship { padding-bottom: 1.5rem; }
.products.flagship .card { flex-basis: calc((100% - 1.5rem) / 2); padding: 2.4rem 2rem; }
.products.compact { padding-bottom: 3rem; }
.card.compact {
  flex-basis: calc((100% - 3rem) / 3);
  min-width: min(280px, 100%);
  flex-direction: row;
  align-items: flex-start;
  gap: 0.9rem;
  text-align: left;
  padding: 1.15rem 1.25rem;
  box-shadow: none;
}
.card.compact:hover { box-shadow: var(--shadow); }
.card.compact img.icon, .card.compact svg.icon { width: 44px; height: 44px; margin: 0; flex: none; }
.card.compact > div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card.compact h2 { font-size: 1.05rem; margin: 0.1rem 0 0.1rem; }
.card.compact .kind { font-size: 0.7rem; }
.card.compact p { font-size: 0.9rem; margin-top: 0.45rem; }
.card.compact .more { margin-top: 0.7rem; font-size: 0.9rem; }
/* One card per row on phones. Last so it beats the flagship/compact widths above. */
@media (max-width: 700px) {
  .products .card, .products.flagship .card, .products .card.compact { flex-basis: 100%; min-width: 0; }
}
.card img.icon { width: 88px; height: 88px; object-fit: contain; margin: 0 auto; }
.card h2 { font-size: 1.45rem; font-weight: 800; margin: 1rem 0 0.2rem; }
.card .kind {
  color: var(--brand-text);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.card p { color: var(--muted); margin-top: 0.8rem; flex: 1; }
.card .more { margin-top: 1.25rem; font-weight: 700; color: var(--brand-text); }

/* ── product page hero ─────────────────────────────────────────────── */
header.product {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: center;
  padding: 2.5rem 0 2rem;
}
header.product img { width: 104px; height: 104px; object-fit: contain; }
header.product .kind {
  color: var(--brand-text);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
header.product h1 { font-size: clamp(2rem, 5.5vw, 2.9rem); margin-top: 0.3rem; }
header.product p { color: var(--muted); font-size: 1.1rem; margin-top: 0.6rem; max-width: 42em; }
@media (max-width: 560px) {
  .theme-switch button { padding-inline: 0.65rem; }
  header.product { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  header.product .pills { justify-content: center; }
  .pill { font-size: 0.78rem; padding: 0.25rem 0.65rem; }
}

.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.pill {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--divider);
}

/* ── sections ──────────────────────────────────────────────────────── */
section { padding: 2.5rem 0; border-top: 1px solid var(--divider); }
section > h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-bottom: 0.4rem;
}
section > .lede { color: var(--muted); max-width: 46em; margin-bottom: 1.6rem; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
  gap: 1.1rem;
  align-items: start;
}
.features + p, .features + .lede, .features + .note { margin-top: 1.6rem; }
.note + .lede { margin-top: 1.6rem; }
section > p + p { margin-top: 0.8rem; }
section > p:last-child a { text-decoration: none; }
section > p:last-child a:hover { text-decoration: underline; }
.feature {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.35rem;
}
.feature h3 { font-size: 1.02rem; font-weight: 800; margin-bottom: 0.35rem; }
.feature h3::before {
  content: "";
  display: block;
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background: var(--brand);
  margin-bottom: 0.7rem;
}
.feature p { color: var(--muted); font-size: 0.94rem; }

/* ── screenshot strip ──────────────────────────────────────────────── */
.shots {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}
.shots::-webkit-scrollbar { height: 6px; }
.shots::-webkit-scrollbar-track { background: transparent; }
.shots::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 999px; }
.shots figure { flex: 0 0 auto; width: 240px; scroll-snap-align: start; }
.shots img {
  width: 100%;
  height: auto;
  border-radius: 20px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow);
  display: block;
}
.shots figcaption { color: var(--muted); font-size: 0.86rem; margin-top: 0.6rem; }

/* walkthrough video beside the screenshot strip */
.demo { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.demo video {
  width: min(280px, 100%);
  height: auto;
  aspect-ratio: 9 / 20;
  border-radius: 20px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow);
  background: #10191c;
  display: block;
}
.demo .demo-text { flex: 1 1 18rem; color: var(--muted); margin: 0; }

/* ── get the app ───────────────────────────────────────────────────── */
.get { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 1.1rem; }
.get + .note { margin-top: 1.6rem; }
.store {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}
.store h3 { font-size: 1.05rem; font-weight: 800; }

.qr {
  width: 148px;
  height: 148px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  border: 1px solid var(--divider);
  display: grid;
  place-items: center;
}
.qr img { width: 100%; height: 100%; display: block; }
/* No QR generated yet → the <img> onerror swaps in this dashed placeholder.
   Drop the PNG into assets/qr/ (see tools/make_qr.py) and it appears by itself. */
.qr.empty { background: var(--surface-2); border-style: dashed; }
.qr.empty img { display: none; }
.qr.empty::after {
  content: "QR code once the listing is live";
  color: var(--muted);
  font-size: 0.76rem;
  padding: 0 0.8rem;
  text-align: center;
  line-height: 1.35;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  transition: filter 0.15s ease, transform 0.15s ease;
}
body.drpeptide .btn { color: var(--on-cta); }
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.disabled {
  background: transparent;
  color: var(--muted);
  border-color: var(--divider);
  cursor: default;
  pointer-events: none;
}

/* ── notes ─────────────────────────────────────────────────────────── */
.note {
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-left: 3px solid var(--brand);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.note strong { color: var(--text); }
.note + .note { margin-top: 0.8rem; }

/* ── long-form pages (privacy, research) ───────────────────────────── */
.prose { max-width: 44em; padding: 1.5rem 0 1rem; overflow-wrap: anywhere; }
.prose h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}
.prose h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 2.4rem 0 0.6rem;
}
.prose h3 { font-size: 1.02rem; font-weight: 800; margin: 1.6rem 0 0.4rem; }
.prose p, .prose ul, .prose ol { margin-bottom: 1rem; color: var(--muted); }
.prose li { margin-bottom: 0.45rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose strong { color: var(--text); }
.prose > p:first-of-type { font-size: 1.1rem; }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 1.2rem; font-size: 0.94rem; }
.prose th, .prose td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}
.prose th { color: var(--text); font-weight: 700; }
.prose td { color: var(--muted); }
.updated { color: var(--muted); font-size: 0.88rem; margin-top: 0.4rem; }

footer {
  text-align: center;
  padding: 2.5rem 0;
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--divider);
}
footer a { color: var(--accent); text-decoration: none; }
footer nav { margin-bottom: 0.6rem; display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .btn { transition: none; }
  .card:hover, .btn:hover { transform: none; }
}

/* ── screenshot lightbox (assets/lightbox.js) ──────────────────────── */
.shots a.zoom { display: block; cursor: zoom-in; border-radius: 20px; }
.shots a.zoom:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(6, 12, 14, 0.95); }
.lb-stage {
  position: absolute;
  inset: 3.5rem 0 4.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  overscroll-behavior: contain;
}
.lb-stage img {
  max-width: calc(100vw - 2rem);
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 14px;
  cursor: zoom-in;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}
/* Actual size: 1320 px composites at 2x density, scroll vertically to read. */
.lightbox.actual .lb-stage { align-items: flex-start; }
.lightbox.actual .lb-stage img { max-height: none; width: min(660px, calc(100vw - 2rem)); cursor: zoom-out; }
.lb-caption, .lb-count {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 4rem;
  text-align: center;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
}
.lb-caption { bottom: 1.4rem; }
.lb-count { top: 1.1rem; font-size: 0.85rem; color: rgba(255, 255, 255, 0.6); }
.lb-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.22); }
.lb-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.lb-close { top: 0.6rem; right: 0.8rem; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: 0.8rem; }
.lb-next { right: 0.8rem; }
@media (max-width: 600px) {
  .lb-prev, .lb-next { top: auto; bottom: 0.8rem; transform: none; }
  .lb-caption { bottom: 1.5rem; padding: 0 3.6rem; font-size: 0.85rem; }
}

/* ── peptide calculator (calculator/index.html) ────────────────────────
   Inputs on the left, a sticky result card on the right; on phones the
   result docks to the bottom of the screen so it stays visible while typing,
   as the app's result dock does. */
.calc-hero { padding: 2.5rem 0 1.8rem; max-width: 44em; }
.calc-hero .kind {
  color: var(--brand-text); font-weight: 700; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.calc-hero h1 { font-size: clamp(2rem, 5.5vw, 2.9rem); margin-top: 0.3rem; }
.calc-hero p { color: var(--muted); font-size: 1.1rem; margin-top: 0.6rem; }

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 1.5rem;
  align-items: start;
  padding-bottom: 3rem;
}
.calc-inputs {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}
.calc-step { display: flex; flex-direction: column; gap: 0.75rem; }
.calc-step[hidden], .calc .field[hidden] { display: none; }
.calc-step h2 { font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: 0.55rem; }
.calc-step h2 span {
  display: inline-grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--cta); color: var(--on-cta); font-size: 0.82rem;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.row-dose { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: end; }
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field > span:first-child, .field-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.field .input {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--divider);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field .input:focus-within { border-color: var(--cta); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cta) 22%, transparent); }
.field input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 1.08rem; font-weight: 600; color: var(--text);
  background: none; border: 0; outline: 0;
  padding: 0.65rem 0.8rem;
}
.field input::placeholder { color: var(--muted); font-weight: 400; }
.field input[aria-invalid="true"] { color: #d64545; }
.field em { font-style: normal; color: var(--muted); font-size: 0.86rem; padding-right: 0.8rem; white-space: nowrap; }
.hint { color: var(--muted); font-size: 0.84rem; }
.hint:empty { display: none; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 11px;
  padding: 3px;
  gap: 3px;
}
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.seg button {
  font: inherit; font-size: 0.9rem; font-weight: 700;
  color: var(--muted);
  background: none; border: 0; border-radius: 8px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  min-height: 2.5rem;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.chips span { font-size: 0.78rem; font-weight: 700; color: var(--muted); margin: 0 0.15rem 0 0.4rem; }
.chips span:first-child { margin-left: 0; }
.chips button, .calc .ghost {
  font: inherit; font-size: 0.82rem; font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}
.chips button:hover, .calc .ghost:hover { border-color: var(--cta); }
.calc .ghost { align-self: flex-start; padding: 0.4rem 0.9rem; }

.comp { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 0.6rem; align-items: end; }
.comp + .comp { margin-top: 0.6rem; }
.comp .x {
  width: 2.6rem; height: 2.85rem;
  font-size: 1.3rem; line-height: 1;
  color: var(--muted); background: none;
  border: 1px solid var(--divider); border-radius: 10px;
  cursor: pointer;
}
.comp .x:hover { color: var(--text); border-color: var(--muted); }

.calc-result { position: sticky; top: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.res-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-top: 4px solid var(--cta);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
}
.res-card.over { border-top-color: #d64545; }
.res-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.res-big { display: flex; align-items: baseline; gap: 0.45rem; margin-top: 0.1rem; }
.res-big strong {
  font-size: clamp(2.8rem, 7vw, 3.6rem); font-weight: 800; line-height: 1.05;
  letter-spacing: -0.03em; color: var(--cta-text);
  font-variant-numeric: tabular-nums;
}
.res-card.over .res-big strong { color: #d64545; }
.res-big span { color: var(--muted); font-weight: 600; }
.syringe { width: 100%; height: auto; margin: 0.9rem 0 0.4rem; display: block; overflow: visible; }
.sy-barrel { fill: var(--bg); stroke: var(--muted); stroke-width: 1.2; }
.sy-fill { fill: color-mix(in srgb, var(--cta) 45%, transparent); }
.sy-fill.over { fill: rgba(214, 69, 69, 0.4); }
.sy-rod { fill: var(--divider); }
.sy-tick { stroke: var(--muted); stroke-width: 0.8; opacity: 0.55; }
.sy-tick.major { stroke-width: 1.2; opacity: 0.9; }
.sy-num { fill: var(--muted); font-size: 9px; text-anchor: middle; font-family: inherit; }
.sy-plunger { fill: var(--cta); }
.sy-plunger.over { fill: #d64545; }
.res-stats { display: grid; gap: 0.1rem; margin-top: 0.6rem; }
.res-stats div {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 0; border-bottom: 1px dashed var(--divider);
  font-size: 0.94rem;
}
.res-stats div:last-child { border-bottom: 0; }
.res-stats dt { color: var(--muted); overflow-wrap: anywhere; }
.res-stats dd { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-warn { color: #d64545; font-size: 0.86rem; font-weight: 600; margin-top: 0.6rem; }
.res-empty { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; }
.res-app {
  display: flex; gap: 0.85rem; align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  font-size: 0.88rem;
}
.res-app img { border-radius: 10px; flex: none; }
.res-app div { display: flex; flex-direction: column; gap: 0.15rem; }
.res-app span { color: var(--muted); }
.res-app a { font-weight: 700; color: var(--cta-text); text-decoration: none; margin-top: 0.2rem; }

.faq { display: flex; flex-direction: column; gap: 0.6rem; max-width: 46em; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 0.9rem 1.15rem;
}
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { color: var(--muted); margin-top: 0.55rem; font-size: 0.95rem; }

@media (max-width: 860px) {
  .calc { grid-template-columns: 1fr; }
  /* Docked to the bottom on phones/tablets: just the number and syringe. */
  .calc-result { position: sticky; bottom: 0; top: auto; z-index: 5; margin: 0 -4.348%; }
  .res-card {
    border-radius: 18px 18px 0 0;
    padding: 0.8rem 4vw 0.9rem;
    box-shadow: 0 -8px 24px var(--shadow-far);
  }
  /* Number on the left, figures on the right, syringe across the bottom. */
  .res-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "label stats" "big stats" "sy sy" "warn warn" "empty empty";
    column-gap: 1rem;
    align-items: start;
  }
  .res-label { grid-area: label; }
  .res-big { grid-area: big; }
  .res-big strong { font-size: 2.3rem; }
  .syringe { grid-area: sy; margin: 0.3rem 0 0; max-height: 46px; }
  .res-stats { grid-area: stats; margin: 0; gap: 0; align-self: center; }
  .res-stats div { padding: 0.05rem 0; border: 0; font-size: 0.8rem; gap: 0.6rem; }
  .res-warn { grid-area: warn; margin-top: 0.3rem; font-size: 0.8rem; }
  .res-empty { grid-area: empty; margin-top: 0.2rem; }
  .res-app { display: none; }
  .calc { padding-bottom: 0; }
}
@media (max-width: 480px) {
  .calc-inputs { padding: 1.1rem; }
  .row2 { grid-template-columns: 1fr; }
  .row-dose { grid-template-columns: 1fr; }
  .comp { grid-template-columns: 1fr 0.8fr auto; }
}
.res-tip {
  margin-top: 0.8rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--cta) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--cta) 35%, transparent);
  font-size: 0.86rem;
  color: var(--muted);
}
.res-tip strong, .res-tip b { color: var(--text); }
.res-tip button {
  font: inherit; font-size: 0.82rem; font-weight: 700;
  margin-top: 0.45rem; display: block;
  background: var(--cta); color: var(--on-cta);
  border: 0; border-radius: 8px; padding: 0.35rem 0.8rem; cursor: pointer;
}
@media (max-width: 860px) {
  .res-tip { grid-area: tip; margin-top: 0.4rem; padding: 0.45rem 0.65rem; font-size: 0.78rem; }
  .res-tip button { display: inline-block; margin: 0 0 0 0.3rem; padding: 0.2rem 0.6rem; }
  .res-card { grid-template-areas: "label stats" "big stats" "sy sy" "warn warn" "tip tip" "empty empty"; }
}

/* click-to-play YouTube embeds on the calculator page */
.videos { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.yt { margin: 0; }
.yt.long { flex: 1 1 22rem; min-width: 0; max-width: 720px; }
.yt .yt-play, .yt iframe {
  display: block; width: 100%;
  border: 1px solid var(--divider); border-radius: 18px;
  background: #10191c; overflow: hidden;
  box-shadow: var(--shadow);
}
.yt.long .yt-play, .yt.long iframe { aspect-ratio: 16 / 9; }
.yt .yt-play { position: relative; padding: 0; cursor: pointer; }
.yt .yt-play img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.yt .yt-play:hover img { transform: scale(1.03); }
.yt-btn {
  position: absolute; left: 50%; top: 50%;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; background: rgba(0, 0, 0, 0.62);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.yt-btn::after {
  content: ""; position: absolute; left: 26px; top: 20px;
  border-style: solid; border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent #fff;
}
.yt-play:hover .yt-btn { background: var(--cta); }
.yt figcaption { margin-top: 0.6rem; font-weight: 700; font-size: 0.95rem; }
.yt figcaption span { display: block; color: var(--muted); font-weight: 500; font-size: 0.84rem; }
@media (prefers-reduced-motion: reduce) { .yt .yt-play img { transition: none; } }
