/* AccuRate iOS tokens, from the AccuRate iOS Design System (iOS/DesignSystem/Tokens: Colors,
   Spacing, Elevation, Motion). Same names as the app, so a value here is the app's value. */
:root {
  --appBackground: #1d2534; --appSurface: #46516340; --appForeground: #eeeeee; --appForegroundMuted: #b8bcc4;
  --appAccent: #ff0075; --appAccentFill: #a7155f; --appControlTint: #d0d4db;
  --appSuccess: #30d158; --appHighlight: #ffd60a;
  --appRange1: #343e50; --appRange2: #56627a; --appRange3: #7b869b; --appRange4: #a5afc0;
  --appGlass: #46516399; --appSegmentSelected: #5a6578; --appTabBar: #343e4f;
  --extraSmall: 4px; --small: 8px; --medium: 12px; --mediumLarge: 16px; --large: 24px; --extraLarge: 32px; --huge: 64px;
  --radius-bar: 4px; --radius-small: 8px; --radius-medium: 12px; --radius-mediumLarge: 16px; --radius-large: 24px; --radius-capsule: 9999px;
  --appElevation: 0 0 20px #00000054;
  --appQuick: .2s ease-in-out; --appStandard: .25s ease-in-out;
  --appPress: .35s cubic-bezier(.34, 1.56, .64, 1); /* SwiftUI .bouncy, approximated */
}
:root {
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Roboto Mono", monospace;
  --bg: #ffffff; --ink: #1d1d1f; --muted: #6e6e73; --line: #e5e5ea; --card: #f5f5f7;
  --accent: #e0245e; --accent-ink: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums; /* after the font shorthand, which would reset it */
  -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.top { max-width: 760px; margin: 0 auto; padding: 14px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; gap: 8px; align-items: center; color: var(--accent); font-weight: 700; text-decoration: none; }
/* Language menu, top right. A native select: works with one tap on phones and reads out well. */
.lang-menu select { appearance: none; -webkit-appearance: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--ink);
  background-color: var(--card);
  /* A globe on the left, a chevron on the right. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%231d2534' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9.5'/%3E%3Cpath d='M2.5 12h19M4 7.5h16M4 16.5h16'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%231d2534' stroke-width='1.8' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center, right 12px center;
  border: 0; border-radius: 999px; padding: 8px 32px 8px 38px; cursor: pointer; }
.lang-menu select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
main { max-width: 760px; margin: 0 auto; padding: 8px 16px 32px; }
h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.15; margin: 16px 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 22px; margin: 32px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }

/* The camera oval and its measuring ring, sized like the app's face scan (220 x 280 oval). */
/* The manual panel's width: up to 340, and short enough on a phone that the Start button below it stays
   on screen (the page above it and the button below take about 470px of the height). In vw, not
   %, so the manual panel can use the same height. 60px = the page's and the ring's side margins. */
:root { --oval-w-full: min(100vw - 60px, max(200px, min(340px, (100svh - 470px) * 11 / 14)));
  /* The oval and the fingertip circle are the scan view's size all the time: 240 at most. */
  --oval-w: min(var(--oval-w-full), 240px); }
.scan { position: relative; z-index: 1; width: var(--oval-w); margin: 14px auto;
  /* Always its own layer, at scale 1 here and smaller in the scan view: Safari blanks a live
     video whenever the layers around it are rebuilt, so only the value ever changes. */
  transform: scale(var(--k, 1)); transform-origin: top center; will-change: transform; }
.stage { position: relative; width: 100%; aspect-ratio: 11 / 14; background: #111;
  border-radius: 50%; overflow: hidden; }
/* The camera picture and face marks round their own corners. The old way, a mask on the oval,
   makes Safari blank everything inside it (camera and hint) whenever the page around it changes. */
.stage video, .stage #overlay { border-radius: 50%; }
.ring { position: absolute; inset: -14px; width: calc(100% + 28px); height: calc(100% + 28px); pointer-events: none; overflow: visible; }
.ring-track { fill: none; stroke: #e3e6ec; stroke-width: 12; }
.ring-fill { fill: none; stroke: #7b869b; stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 1 1; stroke-dashoffset: 1; transition: stroke-dashoffset .25s linear, opacity .2s; opacity: 0; }
video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px;
  color: #9a9aa0; text-align: center; padding: 10%; }
.placeholder[hidden] { display: none; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: #111; color: #fff; font-size: 15px; text-align: center; padding: 24px; }
.loading[hidden] { display: none; }
.loading.over { background: rgba(17,17,17,.45); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25);
  border-top-color: #fff; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.hint { position: absolute; left: 50%; bottom: 17%; translate: -50% 0; width: max-content; max-width: 76%;
  background: var(--appHighlight); color: var(--ink); padding: 4px 10px; border-radius: var(--radius-small);
  font-size: 15px; font-weight: 600; text-align: center; }
.hint:empty { display: none; }

.controls { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 24px; }
button { appearance: none; border: 0; border-radius: 999px; padding: 14px 22px; font-family: inherit; font-size: 17px; font-weight: 600; line-height: 1; cursor: pointer; }
button.primary, a.button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; white-space: nowrap; overflow: hidden;
  transition: background-color .45s cubic-bezier(.2, .8, .2, 1); }
button.primary.stop { background: var(--ink); color: #fff; min-width: 120px; }
button.secondary { background: var(--card); color: var(--ink); margin-top: 12px; }
button.small { padding: 10px 18px; font-size: 15px; }
button:disabled { opacity: .55; cursor: default; }

.readout { position: relative; margin-top: 14px; height: 180px; background: var(--card); border-radius: 16px; overflow: hidden; }
.bpm { position: relative; z-index: 1; display: inline-block; margin: 14px 16px; font-family: var(--mono); font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; line-height: 1; }
.bpm .empty { color: #c7c7cc; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.bpm small { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 4px; }
/* The trace fills the card, on ECG paper, with the reading on top. */
#wave { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Before the browser asks for the camera: what happens and that the video stays here. */
.cam-note { margin: 10px auto 0; max-width: 340px; text-align: center; color: var(--muted); font-size: 14px; }
.cam-note[hidden] { display: none; }
/* A camera the browser blocked or that was turned down: the way back, or Manual instead. */
.cam-help { margin-top: 14px; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; scroll-margin: 12px; }
.cam-help[hidden] { display: none; }
.cam-help h2 { margin: 0 0 4px; font-size: 20px; }
.cam-help p { margin: 0 0 10px; color: var(--muted); }
.cam-help ol { margin: 0 0 14px; padding-left: 22px; display: grid; gap: 4px; font-size: 15px; }
.cam-help ol.plain { list-style: none; padding-left: 0; color: var(--muted); font-size: 14px; }
/* Still blocked after Try Again: the steps are the way through, so they stand out and pulse once. */
.cam-help.again { border-color: var(--appAccentFill); }
.cam-help.again h2 { color: var(--appAccentFill); }
.cam-help.again ol { background: color-mix(in srgb, var(--appAccentFill) 8%, #fff); border-radius: 12px; padding: 12px 14px 12px 34px; font-weight: 600;
  animation: steps-pulse .9s cubic-bezier(.2, .8, .2, 1) 2; }
@keyframes steps-pulse { 50% { transform: scale(1.02); } }
@media (prefers-reduced-motion: reduce) { .cam-help.again ol { animation: none; } }
.cam-help-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cam-help-actions button { margin-top: 0; }
/* Try Again and Open in Safari wear the Start button's colour (Hamid, 2026-11-17). */
.cam-help-actions button.primary { background: var(--appAccentFill); color: var(--appForeground); }
.cam-help-actions button.primary:active { transform: scale(.97); filter: brightness(.95); }
.cam-help-actions button[hidden] { display: none; }
.result { margin-top: 14px; border: 1px solid var(--line); border-radius: 16px; padding: 20px; scroll-margin-top: 12px; }
.result h2 { margin: 0 0 4px; font-size: 28px; }
.result p { margin: 0 0 14px; color: var(--muted); }
.result p:empty { display: none; }
/* The reading, then one ask (Hamid, 2026-11-17): two reasons to get AccuRate and the badge. */
.offer { margin: 14px 0 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.offer[hidden] { display: none; }
.offer h3 { margin: 0 0 10px; font-size: 20px; line-height: 1.25; }
.offer ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.offer li { position: relative; padding-left: 26px; font-size: 17px; }
.offer li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
/* A phone sees only its own store's link in the guide text; a computer sees both. */
body[data-os="ios"] .only-android, body[data-os="android"] .only-ios, body[data-os] .store-or { display: none; }
/* The official App Store and Google Play badges (Hamid, 2026-11-17), the same height side by
   side; the Play badge's built-in clear space is cropped, and the gap gives it back. */
.stores { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.store { display: inline-block; line-height: 0; border-radius: 8px; text-decoration: none; }
.store img { display: block; height: 48px; width: auto; }
.result .store img { height: 56px; }
.store[hidden] { display: none; }

/* The cookie banner: a small card at the bottom. Nothing goes to Google before Accept. */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; max-width: 520px; margin: 0 auto;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.consent[hidden] { display: none; }
.consent p { margin: 0; flex: 1 1 240px; font-size: 15px; }
.consent-buttons { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.consent-buttons button.secondary { margin-top: 0; }
.consent a { color: var(--muted); }

/* Your readings: kept in this browser only. */
.history { margin-top: 14px; border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; }
.history[hidden] { display: none; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; }
.history h2 { margin: 0 0 8px; font-size: 20px; }
.text-button { background: none; padding: 6px 0; color: var(--accent); font-size: 15px; font-weight: 600; }
.history ol { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.history .row { display: flex; justify-content: space-between; align-items: baseline; }
.history .strip { display: block; width: 100%; height: 60px; margin-top: 8px; background: var(--card); border-radius: 8px; }
.history li:last-child { border-bottom: 0; }
.history .reading { font-family: var(--mono); font-weight: 700; font-size: 20px; }
.history .reading small { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.history time { color: var(--muted); font-size: 15px; }
.history-note { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.history-nudge { margin: 10px 0 0; font-size: 15px; }
.history-nudge[hidden] { display: none; }
.tips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 16px 0 0; }
.tips li { background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--muted); }

.content p { margin: 0 0 12px; }
.content h3 { font-size: 18px; margin: 20px 0 6px; }
.content ul, .content ol { margin: 0 0 12px; padding-left: 22px; }
.content li { margin: 0 0 6px; }
.content .note { background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 16px; }
.content .sources { font-size: 15px; color: var(--muted); }
.content .checked { font-size: 14px; color: var(--muted); margin-top: -8px; }
.content .two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }
.table-wrap, table { max-width: 100%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html { scroll-padding-top: 12px; }

/* Heart rate guides, at the top of the footer on every page. */
.guides { margin: 0 0 14px; }
.guides p { margin: 0 0 6px; color: var(--ink); font-weight: 600; font-size: 15px; }
.guides ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.guides a { color: var(--accent); }
.guides [aria-current] { color: var(--muted); }
.langs { margin: 0 0 14px; }
.langs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.langs a { color: var(--accent); }
.langs [aria-current] { color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 16px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); }

footer { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
footer a { color: var(--muted); }

/* While scanning: only the oval, the button and the live trace, centred on a white screen
   that does the lighting. Everything else is hidden, so there is nothing to scroll and nothing
   to peek through behind Safari's toolbar. Nothing around the oval is pinned or lifted above an
   overlay: either would make Safari rebuild the video's layers and blank the camera. */
html:has(body.lit), body.lit { overflow: hidden; overscroll-behavior: none; background: #fff; }
/* The scan view's oval scale (the page sets --k-lit); everywhere else the oval is at 1. */
body.lit { --k: var(--k-lit, 1); }
body.lit header.top, body.lit .lang-menu, body.lit footer, body.lit .hero h1, body.lit .hero .sub, body.lit .result,
body.lit .history, body.lit .tips, body.lit .content, body.lit .consent, body.lit .cam-note, body.lit .cam-help { display: none !important; }
body.lit main { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 56px); }
/* The oval is shrunk by its scale (--k, set by the page), never resized; the negative bottom
   margin takes back the space the scale frees. */
body.lit .scan { margin: 14px auto calc((var(--k, 1) - 1) * var(--scan-h, 0px)); }
/* Sized back up so they look the same at the smaller scale: the ring line, the hint and the
   loading circle. */
body.lit .ring-track, body.lit .ring-fill { stroke-width: calc(12 / var(--k, 1)); }
/* Sized up with font and padding, not a scale: Safari lets a scaled layer escape the oval's
   rounded clip, so the hint would poke out over the progress ring. */
body.lit .hint { font-size: calc(15px / var(--k, 1)); padding: calc(4px / var(--k, 1)) calc(10px / var(--k, 1));
  border-radius: calc(var(--radius-small) / var(--k, 1)); }
body.lit .loading { font-size: calc(15px / var(--k, 1)); gap: calc(14px / var(--k, 1)); }
body.lit .spinner { width: calc(44px / var(--k, 1)); height: calc(44px / var(--k, 1)); border-width: calc(4px / var(--k, 1)); }
body.lit .controls { margin-top: 18px; }
/* Nothing grey on the white screen: the trace card loses its fill. */
body.lit .readout { height: min(180px, 24dvh); background: #fff; }

@media (max-width: 480px) {
  .bpm { font-size: 40px; }
  button.primary { padding: 13px 18px; }
}

/* Into and out of the scan view: these three glide to their new size and place, the rest fades. */
.scan { view-transition-name: scan; }
#start { view-transition-name: scan-button; }
/* The button's snapshots keep their own size and stay centred while the pill morphs, so it
   grows and shrinks evenly from the middle and the text never stretches. */
::view-transition-old(scan-button), ::view-transition-new(scan-button) {
  height: 100%; width: auto; object-fit: none; inset-inline-start: 50%; translate: -50% 0;
}
.readout { view-transition-name: readout; }
/* Switching modes crossfades the camera area in place instead of morphing it between shapes, so
   it never grows past its space (the morph pushed the bottom over the button). */
html.switching .scan { view-transition-name: none; }
::view-transition-group(*) { animation-duration: .45s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* The not found page's list of places to go. */
.content .next-links { list-style: none; padding: 0; margin: 0; }
.content .next-links li { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.content .next-links a { font-weight: 600; text-decoration: none; }
.content .next-links span { color: var(--muted); font-size: 15px; }

/* Guide pages: a floating button to the face scan on the home page, always on screen. */
a.button { display: inline-block; border-radius: 999px; padding: 15px 26px; font-size: 17px; font-weight: 700; line-height: 1;
  text-decoration: none; text-align: center; }
a.button.primary:hover { background: #c81e52; }
.floating-cta { position: fixed; z-index: 50; left: 50%; translate: -50% 0;
  bottom: calc(16px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px);
  padding: 17px 30px; box-shadow: 0 8px 24px rgba(224, 36, 94, .35), 0 2px 6px rgba(0, 0, 0, .12); }
/* Room at the end of the page, so the button never covers the footer's last line. */
body:has(.floating-cta) { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
/* While the cookie banner is up it takes the bottom of the screen; the button comes back after. */
body:has(#consent:not([hidden])) .floating-cta { display: none; }
@media print { .floating-cta { display: none; } }

.chart { margin: 4px 0 16px; }
.chart img { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }
.byline { margin: -6px 0 8px; color: var(--muted); font-size: 14px; }
.byline a { color: var(--muted); }

/* Calculators */
.calc { border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 6px; margin: 8px 0 24px; }
.calc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 16px; margin-bottom: 14px; }
.calc label { display: grid; gap: 6px; font-size: 15px; font-weight: 600; }
.calc .opt { color: var(--muted); font-weight: 400; }
.calc input { font: inherit; font-size: 20px; font-family: var(--mono); padding: 10px 12px; border: 1px solid #c7c7cc;
  border-radius: 10px; width: 100%; background: #fff; color: var(--ink); }
.calc input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.calc output { display: block; }
.calc-big { margin: 4px 0; font-size: 18px; color: var(--muted); }
.calc-big .num { font-size: 40px; font-weight: 700; color: var(--ink); }
.calc-big small { display: block; font-size: 14px; }
.calc-label { margin: 0; font-weight: 600; }
.calc-note, .calc-msg { color: var(--muted); font-size: 15px; }
.calc-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 20px; }
.calc td.num { font-weight: 700; }
/* Results are drawn by the script: keep their space from the start so the page doesn't jump. */
form[data-calc="max"] output { min-height: 330px; }
form[data-calc="zones"] output { min-height: 415px; }
form[data-calc="target"] output { min-height: 331px; }
form[data-calc="running"] output, form[data-calc="cycling"] output { min-height: 415px; }
form[data-calc="zone2"] output, form[data-calc="recovery"] output { min-height: 150px; }
form[data-calc="fat"] output { min-height: 250px; }
@media (min-width: 600px) {
  form[data-calc="max"] output { min-height: 330px; }
  form[data-calc="zones"] output, form[data-calc="running"] output, form[data-calc="cycling"] output { min-height: 319px; }
  form[data-calc="target"] output { min-height: 179px; }
}
.calc label { align-content: end; }

/* Maximum heart rate page: jump links, then the calculator beside its questions. */
.content .jump { margin: 4px 0 20px; }
.calc-layout { display: grid; gap: 8px 24px; align-items: start; }
.calc-layout .calc { margin: 0 0 16px; }
.calc-hrmax { background: linear-gradient(180deg, #fff 0%, #fdf2f6 100%); }
.calc fieldset { border: 0; padding: 0; margin: 0 0 12px; display: flex; gap: 20px; flex-wrap: wrap; }
.calc legend { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.calc label.choice { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 17px; margin: 0 0 12px; cursor: pointer; }
.calc label.choice input { width: 20px; height: 20px; accent-color: var(--accent); }
.calc-row { border-top: 1px solid var(--line); padding: 10px 0 2px; }
.calc-row p { margin: 0 0 4px; }
.calc-mid { font-size: 17px; }
.calc-mid .num { font-weight: 700; font-size: 20px; }
.calc-compare { border-bottom: 0; padding: 8px 0 4px; }
.calc-compare table { margin: 6px 0 0; font-size: 15px; }
.calc-compare tr.main td { font-weight: 700; }
.faq h2 { margin: 16px 0 8px; }
.faq details:first-of-type { border-top: 1px solid var(--line); }
.calc-hrmax .calc-fields { grid-template-columns: 1fr; gap: 12px; }
.calc-hrmax .calc-fields label { display: block; }
.calc-hrmax .calc-fields input { display: block; margin-top: 6px; max-width: 240px; }

/* Height and weight: the unit in a grey box joined to the input, and links to switch units. */
.unit-field { display: block; }
.unit-label { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.unit-inputs { display: flex; flex-wrap: wrap; gap: 10px; }
.unit-input { display: inline-flex; align-items: stretch; }
.calc .unit-input input { width: 104px; max-width: none; margin: 0; border-radius: 10px 0 0 10px; }
.unit-input .suffix { display: grid; place-items: center; min-width: 44px; padding: 0 10px; font-size: 16px; font-weight: 600;
  color: var(--ink); background: var(--card); border: 1px solid #c7c7cc; border-left: 0; border-radius: 0 10px 10px 0; }
.unit-switch { display: block; margin-top: 4px; padding: 6px 0 0; font-size: 15px; text-align: left; }
.unit-switch + .unit-switch { padding-top: 2px; }
/* One focus ring around the input and its unit together, the same height as both. */
.unit-input { border-radius: 10px; }
.calc .unit-input input:focus { outline: none; border-color: #c7c7cc; }
.unit-input:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
/* No up and down arrows in number boxes: they crowd the unit and are hard to tap. */
.calc input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.calc input[type=number]::-webkit-outer-spin-button,
.calc input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc .unit-part { display: grid; gap: 4px; font-weight: 400; }
.unit-part-label { font-size: 14px; color: var(--muted); }
.unit-inputs { gap: 10px 16px; }
.calc-hrmax .calc-fields .unit-part { display: grid; gap: 4px; }
.calc-hrmax .calc-fields .unit-input input { display: block; margin: 0; width: 104px; }
/* The unit switch sits on the same line, right after the boxes. */
.unit-inputs { align-items: center; }
.unit-inputs .unit-switch { display: inline-block; margin: 0; padding: 8px 0; white-space: nowrap; }

/* Grouping: each label sits close to its box, and there's clear space between one question and the next. */
.calc-hrmax .calc-fields { gap: 24px; margin-bottom: 24px; }
.calc-hrmax .calc-fields label, .calc-hrmax .unit-label { font-size: 15px; font-weight: 600; line-height: 1.3; }
.calc-hrmax .calc-fields input { margin-top: 6px; }
.calc-hrmax .unit-label { margin: 0 0 6px; }
.calc-hrmax .unit-field .unit-part input { margin-top: 0; }
.calc-hrmax fieldset { margin: 0 0 24px; }
.calc-hrmax legend { margin-bottom: 4px; }
.calc-hrmax fieldset label.choice { margin: 0; }
.calc-hrmax > label.choice { margin: 0 0 20px; }

/* The one-sentence answer under each calculator. */
.content .answer { border-left: 4px solid var(--accent); padding: 4px 0 4px 14px; margin: 0 0 20px; }
/* Wide tables scroll sideways on small phones instead of squashing. */
/* Every table scrolls sideways inside its own box on a small phone, never the page. */
.content table { display: block; max-width: 100%; overflow-x: auto; }
.content table.wide { white-space: nowrap; }

/* The camera is drawn on #preview, already cropped to the oval; the video only feeds it. */
.stage #video { opacity: 0; }
.stage #preview, .stage #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill;
  transform: scaleX(-1); border-radius: 50%; }

/* Face | Fingertip, above the oval. Hidden in the scan view. */
/* Three equal columns, each as wide as the longest word, so every option matches. */
.mode-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: max-content; max-width: 100%; margin: 8px auto 24px; padding: 3px; gap: 2px;
  background: var(--card); border-radius: 999px; }
/* Never wider than the screen: the three sides share it, padding and text ease down on a narrow
   one, and a label that still can't fit is cut with an ellipsis instead of pushing the page wide. */
.mode-switch button { display: inline-flex; align-items: center; justify-content: center; min-width: 0; gap: 7px;
  padding: 7px clamp(6px, 3vw, 18px); font-size: clamp(13px, 3.8vw, 15px); font-weight: 600; color: var(--muted); background: transparent; position: relative; z-index: 1; }
.mode-switch button[aria-checked="true"] { color: var(--ink); }
/* The label clips for its ellipsis, so it needs a line tall enough for the g in Fingertip
   (buttons are line-height 1); the button's padding is 2px less each side to keep its height. */
.mode-switch button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
/* The white thumb slides under the chosen side, and follows a drag. It glides only once the
   page has set the remembered mode, so it never slides in on load. */
.mode-switch { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.mode-switch .thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 10px) / 3);
  border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); pointer-events: none; }
.mode-switch[data-mode="finger"] .thumb { transform: translateX(calc(100% + 2px)); }
.mode-switch[data-mode="manual"] .thumb { transform: translateX(calc(200% + 4px)); }
/* Narrow phones: a little tighter so three options fit. */
@media (max-width: 400px) {
  .mode-switch button { gap: 5px; }
  .mode-switch .icon { width: 18px; height: 18px; }
}
/* The smallest phones (320 wide): words only, so all three fit. */
@media (max-width: 359px) { .mode-switch .icon { display: none; } }
.mode-switch.ready .thumb { transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
.mode-switch.ready button { transition: color var(--appQuick); }
.mode-switch.dragging .thumb { transition: none; }
.mode-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Material Symbols Outlined (Apache 2.0), drawn as filled paths. */
.mode-switch .icon { width: 20px; height: 20px; flex: none; fill: currentColor; }
body.lit .mode-switch { display: none; }
/* The back camera isn't a mirror. */
.stage.back #preview, .stage.back #overlay { transform: none; }

/* The Start button is the app's PrimaryButtonStyle: 52 tall, 12 corners, 17 semibold,
   appForeground on appAccentFill; pressed it shrinks to 0.97 and darkens, on the bouncy
   spring. Unlike the app it hugs its label (Hamid, 2026-11-11). Stop keeps the shape, on the
   app's navy. */
.controls #start.primary { width: auto; min-height: 52px;
  padding: var(--small) var(--large); border-radius: var(--radius-medium);
  background: var(--appAccentFill); color: var(--appForeground); font-size: 17px; line-height: 22px; font-weight: 600;
  transition: background-color .45s cubic-bezier(.2, .8, .2, 1), transform var(--appPress), filter var(--appPress); }
.controls #start.primary:active { transform: scale(.97); filter: brightness(.95); }
.controls #start.primary.stop { background: var(--appBackground); min-width: 120px; }
.controls #start.primary:focus-visible { outline: 2px solid var(--appAccentFill); outline-offset: 2px; }

/* Fingertip: a circle as wide as the oval, centred in the oval's space, so switching modes
   never moves the button or anything below. The oval is 14/11 of its width tall, so a circle
   leaves 3/22 of the width above and below; margin percentages and the width share a base.
   The base is 24px, not the oval's 14px: its margins collapse into the 24px of the switch
   above and the button below, so 24px is the gap the oval really has. */
.scan.finger { margin-block: calc(24px + var(--oval-w) * 3 / 22); }
.scan.finger .stage { aspect-ratio: 1; }
/* Manual is a rounded rectangle in the oval's space, before the check (steps) and during it (the tap pad). */
.scan.manual .stage { border-radius: var(--radius-medium); }
/* Manual has no camera picture: its panel keeps the full width, at the oval's height, so the
   steps fit and the button stays where it is in every mode. */
.scan.manual { width: min(100vw - 60px, 340px); }
.scan.manual .stage { aspect-ratio: auto; min-height: calc(var(--oval-w-full) * 14 / 11); }

/* Manual, before the check: the oval's space holds plain steps, not a circle. The tap circle
   appears only in the scan view, while you tap. */
.manual-steps { display: none; }
body:not(.lit) .scan.manual .stage { background: var(--card); overflow: hidden; } /* never scrolls: the panel grows to fit its steps */
body:not(.lit) .scan.manual .ring, body:not(.lit) .scan.manual .tap-pad { display: none; }
body:not(.lit) .scan.manual .manual-steps { display: flex; }
body[data-mode="manual"] .tips { display: none; }
/* Sizes are in em from a 16px base; the panel grows to fit the steps, at least as tall as the oval. */
.manual-steps { position: relative; min-height: inherit; flex-direction: column; justify-content: center; gap: .75em;
  padding: var(--large); color: var(--ink); font-size: 16px; line-height: 1.38; }
.manual-steps h2 { margin: 0; font-size: 1.3em; line-height: 1.25; }
.manual-steps ol { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: .6em; }
.manual-steps ol > li { counter-increment: step; display: grid; grid-template-columns: 1.6em 1fr; gap: .5em; }
.manual-steps ol > li::before { content: counter(step); border-radius: 50%;
  background: var(--appAccentFill); color: var(--appForeground); font-size: .875em; font-weight: 700;
  display: grid; place-items: center; width: 1.85em; height: 1.85em; }
.manual-steps .ms-places { list-style: none; margin: .25em 0 0; padding: 0; display: flex; flex-direction: column; gap: .25em; }
.manual-steps .ms-places strong { font-weight: 700; }
.manual-steps p { margin: 0; }
@media (max-width: 400px) { .manual-steps { padding: 14px; } }

/* Manual: no camera. The circle is a big pink pad you tap on each beat you feel. */
/* Shaped like the app's primary button: 12 corners, appAccentFill, semibold label, and the
   same press (0.97, darker) on every tap. */
.tap-pad { display: none; position: absolute; inset: 0; border-radius: var(--radius-medium); padding: 0; z-index: 2;
  flex-direction: column; align-items: center; justify-content: center; gap: var(--small);
  background: var(--appAccentFill); color: var(--appForeground); touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; transition: transform var(--appPress), filter var(--appPress); }
.scan.manual .tap-pad { display: flex; }
.scan.manual .placeholder, .scan.manual #preview, .scan.manual #overlay { visibility: hidden; }
.tap-pad.hit { transform: scale(.97); filter: brightness(.95); }
.tap-pad:focus-visible { outline: 3px solid var(--appAccentFill); outline-offset: 4px; }
.tap-icon { width: calc(56px / var(--k, 1)); height: auto; fill: currentColor; transition: transform .12s ease-out; }
.tap-pad.hit .tap-icon { transform: scale(.9); }
.tap-count { font-size: calc(48px / var(--k, 1)); line-height: 1; font-weight: 700; color: inherit; }
.scan.manual .hint { display: none; }
.tap-count:empty { display: none; }
.tap-label { font-size: calc(17px / var(--k, 1)); line-height: 1.3; font-weight: 600; max-width: 68%; text-align: center; }
@media (prefers-reduced-motion: reduce) { .tap-pad, .tap-icon { transition: none; } }

/* Manual count: after 30 s with too few taps, the panel where the steps were asks for the
   beats you counted, right where you're looking. */
.count-panel { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; justify-content: center;
  gap: var(--medium); padding: var(--large); background: var(--card); color: var(--ink); }
.count-panel[hidden] { display: none; }
.count-panel label { font-size: 21px; line-height: 1.3; font-weight: 700; }
body.lit .count-panel { display: none; }
.count-row { display: flex; gap: var(--small); }
.count-row input { width: 110px; font: inherit; font-size: 20px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-medium); font-variant-numeric: tabular-nums; }
.count-row button.primary { min-height: 52px; border-radius: var(--radius-medium); background: var(--appAccentFill); color: var(--appForeground); }
/* The hint sits over the tap pad and lets taps through to it. */
.hint { z-index: 3; pointer-events: none; }
/* During a manual check the tap area is a horizontal rectangle (5:3), shaped like a big button. */
body.lit .scan.manual .stage { aspect-ratio: 5 / 3; height: auto; }
/* More room between the manual tap area (and its ring) and the Stop button. */
body.lit[data-mode="manual"] .controls { margin-top: 36px; }

/* Phones: the page never scrolls sideways (a stray wide element is clipped, not scrollable),
   and fields and menus are 16px, below which iPhone zooms the page when you tap them. */
html, body { overflow-x: clip; }
@media (max-width: 600px) { input, select, textarea { font-size: 16px; } }
