.health-history {
  --history-ink: #1d1d1f;
  --history-muted: #6e6e73;
  --history-paper: #ffffff;
  --history-surface: #f5f5f7;
  --history-link: #0066cc;
  color: var(--history-ink);
  background: var(--history-paper);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.history-container { max-width: 980px; margin-inline: auto; padding-inline: 32px; }
.history-intro { padding-top: 36px; padding-bottom: 40px; }
.history-intro h1 { margin-top: 28px; font-size: 56px; line-height: 1.12; font-weight: 600; letter-spacing: -0.045em; }
.history-intro h1, .history-section h2, .history-metric h3 { font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif; word-break: keep-all; }
.history-description { margin-top: 20px; font-size: 19px; line-height: 1.65; color: var(--history-muted); word-break: keep-all; }
.history-period { margin-top: 32px; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.history-count { margin-top: 6px; font-size: 14px; color: var(--history-muted); }
.history-record-types { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; font-size: 13px; color: var(--history-muted); }
.history-record-types strong { color: var(--history-ink); font-weight: 500; }
.history-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin-top: 28px; }
.history-actions p { color: var(--history-muted); font-size: 12px; }
.history-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 20px; background: #0071e3; color: #fff; border-radius: 980px; font-size: 14px; cursor: pointer; }
.history-button:hover { background: var(--history-link); }
.history-back { display: inline-flex; align-items: center; min-height: 44px; color: var(--history-link); font-size: 14px; }
.history-back:hover { text-decoration: underline; }
.health-history :is(a, button, summary):focus-visible { outline: 2px solid #0071e3; outline-offset: 4px; border-radius: 4px; }
.history-index { padding-block: 24px; }
.history-index > p { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.history-index-links { display: flex; flex-wrap: wrap; gap: 8px; }
.history-index-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; background: var(--history-surface); color: var(--history-link); border-radius: 980px; font-size: 13px; }
.history-index-links a:hover { background: #ededf2; }
.history-reading-note { padding-top: 12px; padding-bottom: 44px; font-size: 13px; line-height: 1.7; color: var(--history-muted); }
.history-reading-note p + p { margin-top: 8px; }
.history-section { background: var(--history-surface); padding-block: 48px 56px; scroll-margin-top: 110px; }
.history-section:nth-of-type(even) { background: var(--history-paper); }
.history-section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.history-section-heading h2 { font-size: 36px; font-weight: 600; line-height: 1.2; letter-spacing: -0.035em; }
.history-section-heading p { color: var(--history-muted); font-size: 13px; margin-top: 6px; }
.history-metric { min-width: 0; padding: 28px; background: var(--history-paper); border-radius: 8px; }
.history-metric + .history-metric { margin-top: 24px; }
.history-section:nth-of-type(even) .history-metric { background: var(--history-surface); }
.history-metric-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.history-metric-heading > div { min-width: 0; }
.history-metric-heading > a { flex-shrink: 0; font-size: 12px; }
.history-metric h3 { font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: -0.025em; }
.history-metric-period { margin-top: 8px; color: var(--history-muted); font-size: 12px; }
.history-latest { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-top: 22px; margin-bottom: 24px; font-size: 13px; color: var(--history-muted); }
.history-latest strong { margin-left: 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.025em; color: var(--history-ink); font-variant-numeric: tabular-nums; }
.history-chart { background: var(--history-paper); border-radius: 8px; padding: 16px 0 0; break-inside: avoid; }
.history-chart + .history-chart { margin-top: 24px; }
.history-chart [data-chart-panel] > .relative { height: 320px; }
.history-chart canvas:not([data-chart-ready]) { display: block; max-width: 100%; }
.history-chart [data-comparison-reference] { font-size: 13px; }
.history-chart [data-reference-range-note] { font-size: 11px; }
.history-section:nth-of-type(even) .history-chart { padding: 16px; }
.history-exclusion-note { font-size: 12px; line-height: 1.7; margin-top: 16px; color: var(--history-muted); }
.history-values { margin-top: 20px; border-top: 1px solid #d2d2d7; }
.history-values > summary { min-height: 52px; padding-block: 16px; color: var(--history-link); font-size: 14px; cursor: pointer; }
.history-values > summary span { margin-left: 12px; font-size: 12px; color: var(--history-muted); }
.history-text-note { margin-top: 24px; margin-bottom: 8px; font-size: 12px; color: var(--history-muted); }
.history-record { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px 24px; padding-block: 18px; border-bottom: 1px solid #e5e5e7; }
.history-record:last-child { border-bottom: none; }
.history-record-date time { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.history-record-date span { display: block; margin-top: 4px; color: var(--history-muted); font-size: 12px; }
.history-record-context { font-size: 12px; color: var(--history-muted); margin-bottom: 4px; }
.history-record-value { font-size: 16px; line-height: 1.65; font-weight: 500; white-space: pre-wrap; font-variant-numeric: tabular-nums; }
.history-record-reference, .history-record-assessment, .history-record-notes { margin-top: 6px; color: var(--history-muted); font-size: 12px; line-height: 1.6; }
.history-record-notes { white-space: pre-wrap; }
.history-out-of-range { color: #b42318; font-weight: 600; }
.history-empty { padding-block: 20px 100px; }
.history-empty h2 { font-size: 24px; font-weight: 600; }
.history-empty p { margin-block: 16px 24px; line-height: 1.7; color: var(--history-muted); }
.history-print-only { display: none; }

@media (max-width: 639px) {
  .history-container { padding-inline: 20px; }
  .history-intro { padding-top: 16px; padding-bottom: 20px; }
  .history-intro h1 { font-size: 38px; margin-top: 22px; }
  .history-description { font-size: 16px; }
  .history-period { font-size: 22px; }
  .history-section { padding-block: 32px; }
  .history-section > .history-container { padding-inline: 12px; }
  .history-section-heading { padding-inline: 8px; }
  .history-section-heading h2 { font-size: 28px; }
  .history-metric { padding: 20px 12px; }
  .history-metric h3 { font-size: 21px; }
  .history-metric-heading { gap: 8px; }
  .history-chart [data-chart-panel] > .relative { height: 260px; }
  .history-section:nth-of-type(even) .history-chart { padding: 12px 4px; }
  .history-values > summary span { display: block; margin: 4px 0 0 16px; }
  .history-record { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .history-record-date { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
  .history-record-date span { margin: 0; }
}

@media print {
  @page health-history { size: A4; margin: 16mm; }
  body:has(.health-history) { display: block; background: #fff; }
  body:has(.health-history) :is(.site-navigation, .site-message, footer) { display: none !important; }
  .health-history { page: health-history; background: #fff; color: #1d1d1f; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .health-history .history-screen-only { display: none !important; }
  .history-print-only { display: block; }
  .history-container { max-width: none; padding: 0; }
  .history-intro { padding-bottom: 20px; }
  .history-intro h1 { font-size: 30px; margin-top: 0; }
  .history-description { font-size: 12px; margin-top: 10px; }
  .history-period { font-size: 20px; margin-top: 16px; }
  .history-print-date { font-size: 11px; margin-top: 16px; }
  .history-reading-note { font-size: 10px; padding-bottom: 16px; }
  .health-history .history-section { background: #fff; padding: 0; }
  .history-section + .history-section { break-before: page; }
  .history-section-heading { break-after: avoid; margin-bottom: 16px; }
  .history-section-heading h2 { font-size: 24px; }
  .health-history .history-section .history-metric { background: #fff; padding: 0; border-radius: 0; }
  .history-metric + .history-metric { margin-top: 24px; }
  .history-metric-heading { break-inside: avoid; break-after: avoid; }
  .history-metric h3 { font-size: 19px; }
  .history-latest { break-inside: avoid; break-after: avoid; margin-block: 10px; }
  .history-text-note { break-after: avoid; }
  .health-history .history-section .history-chart { padding: 0; background: #fff; }
  .health-history .history-chart [data-chart-panel] > .relative { height: 240px; }
  .health-history canvas { width: 100% !important; height: 240px !important; }
  .history-values > summary { color: #1d1d1f; padding-block: 8px; min-height: 0; font-size: 12px; break-after: avoid; }
  .history-values > summary span { display: inline; margin-left: 8px; }
  .history-record { grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding-block: 9px; break-inside: avoid; }
  .history-record-date { display: block; }
  .history-record-date time, .history-record-value { font-size: 12px; }
  .history-record-date span, .history-record-context, .history-record-reference, .history-record-assessment, .history-record-notes { font-size: 10px; }
  .history-record-reference, .history-record-assessment, .history-record-notes { margin-top: 3px; }
  .history-chart a { color: #1d1d1f; text-decoration: none; }
  .history-chart [data-reference-range-note] { display: none; }
  .history-reading-note p:first-child { display: none; }
  .history-record { padding-block: 7px; grid-template-columns: 100px minmax(0, 1fr); }
  .history-record-body { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 3px 16px; }
  .history-record-reference, .history-record-assessment { font-size: 11px; line-height: 1.4; margin-top: 0; }
  .history-record-notes { grid-column: 1 / -1; white-space: normal; line-height: 1.4; }
  .history-text-note + .history-records .history-record-body { display: block; }
  .history-text-note + .history-records .history-record-status { margin-top: 4px; }
}
