/* =========================================================================
   ECG-Age — design system
   "Clinical paper meets research lab." Teal = science/chrome, coral = the
   heartbeat & warnings. Faint ECG graph-paper texture as background.
   ========================================================================= */

:root {
  /* palette */
  --ink: #0f1e2e; /* deep slate-navy text                */
  --ink-soft: #2a3b4a;
  --muted: #5b6b79; /* secondary text, labels              */
  --surface: #fbfcfd; /* page background                     */
  --surface-strong: #fbfcfc;
  --card: #ffffff;
  --white: #ffffff;
  --paper: #f7f5f0;
  --hairline: #e4eaee; /* borders, dividers                   */
  --paper-pink: #e9b8b8; /* ECG-paper grid, used at low opacity */
  --hairline-strong: #c8d8e0;
  --hairline-input: #d8e2e8;
  --hairline-hover: #b8c8d2;
  --hairline-ghost: #c5d2da;
  --hairline-deep: #b5c4cd;
  --hairline-coral: #f1c7c8;

  --teal: #2c8fb3; /* primary — links, CTAs               */
  --teal-deep: #1c6b8a; /* hovers, heading accents             */
  --teal-deeper: #165e7a;
  --teal-ink: #114b62;
  --teal-muted: #5e8ea1;
  --teal-wash: #ecf5f8; /* tinted fills                        */
  --teal-wash-soft: #edf5f9;
  --teal-wash-muted: #f5f9fb;
  --teal-wash-hover: #d5eaf3;
  --teal-wash-open: #daeef5;
  --lab-teal: #3e9db9; /* the lab nav-bar blue — institutional cue */

  --coral: #e5484d; /* the ECG trace + abnormal flags      */
  --coral-wash: #fceded;
  --good: #2fa36a; /* within expected range               */
  --good-wash: #eaf6f0;
  --amber: #c98a12; /* quality warnings                    */
  --amber-wash: #fbf3e2;
  --amber-ink: #6b4a08;
  --vermillion: #d55e00;
  --sky: #56b4e9;
  --good-deep: #1f7c50;
  --muted-faint: #9aa6b0;

  /* type */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display:
    "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-num: "Inter", ui-monospace, "SF Mono", monospace;

  /* shape */
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(15, 30, 46, 0.04), 0 8px 30px rgba(15, 30, 46, 0.06);
  --shadow-panel:
    0 1px 2px rgba(15, 30, 46, 0.03), 0 6px 18px rgba(15, 30, 46, 0.04);
  --shadow-btn: 0 1px 0 rgba(15, 30, 46, 0.08);
  --focus-ring: 0 0 0 3px rgba(44, 143, 179, 0.12);
  --focus-ring-coral: 0 0 0 3px rgba(229, 72, 77, 0.15);

  --maxw: 960px;
}

/* --- reset ------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--surface);
  /* faint ECG graph paper — two grids (fine + bold), dialed way down */
  background-image:
    linear-gradient(var(--paper-pink) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-pink) 1px, transparent 1px),
    linear-gradient(var(--paper-pink) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-pink) 1px, transparent 1px);
  background-size:
    80px 80px,
    80px 80px,
    16px 16px,
    16px 16px;
  background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* tone the grid down so it reads as texture, not decoration */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--surface);
  opacity: 0.92;
  z-index: -1;
  pointer-events: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}
a {
  color: var(--teal-deep);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
.dropzone:focus-within {
  outline: none;
  box-shadow: var(--focus-ring);
}
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.025em;
}
p {
  margin: 0 0 1rem;
}

/* --- layout ------------------------------------------------------------ */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}
.section {
  padding-block: clamp(56px, 9vw, 104px);
}
.section--tight {
  padding-block: clamp(40px, 6vw, 64px);
}
.eyebrow {
  color: var(--teal-deep);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin-bottom: 14px;
  text-transform: uppercase;
}

/* =======================================================================
   Top bar
   ======================================================================= */
