.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 1.2em;
  line-height: 1;
  vertical-align: -0.22em;
}

/* Palette shared with the rest of the Medecsta site — same values as
   DoseConverter/ui/styles.css so the two tools sit together. Site is
   light-only, so there is no dark-scheme block here. */
:root {
  --bg: #F0FDF4;
  --card: #FFFFFF;
  --ink: #1F2937;
  --ink-soft: #45525e; /* 8.5:1 on --card */
  --head: #14532D;
  --line: #BBF7D0;
  /* Input borders need 3:1 against white to read as a box (WCAG 1.4.11);
     the mint --line is decorative only and measures 1.2:1. */
  --field-line: #7C8794;
  /* The site's brand green is #16A34A, but white on it measures 3.3:1 - below
     the WCAG AA floor of 4.5:1 for the filled buttons, and tests/run-contrast.mjs
     fails the run on it. #15803D is the site's own accent-hover shade, so it
     stays in the Medecsta palette while measuring 5.0:1 against white. */
  --accent: #15803D;
  --accent-ink: #ffffff;
  --accent-text: var(--accent);
  --page: 1400px;
  --error: #8a1c1c;
  --focus: #0b5cd5;
  /* Everything above the tool window: body padding + nav + gap. The tool
     window takes the rest of the screen, so a calculator never needs the
     page to scroll on a desktop. */
  --chrome: 6.4rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0.75rem clamp(0.75rem, 3vw, 1.5rem) 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Public Sans", Arial, sans-serif;
}

/* Tools use the UI face for headings too (DESIGN.md: serif stays out of forms). */
h1, h2, h3 { font-family: inherit; }

a { color: var(--accent-text); }

/* Site chrome — nav markup and behaviour are copied from the other Medecsta
   pages verbatim (checkbox-hack burger); tests/site-audit.js asserts it on
   every crawled page. */
.site-nav {
  max-width: var(--page);
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px clamp(14px,4vw,24px);
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(20,83,45,0.08);
}

.site-nav .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.site-nav .brand img {
  width: clamp(32px,8vw,38px);
  height: clamp(28px,7vw,34px);
  object-fit: contain;
  border-radius: 10px;
  background: var(--bg);
}

.site-nav .brand span {
  font-weight: 700;
  font-size: clamp(17px,4.5vw,21px);
  color: var(--head);
  letter-spacing: 0.2px;
}

.nav-toggle { display: none; }

.nav-burger {
  display: none;
  cursor: pointer;
  font-size: clamp(20px,6vw,28px);
  line-height: 1;
  color: var(--head);
  user-select: none;
}

.site-nav ul { list-style: none; display: flex; gap: 28px; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav ul a { text-decoration: none; color: #374151; font-size: 15px; }
.site-nav ul a:hover { color: var(--head); }

.site-nav ul a.active {
  color: var(--head);
  font-weight: 600;
  border-bottom: 2px solid #4ADE80;
  padding-bottom: 4px;
}

@media (max-width: 768px) {
  .nav-burger { display: block !important; order: 2; }
  .site-nav .brand { order: 1; }
  .site-nav ul {
    display: none !important;
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    gap: 16px;
    padding: 12px;
    margin-top: 8px;
    background: var(--card);
    border-radius: 14px;
  }
  .nav-toggle:checked ~ ul { display: flex !important; }
}

/* ---------------------------------------------------------------- shell -- */

.shell {
  max-width: var(--page);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  gap: 0.9rem;
  height: calc(100vh - var(--chrome));
  height: calc(100dvh - var(--chrome));
  min-height: 30rem;
  padding-bottom: 0.75rem;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.55rem;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  color: var(--ink-soft);
}

.search:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.search input { flex: 1 1 auto; min-width: 0; border: 0; padding: 0.5rem 0; outline: none; background: transparent; }

kbd {
  font: 600 0.72rem/1 "Public Sans", Arial, sans-serif;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--field-line);
  border-radius: 5px;
  color: var(--ink-soft);
}

#catnav { flex: 1 1 auto; min-height: 0; overflow-y: auto; font-size: 0.87rem; }

.side-head {
  margin: 0.8rem 0 0.3rem;
  font-weight: 700;
  color: var(--head);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}

.side-head:first-child { margin-top: 0.2rem; }

#catnav a {
  display: block;
  padding: 0.28rem 0.45rem;
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
}

