/* Reconstitution Calculator — dark lab theme, mobile-first */
:root {
  --bg: #0a101d;
  --bg-2: #0d1526;
  --panel: #111b2f;
  --panel-2: #15213a;
  --border: #1f2c47;
  --border-strong: #2a3a5c;
  --text: #e6edf7;
  --muted: #93a3bd;
  --faint: #5f6f8c;
  --accent: #2dd4bf;
  --accent-2: #22d3ee;
  --accent-ink: #04201d;
  --accent-soft: rgba(45, 212, 191, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .1);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, .1);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 40px -18px rgba(0,0,0,.7);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(34, 211, 238, .10), transparent 60%),
    radial-gradient(700px 420px at -10% 10%, rgba(45, 212, 191, .07), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* subtle lab grid */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148,163,184,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, #000, transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 70%);
  z-index: -1;
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 .75em; }
a { color: var(--accent-2); }
code { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); font-weight: 400; }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

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

/* RUO notice bar */
.ruo-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(45,212,191,.10), rgba(34,211,238,.06));
  border-bottom: 1px solid rgba(45,212,191,.25);
  color: #cdeee9;
  font-size: .875rem;
  text-align: left;
}
.ruo-bar p { margin: 0; }
.ruo-bar strong { color: var(--accent); }
.ruo-icon { width: 20px; height: 20px; flex: none; color: var(--accent); }