.topbar {
  background: rgba(251, 252, 253, 0.78);
  /* institutional accent strip — echoes the lab's teal nav bar */
  border-top: 3px solid var(--lab-teal);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__inner {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 64px;
  padding-block: 10px;
}
.brand {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.brand__text {
  color: var(--muted);
  font-weight: 500;
}
.brand__text strong {
  color: var(--teal-deep);
  font-weight: 650;
}
.group-logo {
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  margin-left: auto;
}
.group-logo img {
  display: block;
  height: 34px;
  object-fit: contain;
  width: auto;
}
.lab-credit {
  color: var(--muted);
  font-size: 13.5px;
}
.lab-credit a {
  color: var(--muted);
}
.lab-credit a:hover {
  color: var(--teal-deep);
}

/* =======================================================================
   Hero
   ======================================================================= */
.hero {
  padding-bottom: 0;
  padding-top: clamp(56px, 10vw, 96px);
  position: relative;
}
.hero h1 {
  font-size: clamp(38px, 7vw, 68px);
  letter-spacing: -0.04em;
  max-width: 14ch;
}
.hero .lede {
  font-size: clamp(17px, 2.2vw, 20px);
  color: var(--muted);
  max-width: 52ch;
}
.hero__aside {
  display: flex;
  justify-content: flex-end;
}
.hero__citation {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
  max-width: 54ch;
}
.hero__content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.hero__cta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
}
.hero__grid {
  align-items: start;
  display: grid;
  gap: clamp(28px, 4vw, 52px);
  grid-template-columns: minmax(0, 1.45fr) minmax(17rem, 0.85fr);
}
.hero__kicker {
  color: var(--teal-deep);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.14em;
  margin: 0;
  text-transform: uppercase;
}
.hero__lede {
  margin: 0;
}
.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hero__meta-item {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--hairline-deep);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 12px;
  padding: 4px 10px;
}

.report-preview {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96),
    rgba(247, 245, 240, 0.96)
  );
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  max-width: 21rem;
  padding: 20px;
  position: relative;
}
.report-preview::before {
  background: linear-gradient(90deg, var(--lab-teal), transparent 72%);
  content: "";
  height: 3px;
  left: 20px;
  position: absolute;
  right: 20px;
  top: 0;
}
.report-preview__foot {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 16px 0 0;
}
.report-preview__label {
  color: var(--teal-deep);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0;
  text-transform: uppercase;
}
.report-preview__list {
  margin: 18px 0 0;
}
.report-preview__metric {
  align-items: baseline;
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.report-preview__row {
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-soft);
  display: flex;
  font-size: 13px;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 0;
}
.report-preview__row:last-child {
  border-bottom: none;
}
.report-preview__row dd,
.report-preview__row dt {
  margin: 0;
}
.report-preview__unit {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}
.report-preview__value {
  color: var(--ink);
  font-family: var(--font-num);
  font-size: clamp(38px, 5vw, 52px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.04em;
}

/* the signature: ECG trace drawing itself across the page */
.trace {
  margin-top: clamp(36px, 7vw, 72px);
  position: relative;
}
.trace svg {
  height: clamp(90px, 14vw, 150px);
  overflow: visible;
  width: 100%;
}
.trace__line {
  animation: draw 5.5s cubic-bezier(0.7, 0, 0.3, 1) infinite;
  fill: none;
  filter: drop-shadow(0 2px 6px rgba(229, 72, 77, 0.16));
  stroke: var(--coral);
  stroke-dasharray: 2600;
  stroke-dashoffset: 2600;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25;
}
.trace__base {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 1.25;
}
@keyframes draw {
  0% {
    stroke-dashoffset: 2600;
  }
  55% {
    stroke-dashoffset: 0;
  }
  85% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .trace__line {
    animation: none;
    stroke-dashoffset: 0;
  }
}

/* =======================================================================
   The idea
   ======================================================================= */
.eyebrow--compact {
  margin-bottom: 10px;
}
.idea h2 {
  font-size: clamp(26px, 4vw, 36px);
  max-width: 20ch;
}
.idea__intro {
  color: var(--ink-soft);
  font-size: clamp(17px, 2vw, 19px);
  max-width: 62ch;
}
.idea__intro--offset {
  margin-top: -0.25rem;
}
.idea__cite {
  border-left: 3px solid var(--teal);
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  padding: 4px 0 4px 16px;
}

/* pipeline figure */
.pipeline {
  margin: 44px 0 0;
}
.pipeline__frame {
  overflow: hidden;
  border-radius: var(--radius);
}
.pipeline img {
  display: block;
  height: auto;
  width: 100%;
}
.pipeline figcaption {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 14px;
  text-align: center;
}

/* =======================================================================
   The tool
   ======================================================================= */
.tool {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.9),
    rgba(236, 245, 248, 0.95) 240%
  );
}
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  padding: clamp(24px, 4vw, 40px);
  position: relative;
}
.card::after,
.result-card::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(44, 143, 179, 0.06);
  border-radius: calc(var(--radius) - 6px);
  pointer-events: none;
}
.card__head {
  margin-bottom: 18px;
}
.card__head h2 {
  font-size: clamp(22px, 3vw, 28px);
}
.card__sub {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 6px 0 0;
}
.card__disclaimer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 0;
}
.card__disclaimer svg {
  flex-shrink: 0;
  color: var(--muted);
}

