/* =========================================================================
   Peptide Dosage Reference — laboratory-label theme
   Mobile-first. Breakpoints widen the layout; nothing is desktop-only.
   ========================================================================= */

:root {
  /* Core palette — deep navy, warm gold, warm paper */
  --navy: #17273f;
  --navy-deep: #101c2e;
  --navy-soft: #2c3f5c;
  --gold: #a8834a;
  --gold-bright: #c4a06a;
  --gold-pale: #e8dcc6;

  /* Sampled from the label artwork: a neutral white plate, not a warm cream. */
  --paper: #f7f7f7;
  --plate: #ffffff;
  --surface: #efefef;
  --ink: #17273f;
  --ink-soft: #5f6a7a;
  --ink-faint: #8b95a3;
  --line: #e0dad0;
  --line-strong: #cbc2b4;

  --warn-bg: #fdf4e3;
  --warn-ink: #7a5a1e;
  --warn-line: #d9b978;
  --error: #9c2b2b;
  --error-bg: #fbf0f0;

  --radius: 4px;
  --radius-lg: 8px;

  --font-display: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 46rem;
  --pad: 1.1rem;

  /* The brand is a light plate. Declaring the scheme stops browsers on
     dark-mode devices auto-darkening form controls and scrollbars. */
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  position: relative;
}

/* ---------- Label artwork ---------------------------------------------
   The DNA helix and the molecular model are lifted from the source label
   (tools/make-decor-assets.ps1). Both are fixed rather than scrolling, so
   they read as printed-on stationery instead of tiling seams, and both sit
   behind everything and ignore pointer events.
   ---------------------------------------------------------------------- */

.decor {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

/* Helix down the left margin. Keyed to alpha, so CSS decides its colour.
   Mobile-first: narrow and faint here, opened up at wider breakpoints where
   there is margin to spare. */
.decor--dna {
  top: 0;
  left: 0;
  width: 42px;
  height: 100vh;
  background-color: var(--navy);
  opacity: .05;
  -webkit-mask-image: url('./icons/dna.png');
  mask-image: url('./icons/dna.png');
  -webkit-mask-repeat: repeat-y;
  mask-repeat: repeat-y;
  -webkit-mask-position: left top;
  mask-position: left top;
  -webkit-mask-size: 42px auto;
  mask-size: 42px auto;
}

/* Molecular model, upper right. It keeps the artwork's plate background, so
   its edges are feathered to blend into the page rather than showing a box. */
.decor--molecule {
  top: 3.2rem;
  right: 0;
  width: 130px;
  height: 268px;
  background-image: url('./icons/molecule.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: top right;
  opacity: .07;
  -webkit-mask-image: radial-gradient(ellipse 78% 78% at 68% 40%, #000 42%, transparent 78%);
  mask-image: radial-gradient(ellipse 78% 78% at 68% 40%, #000 42%, transparent 78%);
}

/* Content sits above the artwork. */
#app-header, #main, #app-footer { position: relative; z-index: 1; }

/* ---------- Typography ------------------------------------------------- */

h1, h2, h3 { line-height: 1.2; }

.skip-link {
  position: absolute; left: -9999px;
  background: var(--gold); color: #fff;
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
  font-size: .85rem; z-index: 200;
}
.skip-link:focus { left: 0; top: 0; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Uppercase letterspaced label, as used throughout the reference label. */
.eyebrow, .panel__title, .schedule thead th, .field label, .kv dt {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-weight: 600;
  color: var(--ink-faint);
}

/* ---------- Layout ----------------------------------------------------- */

#main {
  padding: 1.25rem var(--pad) 2.5rem;
  max-width: var(--wrap);
  margin: 0 auto;
  min-height: 60vh;
}

/* ---------- Header ----------------------------------------------------- */

/* The label's body is a light plate; only the utility band at its foot is
   navy. The header follows the plate, the footer follows the band. */
#app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(168, 131, 74, .35);
}

.nav {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: .6rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  color: var(--ink);
  min-height: 0;
}

.nav__mark { display: inline-flex; flex: 0 0 auto; }
.brand-mark { display: block; height: auto; }

/* The brand lockup: PURE in navy serif over the gold tagline, both widely
   letterspaced as in the artwork. The trailing letter of a letterspaced run
   carries trailing space, so the block is nudged left to stay optically
   centred under the mark. */
.nav__wordmark { display: flex; flex-direction: column; line-height: 1; }
.nav__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: .34em;
  text-indent: .34em;
  text-transform: uppercase;
  color: var(--navy);
}
.nav__tagline {
  font-size: .5rem;
  font-weight: 600;
  letter-spacing: .13em;
  text-indent: .13em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: .35rem;
  white-space: nowrap;
}

/* ---------- Hamburger toggle ------------------------------------------ */

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 46px;
  min-height: 46px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  flex: 0 0 auto;
}
.menu-toggle:hover { border-color: var(--gold); }
.menu-toggle__bar {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--navy);
  border-radius: 2px;
  transition: transform .18s ease, opacity .18s ease;
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Navigation drawer ----------------------------------------- */

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 28, 46, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.menu-backdrop.is-open { opacity: 1; pointer-events: auto; }

.menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(20rem, 86vw);
  background: var(--paper);
  border-left: 3px solid var(--gold);
  box-shadow: -8px 0 28px rgba(16, 28, 46, .18);
  transform: translateX(100%);
  transition: transform .22s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.1rem 2rem;
}
.menu.is-open { transform: translateX(0); }

.menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: .7rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--gold-pale);
}
.menu__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: .82rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
}
.menu__close {
  width: 44px;
  min-height: 44px;
  font-size: 1.6rem;
  line-height: 1;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  cursor: pointer;
}
.menu__close:hover { color: var(--navy); }

.menu__group { margin-top: 1.1rem; }
.menu__group-title {
  margin: 0 0 .35rem;
  font-size: .62rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.menu__link {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: .3rem .55rem;
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.menu__link:hover { background: var(--surface); border-left-color: var(--gold-pale); }
.menu__link.is-current {
  border-left-color: var(--gold);
  background: var(--surface);
  font-weight: 600;
  color: var(--navy);
}

.menu__foot {
  margin-top: 1.6rem;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
  font-size: .7rem;
  color: var(--ink-faint);
}

body.menu-open { overflow: hidden; }

/* ---------- Footer ----------------------------------------------------- */

#app-footer {
  background: var(--navy-deep);
  border-top: 3px solid var(--gold);
  margin-top: 3rem;
  padding: 1.4rem var(--pad);
}
#app-footer .disclaimer {
  max-width: var(--wrap);
  margin: 0 auto;
  color: rgba(255, 255, 255, .72);
  font-size: .76rem;
  text-align: center;
  line-height: 1.6;
}

/* ---------- Index ------------------------------------------------------ */

.view--index h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: .04em;
  margin: 0 0 .2rem;
}
.lede {
  color: var(--ink-soft);
  font-size: .84rem;
  margin: 0 0 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

#peptide-search {
  width: 100%;
  padding: .8rem .9rem;
  font-size: 16px; /* 16px prevents iOS zoom-on-focus */
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
#peptide-search:focus { border-color: var(--gold); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .8rem 0 .2rem;
}
.chip {
  padding: .42rem .7rem;
  font-family: inherit;
  font-size: .68rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  min-height: 36px;
}
.chip[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.result-count {
  font-size: .7rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: .9rem 0 .3rem;
}

.peptide-list { list-style: none; margin: 0; padding: 0; }

.peptide-row {
  display: grid;
  gap: .15rem;
  padding: .95rem .6rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
  transition: background .12s, border-left-color .12s;
}
.peptide-row:hover,
.peptide-row:focus-visible {
  background: var(--surface);
  border-left-color: var(--gold);
}
.peptide-row__name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .01em;
}
.peptide-row__full { font-size: .78rem; color: var(--ink-soft); }
.peptide-row__meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }

.tag {
  font-size: .62rem;
  padding: .2rem .45rem;
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 600;
}
.tag--quiet {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-pale);
  font-weight: 500;
}