#catnav a:hover { background: var(--bg); color: var(--head); }

#catnav a[aria-current="page"] {
  background: var(--bg);
  color: var(--head);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-cat > summary {
  padding: 0.32rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
}

.side-cat > summary:hover { background: var(--bg); }
.side-cat[open] > summary { color: var(--head); }
.side-cat > a { padding-left: 1.7rem !important; font-size: 0.83rem; }

.side-foot { margin: 0; font-size: 0.78rem; color: var(--ink-soft); }

.workspace {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.ws-head { display: flex; align-items: center; gap: 0.8rem; }

/* Calculator pages: one centred column, like a dialog in a desktop app. */
.focus > * { width: 100%; max-width: 50rem; margin-inline: auto; }
.ws-head h1 { margin: 0; color: var(--head); font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.crumb { margin: 0; font-size: 0.8rem; }
.lede { margin: 0.1rem 0 0; color: var(--ink-soft); font-size: 0.9rem; max-width: 70ch; }

.cat-icon-lg {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 12px;
  background: var(--line);
  color: var(--head);
  font-size: 1.3rem;
}

.cat-icon-lg:empty { display: none; }

/* ------------------------------------------------------------ calculator -- */

.calc {
  width: 100%;
  max-width: 50rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.4rem 1.2rem;
  box-shadow: 0 1px 3px rgba(20,83,45,0.06);
}

.head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }

.calc h2 { margin: 0; color: var(--head); font-size: 1.2rem; font-weight: 700; }

button { cursor: pointer; }

.help, .copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--field-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.help:hover, .copy:hover { border-color: var(--accent); color: var(--head); }

.formula {
  margin: 0.25rem 0 0.9rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* minmax(0, max-content) stops one long label ("Molar extinction coefficient
   (M⁻¹cm⁻¹)") from widening the shared label column and squeezing every other
   row's controls onto a second line. */
.fields {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: 0.55rem 1rem;
  align-items: center;
}

.fields label { font-size: 0.9rem; color: var(--ink); }

.control { display: flex; flex-wrap: wrap; gap: 0.4rem; min-width: 0; }

input, select, button {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--field-line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  min-width: 0;
}

/* Longer option labels ("dsDNA (50 µg/mL)", "U (µmol/min)") ran under the
   dropdown caret. Reserve room for it. */
select { padding-right: 1.75rem; text-overflow: ellipsis; }

/* Same size for every value box (no flex-grow, so a row with no unit
   dropdown doesn't stretch full-width) but allowed to shrink so a narrow
   card doesn't overflow. */
.control input { flex: 0 1 11rem; min-width: 5rem; font-variant-numeric: tabular-nums; }
.control input[type="text"] { flex: 1 1 18rem; font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.04em; }
.control select, select.unit { flex: 0 1 8rem; min-width: 5.5rem; }

input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.calc-go {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 0.65rem 1.4rem;
  border-radius: 10px;
}

.calc-go:hover { filter: brightness(0.93); }

.readout { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }

.out-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.out-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; min-width: 0; }

.out-line input {
  flex: 1 1 9rem;
  min-width: 0;
  padding: 0.3rem 0.6rem;
  border-color: var(--line);
  background: var(--bg);
  color: var(--head);
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.out-line select.unit { flex: 0 0 7.5rem; }
.suffix { color: var(--ink-soft); font-size: 0.9rem; white-space: nowrap; }

.msg {
  margin: 0.6rem 0 0;
  min-height: 1.4em;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.msg.error { color: var(--error); font-weight: 600; }

/* ---------------------------------------------------------------- dialog -- */

dialog.help-dialog {
  max-width: 44rem;
  width: min(92vw, 44rem);
  max-height: 85vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.4rem 1.7rem 1.5rem;
  background: var(--card);
  color: var(--ink);
}

dialog.help-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }

.help-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

.help-body h3 { margin: 0 2rem 0.6rem 0; color: var(--head); font-size: 1.15rem; }
.help-inputs { margin: 0 0 0.8rem; padding-left: 1.2rem; color: var(--ink-soft); font-size: 0.9rem; }
.help-label { margin: 0.6rem 0 0.2rem; font-weight: 700; font-size: 0.85rem; }
.help-line { margin: 0 0 0.4rem; font-size: 0.9rem; }
.help-more { margin-top: 0.9rem; }

/* ---------------------------------------------------------- landing page -- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: 0.75rem;
}

.cat-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
}

.cat-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(20,83,45,0.08); }

.cat-icon {
  grid-row: 1 / span 3;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: var(--line);
  color: var(--head);
  font-size: 1.25rem;
  vertical-align: 0;
}

.cat-card h2 { margin: 0; font-size: 1rem; color: var(--head); }
.cat-card p { margin: 0.15rem 0 0.4rem; color: var(--ink-soft); font-size: 0.84rem; }
.cat-count { font-size: 0.76rem; color: var(--accent-text); font-weight: 700; }

.trust-line { margin: 0.25rem 0 0; font-size: 0.84rem; color: var(--ink-soft); }

/* ---------------------------------------------------------- methods page -- */

.doc {
  max-width: 60rem;
  padding: 1.2rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.doc h2 { margin: 1.4rem 0 0.4rem; color: var(--head); font-size: 1.1rem; }
.doc h2:first-child { margin-top: 0; }
.doc h3 { margin: 1rem 0 0.2rem; font-size: 0.95rem; }
.doc p, .doc li { font-size: 0.92rem; }
.doc .formula { margin: 0 0 0.3rem; }

/* ---------------------------------------------------------------- footer -- */

.site-footer {
  padding: clamp(24px,6vw,40px) clamp(16px,5vw,48px) clamp(16px,4vw,28px);
  margin: 0 calc(-1 * clamp(0.75rem, 3vw, 1.5rem));
  /* Solid colour under the gradient: it is what shows if the gradient fails,
     and it is what a contrast checker can actually resolve - a gradient only
     sets background-image, leaving background-color transparent, so without
     this every footer element measures against the page background instead. */
  background-color: #14532D;
  background-image: linear-gradient(160deg,#14532D 0%,#166534 100%);
  color: #DCFCE7;
  font-size: 0.8rem;
}

.site-footer p { margin: 0.75rem 0 0; max-width: 62ch; }

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(12px,3vw,24px);
}

.footer-brand { display: flex; align-items: center; gap: 12px; }

.footer-brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg);
}

.footer-brand span { font-weight: 600; font-size: 17px; color: #FFFFFF; }

.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: clamp(12px,3vw,24px); margin: 0; padding: 0; }
.site-footer a { color: #DCFCE7; text-decoration: none; font-size: 14px; }
.site-footer p a { text-decoration: underline; font-size: inherit; }
.site-footer a:hover { color: #FFFFFF; }

.site-footer .copyright {
  max-width: none;
  margin-top: clamp(12px,3vw,24px);
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  text-align: center;
  color: #86EFAC;
}

/* --------------------------------------------------------------- narrow -- */

/* Below tablet width the two panes stack: the calculator first, the tool
   list after it, and the page scrolls normally. */
@media (max-width: 900px) {
  .shell { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .workspace { order: 1; overflow: visible; }
  .side { order: 2; max-height: none; }
  #catnav { overflow: visible; }
  .site-nav { position: sticky; top: 0.5rem; z-index: 100; }
}

@media (max-width: 560px) {
  .fields { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .fields label { margin-top: 0.45rem; }
  .result { grid-template-columns: minmax(0, 1fr); }
  .calc-go { width: 100%; }
  .copy { justify-self: start; }
  .calc { padding: 1rem; }
  .head { flex-wrap: wrap; }
}

/* Short laptop screens (1366×768 leaves ~650 px of viewport): tighten the
   vertical rhythm so even the six-input calculators fit without scrolling. */
@media (min-width: 901px) and (max-height: 760px) {
  .ws-head .lede { display: none; }
  .workspace { gap: 0.5rem; }
  .calc { padding: 0.85rem 1.2rem 0.9rem; }
  .fields { gap: 0.35rem 1rem; }
  input, select { padding-top: 0.32rem; padding-bottom: 0.32rem; }
  .result { margin-top: 0.7rem; padding-top: 0.7rem; }
  .formula { margin-bottom: 0.6rem; }
  .msg { margin-top: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