.protocol {
  border-bottom: 1px solid rgba(44, 143, 179, 0.18);
  border-top: 1px solid rgba(44, 143, 179, 0.18);
  display: grid;
  gap: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}
.protocol__index {
  color: var(--teal-ink);
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 650;
}
.protocol__step {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 14px 12px;
}
.protocol__step + .protocol__step {
  border-left: 1px solid rgba(44, 143, 179, 0.14);
}
.protocol__text {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

/* result card — lives below the form card, appears on htmx swap */
.analysis-slot:empty {
  display: none;
}
/* clinical research-report surface: off-white, faint grid, no accent border */
.result-card {
  position: relative;
  margin-top: 20px;
  background: linear-gradient(
    180deg,
    rgba(251, 252, 252, 0.98),
    rgba(247, 245, 240, 0.82)
  );
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: none;
  padding: clamp(24px, 4vw, 40px);
  animation: result-enter 0.35s cubic-bezier(0.2, 0, 0.2, 1) both;
  background-image:
    linear-gradient(rgba(15, 30, 46, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 30, 46, 0.025) 1px, transparent 1px);
  background-size: 17px 17px;
}
.result-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hairline);
}
.result-card__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-card__label::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(44, 143, 179, 0.2);
}
.result-card__status {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
@keyframes result-enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* report sections + dividers */
.report-section__title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-deep);
  margin-bottom: 12px;
}
.report-divider {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 26px 0;
}

/* report table (reference values) */
.report-table {
  flex: 0 0 auto;
  min-width: 250px;
}
.report-table__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.report-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline-deep);
  font-size: 13.5px;
}
.report-row:last-child {
  border-bottom: none;
}
.report-row__label {
  color: var(--muted);
}
.report-row__val {
  font-family: var(--font-num);
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.report-row__val--normal {
  color: var(--good-deep);
}
.report-row__val--mild {
  color: var(--amber-ink);
}
.report-row__val--elevated {
  color: var(--vermillion);
}
.report-row__val--muted {
  color: var(--muted);
  font-weight: 500;
}

/* interpretation summary rows — calm, thin left severity border */
.interp {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.interp-row {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 12px 0 12px 15px;
  border-left: 3px solid var(--hairline);
}
.interp-row--amber {
  border-left-color: var(--amber);
}
.interp-row--plain {
  border-left-color: var(--hairline-deep);
}
.interp-row--attention {
  border-left-color: var(--amber);
}
.interp-row--flagged {
  border-left-color: var(--vermillion);
}
.interp-row--normal {
  border-left-color: var(--good);
}
.interp-row--technical {
  border-left-color: var(--sky);
}
.interp-row--good {
  border-left-color: var(--good);
}
.interp-row__title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.interp-row__body {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.status-chip {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-chip--amber {
  background: var(--amber-wash);
  color: var(--amber);
}
.status-chip--plain {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
}
.status-chip--attention {
  background: var(--amber-wash);
  color: var(--amber-ink);
}
.status-chip--flagged {
  background: var(--coral-wash);
  color: var(--vermillion);
}
.status-chip--normal {
  background: var(--good-wash);
  color: var(--good-deep);
}
.status-chip--technical {
  background: rgba(86, 180, 233, 0.14);
  color: var(--teal-ink);
}
.status-chip--good {
  background: var(--good-wash);
  color: var(--good);
}

/* shared input group — one border wraps dropzone + disclosure */
.input-group {
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.input-group:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(44, 143, 179, 0.1);
}

/* dropzone — upper zone, white, dashed interior feel via padding only */
.dropzone {
  display: block;
  position: relative;
  background: var(--white);
  border: none;
  border-bottom: 1.5px dashed var(--hairline-deep);
  border-radius: 0;
  padding: 26px 24px;
  text-align: left;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  cursor: pointer;
}
.dropzone:hover,
.dropzone.is-drag {
  background: var(--teal-wash);
  border-color: rgba(44, 143, 179, 0.35);
}
.dropzone.is-error {
  background: var(--coral-wash);
  border-color: rgba(229, 72, 77, 0.45);
}
.dropzone.has-file {
  background: var(--teal-wash);
  border-color: rgba(44, 143, 179, 0.4);
  cursor: pointer;
}

/* idle vs selected states — both horizontal, left-aligned */
.dropzone__idle {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  min-height: 8.5rem;
  text-align: center;
}
.dropzone.has-file .dropzone__idle {
  display: none;
}
.dropzone__idle-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dropzone__heading {
  font-size: 16px;
  color: var(--ink);
}
.dropzone__selected {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}
.dropzone.has-file .dropzone__selected {
  display: flex;
}

.dropzone__cta {
  color: var(--teal-deep);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dropzone__file-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}
.dropzone__file-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--teal-deep);
}
.dropzone__file-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.dropzone__filename {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}
.dropzone__filesize {
  font-size: 13px;
  color: var(--muted);
}
.dropzone__replace {
  font-size: 12.5px;
  color: var(--teal-deep);
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.8;
}

/* privacy note — sits between dropzone and disclosure, inside the group */
.privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--teal-wash-muted);
  border-top: 1px solid rgba(44, 143, 179, 0.12);
  border-bottom: 1px solid rgba(44, 143, 179, 0.12);
}
.privacy-note svg {
  flex-shrink: 0;
  color: var(--teal);
}