.empty { padding: 2rem .6rem; color: var(--ink-soft); font-size: .9rem; }

/* ---------- Detail ----------------------------------------------------- */

.back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--gold);
  text-decoration: none;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  min-height: 0;
}
.back:hover { color: var(--navy); }

.detail-head { margin-bottom: 1.1rem; }
.detail-head h1 {
  margin: 0;
  font-size: clamp(1.9rem, 8vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -.02em;
  text-transform: uppercase;
  color: var(--navy);
  line-height: 1.02;
}
.detail-head__full {
  margin: .5rem 0 0;
  padding-top: .55rem;
  border-top: 1px solid var(--gold-pale);
  color: var(--gold);
  font-size: .74rem;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.detail-head .peptide-row__meta { margin-top: .7rem; }

.description {
  font-size: .93rem;
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
}

/* The label's spec table: ruled label/value rows. */
.spec { margin: 0 0 1.4rem; border-top: 1px solid var(--line); }
.spec__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: .1rem;
  padding: .6rem .2rem;
  border-bottom: 1px solid var(--line);
}
.spec__key {
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-weight: 600;
  color: var(--ink-faint);
}
.spec__val { font-size: .9rem; font-weight: 600; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  padding: 1rem;
  margin-top: 1rem;
}
.panel__title {
  margin: 0 0 .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--gold-pale);
  color: var(--gold);
}

/* Wide content scrolls inside its own box; the page body never does. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.schedule {
  width: 100%;
  min-width: 17rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.schedule th, .schedule td {
  text-align: left;
  padding: .55rem .3rem;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.schedule tbody tr:last-child th,
.schedule tbody tr:last-child td { border-bottom: 0; }
.schedule tbody th { font-weight: 600; color: var(--ink-soft); }
.schedule thead th { border-bottom: 1px solid var(--line-strong); }
.schedule .num {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.frequency { font-size: .88rem; margin: .8rem 0 0; }
.hint { font-size: .78rem; color: var(--ink-soft); line-height: 1.55; }

.kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: .15rem;
  margin: 0;
  font-size: .9rem;
}
.kv dt { margin-top: .55rem; }
.kv dt:first-child { margin-top: 0; }
.kv dd {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--navy);
}

.note {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid var(--warn-line);
  border-left-width: 3px;
  padding: .7rem .85rem;
  font-size: .82rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0;
}
.note p { margin: .2rem 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
  padding: .8rem 1.2rem;
  width: 100%;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  border: 0;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
}
.button:hover, .button:focus-visible { background: var(--gold); }

.components { margin: 0; padding-left: 1.1rem; font-size: .9rem; }
.components li { margin-bottom: .3rem; }

.detail-foot {
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.disclaimer { font-size: .76rem; color: var(--ink-soft); margin: 0 0 .4rem; }
.detail-foot .hint { margin: 0; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Calculator ------------------------------------------------- */

.view--calculator h1, .view--about h1, .view--install h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: .03em;
  margin: 0 0 1.2rem;
  padding-bottom: .7rem;
  border-bottom: 2px solid var(--gold);
}

.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
.field input, .field select {
  padding: .75rem .8rem;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.field .hint { margin-top: .1rem; }

.calc-output {
  margin-top: 1.5rem;
  padding: 1.1rem;
  background: var(--navy);
  border-radius: var(--radius-lg);
  color: #fff;
}
.calc-headline {
  margin: 0 0 1rem;
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1.1;
}
.calc-headline .hint { color: rgba(255, 255, 255, .6); font-size: .78rem; display: block; }

.calc-output .kv dt { color: rgba(255, 255, 255, .55); }
.calc-output .kv dd { color: #fff; }
.calc-output .note {
  background: rgba(196, 160, 106, .12);
  border-color: rgba(196, 160, 106, .4);
  color: var(--gold-pale);
}

.syringe { margin: 0 0 1.2rem; }
.syringe__barrel {
  height: 30px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-radius: 3px;
  background: rgba(0, 0, 0, .22);
  overflow: hidden;
}
.syringe__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width .15s ease-out;
}
.syringe__scale {
  display: flex;
  justify-content: space-between;
  font-size: .66rem;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, .55);
  margin-top: .3rem;
}