/* Header */
.site-header { padding: 28px 0 18px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 700;
  color: var(--accent); margin-bottom: 8px;
}
.site-header h1 {
  font-size: clamp(1.75rem, 6vw, 2.6rem);
  font-weight: 750;
  background: linear-gradient(90deg, #f1f6ff 30%, #9ff3e6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { color: var(--muted); max-width: 62ch; margin-top: 10px; font-size: 1rem; }

/* Layout */
.layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.info-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 16px; }

.card {
  background: linear-gradient(180deg, var(--panel), rgba(17,27,47,.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.05rem; font-weight: 650; margin-bottom: 14px;
}
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
  font-size: .78rem; font-weight: 700; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* Fields */
.field { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.field legend { font-weight: 600; font-size: .92rem; margin-bottom: 8px; padding: 0; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input[type="text"] {
  flex: 1 1 auto; min-width: 0;
  font: inherit; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  height: 48px;
  transition: border-color .15s, box-shadow .15s;
}
.input-row input[type="text"]:hover { border-color: #375080; }
.input-row input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.has-error input[type="text"] { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-soft); }
.suffix {
  display: inline-grid; place-items: center; padding: 0 14px; min-width: 56px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); font-weight: 600;
  background: var(--panel-2);
}
.field-error { color: var(--error); font-size: .85rem; margin: 6px 0 0; min-height: 0; }
.field-error:empty { display: none; }

/* Segmented controls (radio based) */
.segmented {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  flex: none;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented label {
  display: grid; place-items: center; min-width: 52px; padding: 0 12px; border-radius: 7px;
  font-weight: 600; font-size: .92rem; color: var(--muted); cursor: pointer; user-select: none;
  transition: background .15s, color .15s;
}
.segmented label:hover { color: var(--text); }
.segmented input:checked + label {
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.segmented input:focus-visible + label { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.segmented-wide { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
.segmented-wide label { padding: 8px 6px; line-height: 1.2; text-align: center; }
.segmented-wide label b { display: block; font-size: .98rem; }
.segmented-wide label small { display: block; font-size: .74rem; font-weight: 500; opacity: .8; }

/* Preset chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--muted); background: transparent;
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 6px 12px; min-height: 34px; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { color: var(--text); border-color: #3d5585; }
.chip[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn-ghost {
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted);
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; min-height: 38px; cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }

/* Results */
.summary {
  font-size: 1rem; color: var(--text);
  background: var(--accent-soft); border: 1px solid rgba(45,212,191,.28);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px;
}
.summary.is-empty { background: transparent; border-color: var(--border); color: var(--muted); }
.summary strong { color: var(--accent); font-variant-numeric: tabular-nums; }

.syringe-wrap {
  background: radial-gradient(120% 140% at 50% 0%, #13213b, #0c1424);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 6px 4px; margin-bottom: 12px;
}
.syringe { display: block; width: 100%; height: auto; }
.syringe .tick { stroke: #8fa3c4; }
.syringe .tick-major { stroke: #c9d6ea; }
.syringe .tick-label { fill: #a9b8d2; font: 600 11px var(--font); font-variant-numeric: tabular-nums; }
.syringe .cap-label { fill: #7486a6; font-size: 12px; letter-spacing: .04em; }
.syringe .fill-line { stroke: var(--accent); }
.syringe .fill-label { fill: var(--accent); font: 700 13px var(--font); }
.syringe.is-over .fill-line { stroke: var(--warn); }
.syringe.is-over .fill-label { fill: var(--warn); }
.syringe .fill-rect { transition: width .25s ease; }
.syringe .plunger { transition: transform .25s ease; }

.warnings { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.warnings:empty { display: none; }
.warnings li {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: .88rem; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); border: 1px solid rgba(251,191,36,.3); color: #fde7a8;
}
.warnings li.is-error { background: var(--error-soft); border-color: rgba(248,113,113,.35); color: #fecaca; }
.warnings li::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; font-size: .72rem; font-weight: 800; background: var(--warn); color: var(--bg); }
.warnings li.is-error::before { background: var(--error); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stat {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; min-width: 0;
}
.stat dt { font-size: .76rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat dt .muted { text-transform: none; letter-spacing: 0; color: var(--faint); }
.stat dd { margin: 4px 0 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .unit { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .sub { display: block; font-size: .82rem; color: var(--muted); font-weight: 500; margin-top: 2px; }
.stat-hero { background: linear-gradient(180deg, rgba(45,212,191,.08), rgba(13,21,38,1)); border-color: rgba(45,212,191,.25); }
.stat-hero .big { font-size: 1.75rem; color: #effffc; letter-spacing: -.02em; }
.results.is-over .stat-hero:first-child { border-color: rgba(251,191,36,.45); background: linear-gradient(180deg, rgba(251,191,36,.08), var(--bg-2)); }

.ref-table { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-2); }
.ref-table summary { cursor: pointer; padding: 10px 12px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.ref-table summary:hover { color: var(--text); }
.table-scroll { overflow-x: auto; padding: 0 12px 10px; max-height: 300px; overflow-y: auto; }
.ref-table table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.ref-table th, .ref-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.ref-table th:first-child, .ref-table td:first-child { text-align: left; }
.ref-table thead th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg-2); }
.ref-table tr.is-target td { color: var(--accent); font-weight: 700; }

/* Prose / info */
.prose h2 { font-size: 1.15rem; margin-bottom: 12px; }
.prose p { color: #c4cfe1; }
.formulas { list-style: none; counter-reset: f; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; }
.formulas li { counter-increment: f; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.formulas code { display: block; color: #bff7ee; margin-top: 3px; overflow-wrap: anywhere; }
.f-label { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); margin: 0; }
.f-label::before { content: counter(f) ". "; color: var(--accent); }
.example .f-label::before { content: ""; }
.example { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; }
.example p:last-child { margin-bottom: 0; }

.prose details { border-top: 1px solid var(--border); }
.prose details:last-of-type { border-bottom: 1px solid var(--border); }
.prose summary {
  cursor: pointer; list-style: none; padding: 12px 28px 12px 0; position: relative; font-weight: 600;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: "+"; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 1.2rem; font-weight: 500; transition: transform .2s;
}
.prose details[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.prose details p { padding-bottom: 6px; }

/* Footer */
.site-footer { margin-top: 28px; padding: 22px 0 36px; border-top: 1px solid var(--border); background: rgba(8,13,24,.6); }
.footer-ruo { font-size: .9rem; color: #c4cfe1; max-width: 80ch; }
.footer-ruo strong { color: var(--accent); }
.footer-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; font-size: .8rem; color: var(--faint); margin: 0; }
.supplier-link { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--faint); }
.supplier-link:hover { color: var(--accent); border-color: var(--accent); }

.noscript { text-align: center; color: var(--warn); padding: 12px; }

/* Larger screens */
@media (min-width: 560px) {
  .wrap { padding: 0 24px; }
  .card { padding: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .site-header { padding: 44px 0 26px; }
  .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
  .results { position: sticky; top: 16px; }
  .info-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr) ; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  body { background: #fff; color: #000; }
  body::before, .ruo-bar .ruo-icon, .form-actions, .chips, .skip-link { display: none; }
  .card { box-shadow: none; border-color: #999; background: #fff; }
}

/* Small screens: the syringe SVG is scaled down, so enlarge its text */
@media (max-width: 559px) {
  .syringe .tick-label { font-size: 17px; }
  .syringe .cap-label { font-size: 17px; }
  .syringe .fill-label { font-size: 21px; }
  .syringe-wrap { padding: 6px 2px 2px; }
}