/* sample shortcuts — try the tool with a known ECG (precomputed result) */
.samples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 18px;
  background: var(--white);
  border-bottom: 1px solid rgba(44, 143, 179, 0.12);
}
.samples__label {
  font-size: 12.5px;
  color: var(--muted);
}
.samples__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sample-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--teal-deep);
  background: var(--teal-wash);
  border: 1px solid rgba(44, 143, 179, 0.25);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.sample-btn:hover {
  background: var(--teal-wash-hover);
  border-color: rgba(44, 143, 179, 0.45);
  color: var(--teal-deeper);
}
.sample-btn:active {
  background: var(--teal-wash-open);
}
.sample-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.sample-btn:disabled:hover {
  background: var(--teal-wash);
  border-color: rgba(44, 143, 179, 0.25);
  color: var(--teal-deep);
}
.sample-btn svg {
  flex-shrink: 0;
  color: var(--teal);
}

.intake-footer {
  align-items: center;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92),
    rgba(245, 249, 251, 0.98)
  );
  border-top: 1px solid rgba(44, 143, 179, 0.12);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 18px;
}

/* actions status text */
.actions__status {
  color: var(--muted);
  flex: 1;
  font-size: 13px;
}

/* disabled submit button */
.btn-submit:disabled {
  background: var(--hairline-strong);
  color: var(--white);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-submit:disabled:hover {
  background: var(--hairline-strong);
  box-shadow: none;
}
.dropzone__error {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 550;
  color: var(--coral);
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}
.dropzone__error:empty {
  margin-top: 0;
}
.dropzone__error:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  background: var(--coral);
  border-radius: 50%;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E")
    center/14px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E")
    center/14px no-repeat;
  background-color: var(--coral);
}
/* Visually-hidden input: clips the native file-input chrome (incl. WebKit's
   shadow-DOM "drop files here" UI) to a 1px box. The <label> wrapper still
   opens the dialog on click; drag-drop is forwarded to it in JS. */