.errors {
  margin: 0;
  padding: .8rem .8rem .8rem 2rem;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  font-size: .88rem;
}
.calc-output .errors { background: rgba(156, 43, 43, .18); color: #ffbcbc; border-color: rgba(255, 140, 140, .5); }

/* ---------- Gate ------------------------------------------------------- */

.gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--paper);
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 0 var(--pad) 2rem;
}
.gate__panel {
  max-width: 34rem;
  width: 100%;
  padding: 2rem 0;
}
.gate__mark {
  display: block;
  color: var(--gold);
  margin-bottom: 1.2rem;
}
.gate__mark svg { display: block; }

.gate__panel h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: .03em;
  margin: 0 0 .8rem;
  padding-bottom: .7rem;
  border-bottom: 2px solid var(--gold);
}
.gate__panel > p { font-size: .95rem; }
.gate__panel ul {
  font-size: .87rem;
  color: var(--ink-soft);
  padding-left: 1.1rem;
  margin: 1rem 0 1.5rem;
}
.gate__panel li { margin-bottom: .55rem; }

/* ---------- About / Install ------------------------------------------- */

.view--about h2, .view--install h2 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--gold);
  margin: 1.8rem 0 .5rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--gold-pale);
}
.view--about p, .view--install p { font-size: .89rem; }
.view--about ul, .view--install ul { font-size: .89rem; padding-left: 1.1rem; }
.view--about li, .view--install li { margin-bottom: .35rem; }

.steps { padding-left: 1.3rem; font-size: .89rem; }
.steps li { margin-bottom: .6rem; }

/* ---------- Offline indicator ----------------------------------------- */

body.is-offline #app-header::after {
  content: "Offline — showing saved data";
  display: block;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--gold-bright);
  padding: .35rem .5rem;
  text-align: center;
  font-weight: 600;
}

/* =========================================================================
   Breakpoints — the layout widens; nothing is hidden on small screens.
   ========================================================================= */

@media (min-width: 34rem) {
  :root { --pad: 1.5rem; }

  .nav__title { font-size: 1.15rem; }

  .decor--molecule { width: 170px; height: 350px; opacity: .10; }
  .decor--dna {
    width: 70px;
    -webkit-mask-size: 70px auto;
    mask-size: 70px auto;
  }

  .spec__row {
    grid-template-columns: 12rem 1fr;
    gap: 1rem;
    align-items: baseline;
  }
  .kv { grid-template-columns: 12rem 1fr; gap: .45rem 1rem; align-items: baseline; }
  .kv dt { margin-top: 0; }

  .button { width: auto; }
  .peptide-row { padding: 1rem .7rem; }
  .panel { padding: 1.35rem; }
  .calc-output { padding: 1.5rem; }
  .calc-headline { font-size: 2.3rem; }
}

@media (min-width: 52rem) {
  .detail-head h1 { font-size: 3.1rem; }
  #main { padding-top: 2rem; }

  /* Wide enough that the artwork clears the text column entirely. */
  .decor--molecule { width: 214px; height: 440px; opacity: .2; }
  .decor--dna { opacity: .085; }

  /* Calculator inputs pair up once there is room. */
  .calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
  .calc-grid .field--wide { grid-column: 1 / -1; }
}

/* =========================================================================
   No dark theme, deliberately.

   The brand is a light plate with gold and navy on it; inverting it makes
   the app read as a different product and turns the page navy. `color-scheme:
   light` on :root stops browsers auto-darkening form controls on devices set
   to dark, which was the actual cause of the page appearing blue.
   ========================================================================= */

/* =========================================================================
   Accessibility and print
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  #app-header, #app-footer, .back, .button, .chips, #peptide-search { display: none; }
  body { background: #fff; }
  .panel { border-color: #999; break-inside: avoid; }
}