.dropzone__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.dropzone__icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  color: var(--teal);
}
.dropzone__icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}
.dropzone__emphasis {
  color: var(--ink);
  font-weight: 700;
}
.dropzone__hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* optional context disclosure */
.disclosure {
  margin-top: 0;
}
.disclosure > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 18px;
  /* slightly deeper teal-wash than the white dropzone — shows depth in the same family */
  background: var(--teal-wash);
  border: none;
  border-radius: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--teal-deep);
  transition: background 0.15s ease;
}
.disclosure > summary:hover {
  background: var(--teal-wash-hover);
}
.disclosure > summary::-webkit-details-marker {
  display: none;
}
.disclosure > summary .chev {
  transition: transform 0.2s ease;
  color: var(--teal);
  flex-shrink: 0;
}
.disclosure[open] > summary {
  background: var(--teal-wash-open);
  border-bottom: 1px solid var(--hairline-strong);
}
.disclosure[open] > summary .chev {
  transform: rotate(90deg);
}
.summary-sub {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}
.field__sub {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

/* fields panel — same tint family, slightly richer */
.fields-panel {
  background: var(--teal-wash-soft);
  border: none;
  border-radius: 0;
  padding: 20px 18px;
}
.fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field select {
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  height: 42px;
  padding: 0 13px;
  border: 1.5px solid var(--hairline-input);
  border-radius: var(--radius-xs);
  background: var(--white);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-appearance: none;
}
.field input:hover,
.field select:hover {
  border-color: var(--hairline-hover);
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}
.field input::placeholder {
  color: var(--hairline-hover);
}

/* error state */
.field__error {
  font-size: 12px;
  color: var(--coral);
  font-weight: 500;
  min-height: 16px;
  display: block;
}
.field--error input {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.1);
}
.field--error input:focus {
  border-color: var(--coral);
  box-shadow: var(--focus-ring-coral);
}
/* custom select chevron — no native arrow */
.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235B6B79' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.field select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231C6B8A' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* actions row: hint left, button right */
.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}
/* submit button — uses card's radius, not a pill, so it reads as a form action */
.btn-submit {
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  height: 42px;
  background: var(--teal-ink);
  color: var(--white);
  border: 1px solid rgba(17, 75, 98, 0.92);
  border-radius: var(--radius-xs);
  cursor: pointer;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow-btn);
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.08s ease;
}
.btn-submit:hover {
  background: var(--teal-deeper);
  box-shadow: var(--shadow-btn);
}
.btn-submit:active {
  transform: translateY(1px);
}
.btn-submit[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
/* spinner: hidden by default, shown during request */
.btn-spin {
  display: none;
}
/* htmx-request is added to the <form> (the requesting element), not the button */
.analyze-form.htmx-request .btn-spin {
  display: inline-block;
}
.actions__progress {
  flex: 1;
  height: 6px;
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--hairline);
  overflow: hidden;
}
.actions__progress::-webkit-progress-bar {
  background: var(--hairline);
  border-radius: 999px;
}
.actions__progress::-webkit-progress-value {
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.actions__progress::-moz-progress-bar {
  background: var(--teal);
  border-radius: 999px;
}

/* =======================================================================
   Buttons
   ======================================================================= */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 0.08s ease,
    background 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn:active {
  transform: translateY(1px);
}
.btn svg {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.btn:hover svg {
  transform: translateX(2px);
}
.btn-primary {
  background: var(--teal-ink);
  color: var(--white);
  border-color: rgba(17, 75, 98, 0.95);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
  background: var(--teal-deeper);
  text-decoration: none;
  box-shadow: var(--shadow-btn);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-soft);
  border-color: var(--hairline-deep);
}
.btn-ghost:hover {
  border-color: var(--teal-deep);
  background: var(--surface);
  text-decoration: none;
}
.btn-stop {
  background: var(--white);
  color: var(--coral);
  border-color: var(--hairline-coral);
}
.btn-stop:hover {
  background: var(--coral-wash);
  text-decoration: none;
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =======================================================================
   Processing state
   ======================================================================= */
.processing {
  text-align: center;
  padding: 30px 10px;
}
.processing__pulse {
  width: 100%;
  max-width: 420px;
  margin: 0 auto 18px;
  height: 54px;
}
.processing__pulse svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.processing__pulse path {
  fill: none;
  stroke: var(--coral);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: scan 1.4s linear infinite;
}
@keyframes scan {
  to {
    stroke-dashoffset: -600;
  }
}
.processing h3 {
  font-size: 19px;
}
.processing p {
  color: var(--muted);
  font-size: 14.5px;
}
.processing progress {
  width: min(420px, 100%);
  height: 6px;
  margin-top: 10px;
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--hairline);
  overflow: hidden;
}
.processing progress::-webkit-progress-bar {
  background: var(--hairline);
  border-radius: 999px;
}
.processing progress::-webkit-progress-value {
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.processing progress::-moz-progress-bar {
  background: var(--teal);
  border-radius: 999px;
}

/* =======================================================================
   Result panel
   ======================================================================= */
.result {
  margin-top: 0;
}

/* age block — big estimate on the left, reference table on the right */
.age-block {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.age-block__main {
  flex: 1;
  min-width: 220px;
}
.bioage__num {
  font-family: var(--font-num);
  font-weight: 700;
  letter-spacing: -0.04em;
  font-size: clamp(44px, 9vw, 70px);
  line-height: 0.95;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.bioage__num .unit {
  font-size: 0.34em;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 6px;
}
.bioage__explain {
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
  max-width: 40ch;
  line-height: 1.55;
}

/* sub-sections */
.result__grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 30px;
  margin-top: 28px;
}
.result h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.result__section-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 14px;
}

/* digitized ECG trace — server-rendered inline SVG polylines on ECG paper */
.ecgwave {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--hairline-coral);
  border-radius: var(--radius-sm);
  /* faint ECG-paper grid: 1mm fine lines, 5mm bold lines */
  background-color: #fffafa;
  background-image:
    linear-gradient(rgba(229, 72, 77, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(229, 72, 77, 0.28) 1px, transparent 1px),
    linear-gradient(rgba(229, 72, 77, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(229, 72, 77, 0.1) 1px, transparent 1px);
  background-size:
    25px 25px,
    25px 25px,
    5px 5px,
    5px 5px;
}
.ecgwave__row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ecgwave__label {
  flex: 0 0 2.6rem;
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ecgwave__trace {
  flex: 1;
  height: 46px;
  display: block;
  min-width: 0;
}
.ecgwave__trace polyline {
  fill: none;
  stroke: var(--coral);
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
  /* keep the line crisp despite the non-uniform viewBox stretch */
  vector-effect: non-scaling-stroke;
}

@media (max-width: 560px) {
  .ecgwave__trace {
    height: 38px;
  }
  .ecgwave__label {
    flex-basis: 2.1rem;
  }
}

/* condition/pattern bars */
.conditions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cond {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
}
.cond__name {
  font-size: 14px;
  color: var(--ink-soft);
}
.cond__pct {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cond__bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 999px;
  background: var(--hairline);
  overflow: hidden;
}
.meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
.meter-fill::-webkit-progress-bar {
  background: transparent;
  border-radius: 999px;
}
.meter-fill::-webkit-progress-value {
  background: var(--teal-muted);
  border-radius: 999px;
}
.meter-fill::-moz-progress-bar {
  background: var(--teal-muted);
  border-radius: 999px;
}
.cond--neutral .meter-fill::-webkit-progress-value,
.cond--technical .meter-fill::-webkit-progress-value {
  background: var(--sky);
}
.cond--neutral .meter-fill::-moz-progress-bar,
.cond--technical .meter-fill::-moz-progress-bar {
  background: var(--sky);
}
.cond--neutral .cond__pct,
.cond--technical .cond__pct {
  color: var(--teal-ink);
}
.cond--attention .meter-fill::-webkit-progress-value {
  background: var(--amber);
}
.cond--attention .meter-fill::-moz-progress-bar {
  background: var(--amber);
}
.cond--attention .cond__pct {
  color: var(--amber-ink);
}
.cond--flagged .meter-fill::-webkit-progress-value {
  background: var(--vermillion);
}
.cond--flagged .meter-fill::-moz-progress-bar {
  background: var(--vermillion);
}
.cond--flagged .cond__pct {
  color: var(--vermillion);
}
.cond--normal .meter-fill::-webkit-progress-value {
  background: var(--good);
}
.cond--normal .meter-fill::-moz-progress-bar {
  background: var(--good);
}
.cond--normal .cond__pct {
  color: var(--good-deep);
}

/* gauges */
.gauges {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gauge__top {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.gauge__name {
  font-size: 13.5px;
  color: var(--ink-soft);
  flex: 1;
}
.gauge__label {
  font-size: 12px;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
}
.gauge__label--good {
  background: var(--good-wash);
  color: var(--good);
}
.gauge__label--ok {
  background: var(--amber-wash);
  color: var(--amber);
}
.gauge__val {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.gauge__track {
  height: 5px;
  border-radius: 999px;
  background: var(--hairline);
  margin-top: 7px;
  overflow: hidden;
}
.gauge__track > .meter-fill::-webkit-progress-value {
  background: var(--teal-ink);
}
.gauge__track > .meter-fill::-moz-progress-bar {
  background: var(--teal-ink);
}

/* quality note — always visible */
.quality-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 22px;
  padding: 13px 16px;
  background: var(--amber-wash);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--amber-ink);
  line-height: 1.5;
}
.quality-note svg {
  flex-shrink: 0;
  stroke: var(--amber);
  margin-top: 2px;
}

/* metadata */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
}
.tag {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--hairline-deep);
  border-radius: var(--radius-xs);
  padding: 4px 11px;
}
.tag b {
  color: var(--ink-soft);
  font-weight: 600;
}
.meta-advanced {
  margin-top: 8px;
}
.meta-advanced > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.meta-advanced > summary::-webkit-details-marker {
  display: none;
}
.meta-advanced > summary::before {
  content: "›";
  font-size: 14px;
  transition: transform 0.15s ease;
  display: inline-block;
}
.meta-advanced[open] > summary::before {
  transform: rotate(90deg);
}
.meta--advanced {
  margin-top: 8px;
  padding-top: 0;
  border-top: none;
}

/* =======================================================================
   Footer
   ======================================================================= */
.footer {
  border-top: 1px solid var(--hairline);
  background: var(--white);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: space-between;
}
.footer p {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 6px;
  max-width: 56ch;
}
.footer__disclaimer {
  color: var(--muted-faint);
  font-size: 12.5px;
}
.footer__col h5 {
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
  font-weight: 600;
}
.footer-brand {
  margin-bottom: 12px;
}

/* =======================================================================
   Shared state + utilities
   ======================================================================= */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 0;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
.banner svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}
.banner__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.banner__title,
.banner__detail {
  margin: 0;
}
.banner__title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.banner__detail {
  font-size: 13.5px;
  line-height: 1.5;
}
.banner--flag {
  background: var(--coral-wash);
  border-color: var(--hairline-coral);
  color: var(--coral);
}
.banner--ok {
  background: var(--good-wash);
  border-color: rgba(47, 163, 106, 0.22);
  color: var(--good);
}
.request-ref {
  display: inline-block;
  margin-top: 4px;
  opacity: 0.8;
}
.actions--centered {
  justify-content: center;
  margin-top: 18px;
}
.u-flex-1 {
  flex: 1;
}
.report-empty {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
}
.footer__affil {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--lab-teal);
  border-top: 2px solid var(--lab-teal);
  padding-top: 8px;
}

/* =======================================================================
   Responsive
   ======================================================================= */
@media (max-width: 720px) {
  body {
    font-size: 16px;
  }
  .wrap {
    padding-inline: 18px;
  }
  .fields {
    grid-template-columns: 1fr;
  }
  .hero__aside {
    justify-content: flex-start;
  }
  .hero__grid {
    grid-template-columns: 1fr;
  }
  .intake-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .protocol {
    grid-template-columns: 1fr 1fr;
  }
  .result__grid {
    grid-template-columns: 1fr;
    gap: 26px;
  }
  .lab-credit {
    display: none;
  }
  .topbar__inner {
    min-height: 60px;
  }
  .group-logo img {
    height: 30px;
  }
  .result-card__head {
    flex-direction: column;
  }
  .interp-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .disclosure > summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .summary-sub {
    display: block;
    margin-left: 23px;
  }
  .actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  .wrap {
    padding-inline: 16px;
  }
  .protocol {
    grid-template-columns: 1fr;
  }
  .protocol__step + .protocol__step {
    border-left: none;
    border-top: 1px solid rgba(44, 143, 179, 0.12);
  }
  .pipeline__frame {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .pipeline img {
    width: 560px;
    max-width: none;
    padding: 14px;
  }
  .pipeline figcaption {
    font-size: 12px;
    text-align: left;
  }
  .dropzone__selected {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .dropzone__replace {
    margin-left: 0;
  }
  .intake-footer {
    padding: 12px 14px;
  }
  .btn-submit {
    justify-content: center;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .trace__line,
  .processing__pulse path {
    animation: none;
    stroke-dashoffset: 0;
  }
  .result-card {
    animation: none;
  }
}

/* =======================================================================
   htmx state hooks (used live in pass two)
   ======================================================================= */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.htmx-request .htmx-indicator {
  opacity: 1;
}
.htmx-request.htmx-indicator {
  opacity: 1;
}
[hx-disabled-elt].htmx-request {
  opacity: 0.55;
  pointer-events: none;
}
