/*
 * Swim Sage, in a browser: the app's design system (Tokens.swift and the asset catalogue's colour
 * sets) for the web demo. Calm, analytical, recognisably iOS: generous whitespace, strong type, a
 * pale cool background, one aqua accent. Colours are the asset catalogue's, light and dark.
 */
:root {
  color-scheme: light dark;
  --background: #f1f5f8;
  --surface: #ffffff;
  --aqua: #0984a8;
  --positive: #23893c;
  --attention: #c35a00;
  --reference: #6d6d73;
  --accent: #008eb5;
  --destructive: #ff3b30;
  --stroke-freestyle: #0984a8;
  --stroke-breaststroke: #3e51b5;
  --stroke-backstroke: #8e44ac;
  --stroke-butterfly: #c2175b;
  --stroke-kickboard: #8d6d62;
  --stroke-other: #8e8e92;
  --label: #000000;
  --secondary: rgba(60, 60, 67, 0.6);
  --tertiary: rgba(60, 60, 67, 0.3);
  --quaternary: rgba(60, 60, 67, 0.18);
  --separator: rgba(60, 60, 67, 0.29);
  --fill: rgba(120, 120, 128, 0.12);
  --grouped: #f2f2f7;
  --glass: rgba(250, 252, 253, 0.9);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);

  --xs: 4px; --s: 8px; --m: 12px; --l: 16px; --xl: 24px; --xxl: 32px;
  --radius-control: 12px;
  --radius-card: 24px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono-digits: tabular-nums;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #000000; --surface: #1c1c1e; --aqua: #4fc3df; --positive: #2fd157; --attention: #ff9f09;
    --reference: #97979d; --accent: #3fc1e0; --destructive: #ff453a;
    --stroke-freestyle: #4fc3df; --stroke-breaststroke: #8b9eff; --stroke-backstroke: #c589ef;
    --stroke-butterfly: #ff6ea4; --stroke-kickboard: #c4a69b; --stroke-other: #8e8e92;
    --label: #ffffff; --secondary: rgba(235, 235, 245, 0.6); --tertiary: rgba(235, 235, 245, 0.3);
    --quaternary: rgba(235, 235, 245, 0.16); --separator: rgba(84, 84, 88, 0.6); --fill: rgba(118, 118, 128, 0.24);
    --grouped: #000000; --glass: rgba(36, 36, 38, 0.9); --shadow: none;
  }
}
:root[data-theme="dark"] {
  --background: #000000; --surface: #1c1c1e; --aqua: #4fc3df; --positive: #2fd157; --attention: #ff9f09;
  --reference: #97979d; --accent: #3fc1e0; --destructive: #ff453a;
  --stroke-freestyle: #4fc3df; --stroke-breaststroke: #8b9eff; --stroke-backstroke: #c589ef;
  --stroke-butterfly: #ff6ea4; --stroke-kickboard: #c4a69b; --stroke-other: #8e8e92;
  --label: #ffffff; --secondary: rgba(235, 235, 245, 0.6); --tertiary: rgba(235, 235, 245, 0.3);
  --quaternary: rgba(235, 235, 245, 0.16); --separator: rgba(84, 84, 88, 0.6); --fill: rgba(118, 118, 128, 0.24);
  --grouped: #000000; --glass: rgba(36, 36, 38, 0.9); --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 17px; line-height: 1.29; color: var(--label); background: var(--background);
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; border-radius: 8px; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Type: the iOS text styles at the default size. */
.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.37px; }
.title { font-size: 28px; line-height: 34px; font-weight: 400; }
.title2 { font-size: 22px; line-height: 28px; }
.title3 { font-size: 20px; line-height: 25px; }
.headline { font-size: 17px; line-height: 22px; font-weight: 600; }
.body { font-size: 17px; line-height: 22px; }
.callout { font-size: 16px; line-height: 21px; }
.subheadline { font-size: 15px; line-height: 20px; }
.footnote { font-size: 13px; line-height: 18px; }
.caption { font-size: 12px; line-height: 16px; }
.caption2 { font-size: 11px; line-height: 13px; }
.semibold { font-weight: 600; }
.medium { font-weight: 500; }
.bold { font-weight: 700; }
.hero { font-family: var(--rounded); font-weight: 600; }
.digits { font-variant-numeric: var(--mono-digits); }
.secondary { color: var(--secondary); }
.tertiary { color: var(--tertiary); }
.aqua { color: var(--aqua); }
.positive { color: var(--positive); }
.attention { color: var(--attention); }
.reference { color: var(--reference); }
.eyebrow { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; color: var(--secondary); letter-spacing: 0.2px; }

/* Layout helpers. */
.row { display: flex; align-items: center; gap: var(--s); }
.row.top { align-items: flex-start; }
.row.baseline { align-items: baseline; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--xs); }
.stack { display: flex; flex-direction: column; gap: var(--m); }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--l); }

/* The phone: a status bar, the tabs' navigation stacks, and the floating tab bar. */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--background); }
.statusbar { height: 54px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 32px 0 40px;
  font-weight: 600; font-size: 17px; position: absolute; top: 0; left: 0; right: 0; z-index: 40; pointer-events: none; }
.statusbar .icons { display: flex; gap: 6px; align-items: center; }
.app.no-status .statusbar { display: none; }
.tabs { position: relative; flex: 1; overflow: hidden; }
.tab { position: absolute; inset: 0; display: none; }
.tab.active { display: block; }

.page { position: absolute; inset: 0; background: var(--background); display: flex; flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s; will-change: transform; }
.page.grouped { background: var(--grouped); }
.page.entering { transform: translateX(100%); }
.page.covered { transform: translateX(-28%); opacity: 0.6; }
.page.leaving { transform: translateX(100%); }
@media (prefers-reduced-motion: reduce) { .page { transition: none; } }

.navbar { position: absolute; top: 0; left: 0; right: 0; z-index: 20; padding-top: 54px; height: 98px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s); padding-left: var(--l); padding-right: var(--l);
  transition: background 0.2s; }
.app.no-status .navbar { padding-top: 0; height: 44px; }
/* iOS 26's scroll edge: the page behind the bar fades out. Translucent (72%, then 90%, with WebKit's
   backdrop blur) the status bar and the title read over the cards' figures (demo sweep, 16 Oct). */
.navbar.scrolled { background: var(--background); box-shadow: 0 8px 12px -4px var(--background); }
.page.grouped .navbar.scrolled { background: var(--grouped); box-shadow: 0 8px 12px -4px var(--grouped); }
.sheet .navbar.scrolled { background: var(--grouped); box-shadow: 0 8px 12px -4px var(--grouped); }
.navbar .inline-title { font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 0.2s; }
.navbar.scrolled .inline-title, .navbar.inline .inline-title { opacity: 1; }
.navbar .leading { justify-self: start; display: flex; gap: var(--s); align-items: center; }
.navbar .trailing { justify-self: end; display: flex; gap: var(--s); align-items: center; }
.navbtn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  color: var(--label); font-size: 17px; }
.navbtn.glass { width: 44px; height: 44px; border-radius: 50%; background: var(--glass); box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.navbtn.pill { padding: 0 var(--l); border-radius: 22px; background: var(--glass); box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); font-weight: 500; }
.navbtn.prominent { color: #fff; background: var(--aqua); }
.navbtn[disabled] { opacity: 0.35; cursor: default; }
.navbtn svg { width: 22px; height: 22px; }

.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding-top: 98px; padding-bottom: 120px; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }
.app.no-status .scroll { padding-top: 44px; }
.page-title { padding: 6px var(--l) var(--s); }
.content { display: flex; flex-direction: column; gap: var(--l); padding: 0 var(--l); }

/* The floating tab bar (Liquid Glass). */
.tabbar { position: absolute; left: 16px; right: 16px; bottom: 22px; height: 62px; z-index: 30; display: flex; align-items: stretch;
  border-radius: 31px; background: var(--glass); box-shadow: 0 2px 14px rgba(0,0,0,0.12); padding: 4px;
  backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8); transition: transform 0.3s, opacity 0.3s; }
.tabbar.hidden { transform: translateY(120px); opacity: 0; pointer-events: none; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; font-weight: 600; border-radius: 27px; color: var(--label); }
.tabbar button svg { width: 26px; height: 26px; }
.tabbar button.selected { color: var(--aqua); background: var(--fill); }
.home-indicator { position: absolute; bottom: 8px; left: 50%; width: 140px; height: 5px; margin-left: -70px; border-radius: 3px;
  background: var(--label); opacity: 0.85; z-index: 45; pointer-events: none; }
.app.no-status .home-indicator { display: none; }

/* SageCard. */
.card { background: var(--surface); border-radius: var(--radius-card); padding: var(--l); display: flex; flex-direction: column;
  gap: var(--m); min-width: 0; }
.card.tappable { cursor: pointer; }
.card h3 { margin: 0; }

/* MetricValueView: "DISTANCE" above "1,800 m". */
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric .title-row { display: flex; align-items: center; gap: var(--xs); font-size: 12px; line-height: 16px; color: var(--secondary); }
.metric .value { display: flex; align-items: baseline; gap: 3px; font-family: var(--rounded); font-weight: 600; }
.metric .value .unit { font-family: var(--font); font-weight: 400; font-size: 15px; color: var(--secondary); }
.metric.title2 .value { font-size: 22px; line-height: 28px; }
.metric.title .value { font-size: 28px; line-height: 34px; }
.metric.largeTitle .value { font-size: 34px; line-height: 41px; }
.metric.headline .value { font-size: 17px; line-height: 22px; }
.metric.title3 .value { font-size: 20px; line-height: 25px; }

/* Pills, badges and labels. */
.adjusted { display: inline-flex; align-items: center; gap: 3px; color: var(--aqua); font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--aqua) 12%, transparent); }
.adjusted.icon { padding: 0; background: none; }
.adjusted svg { width: 13px; height: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status svg { width: 17px; height: 17px; flex: none; }
.target-mark svg { width: 14px; height: 14px; }
.period-pills { display: flex; gap: var(--s); overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--l)); padding: 0 var(--l); }
.period-pills::-webkit-scrollbar { display: none; }
.period-pills button { min-width: 44px; min-height: 32px; padding: 0 var(--m); border-radius: 999px; background: var(--fill);
  font-size: 15px; font-weight: 600; flex: none; }
.period-pills button.selected { background: var(--aqua); color: #fff; }
.segmented { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); gap: 0; }
.segmented button { flex: 1; min-height: 28px; border-radius: 7px; font-size: 13px; font-weight: 500; padding: 0 var(--s); }
.segmented button.selected { background: var(--surface); box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 3px 1px rgba(0,0,0,0.04); font-weight: 600; }
:root[data-theme="dark"] .segmented button.selected { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented button.selected { background: #636366; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 var(--l);
  border-radius: 999px; font-size: 17px; font-weight: 600; }
/* iOS 26's bordered button: a grey capsule with aqua text. */
.btn.bordered { background: var(--fill); color: var(--aqua); min-height: 34px; font-size: 15px; padding: 0 14px; }
.btn.prominent { background: var(--aqua); color: #fff; }
.btn.plain { color: var(--aqua); padding: 0; min-height: 0; font-weight: 400; }
.btn.small { min-height: 30px; font-size: 15px; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.link { color: var(--aqua); }

/* Inset grouped lists (Swims, Settings, forms). */
.list { display: flex; flex-direction: column; gap: 0; padding: 0 var(--l) var(--xl); }
.list-section { margin-top: var(--xl); }
.list-section:first-child { margin-top: var(--s); }
.list-header { padding: 0 var(--l) 7px; font-size: 13px; color: var(--secondary); text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.list-header.plain { text-transform: none; font-size: 17px; font-weight: 600; color: var(--label); padding-left: var(--s); }
.list-footer { padding: 7px var(--l) 0; font-size: 13px; line-height: 18px; color: var(--secondary); }
.list-body { background: var(--surface); border-radius: 26px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: var(--m); padding: 11px var(--l); min-height: 44px; position: relative; width: 100%; text-align: left; }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: var(--l); right: 0; border-top: 0.5px solid var(--separator); }
.list-row.tappable { cursor: pointer; }
.list-row.tappable:active { background: var(--fill); }
.list-row .chevron { color: var(--tertiary); width: 9px; flex: none; }
.list-row.selected-row { background: color-mix(in srgb, var(--aqua) 14%, transparent); }
.checkcircle { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--tertiary); flex: none; display: grid; place-items: center; }
.checkcircle.on { background: var(--aqua); border-color: var(--aqua); color: #fff; }
.checkcircle svg { width: 13px; height: 13px; }
.toggle { width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; flex: none; transition: background 0.2s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15); transition: transform 0.2s; }
.toggle.on { background: var(--positive); }
.toggle.on::after { transform: translateX(20px); }
.stepper { display: inline-flex; border-radius: 9px; background: var(--fill); flex: none; }
.stepper button { width: 47px; height: 32px; display: grid; place-items: center; font-size: 20px; }
.stepper button + button { border-left: 0.5px solid var(--separator); }
.stepper button[disabled] { opacity: 0.3; }

.search { display: flex; align-items: center; gap: 6px; margin: 0 var(--l) var(--s); padding: 0 var(--s); height: 36px; border-radius: 10px;
  background: var(--fill); color: var(--secondary); }
.search input { flex: 1; border: 0; background: none; font: inherit; font-size: 17px; color: var(--label); outline: none; min-width: 0; }
.search svg { width: 16px; height: 16px; }

/* Sheets. */
.sheet-backdrop { position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.3s; }
.sheet-backdrop.shown { opacity: 1; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; top: 54px; z-index: 61; border-radius: 34px 34px 0 0; overflow: hidden;
  background: var(--grouped); transform: translateY(100%); transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1); display: flex; flex-direction: column; }
.app.no-status .sheet { top: 12px; }
.sheet.shown { transform: none; }
.sheet.medium { top: 45%; }
.sheet .navbar { padding-top: 0; height: 56px; position: relative; flex: none; }
.sheet .scroll { padding-top: var(--s); padding-bottom: 40px; }
.sheet .grabber { position: absolute; top: 5px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--tertiary); z-index: 3; }

/* A toast at the bottom, above the tab bar: Undo after a correction. */
.toast { position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 50; display: flex; align-items: center; gap: var(--m);
  padding: 12px var(--l); border-radius: 22px; background: var(--glass); box-shadow: 0 2px 14px rgba(0,0,0,0.15);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); font-size: 15px; transform: translateY(20px); opacity: 0; transition: 0.3s; }
.toast.shown { transform: none; opacity: 1; }

/* Empty states and notices. */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s); padding: var(--l) 0; text-align: center; }
.empty svg { width: 30px; height: 30px; color: var(--secondary); }
.notice { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; line-height: 18px; color: var(--secondary); }
.notice svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.demo-note { margin: 0 var(--l); padding: var(--m) var(--l); border-radius: 18px; background: color-mix(in srgb, var(--aqua) 10%, transparent);
  font-size: 13px; line-height: 18px; color: var(--secondary); }

/* Charts: SVG drawn by charts.js. */
.chart { width: 100%; overflow: visible; touch-action: pan-y; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--secondary); }
.chart .grid { stroke: var(--quaternary); stroke-width: 0.5; }
.chart .ruler { stroke: var(--reference); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .selection { stroke: var(--reference); stroke-width: 1; }
.chart-tip { font-size: 13px; }

/* The page inside the site's phone frame has no status bar of its own beyond the frame's. */
@media (min-width: 700px) and (min-height: 700px) {
  body.standalone .app { left: 50%; right: auto; width: 402px; margin-left: -201px; top: 50%; bottom: auto; height: 874px; margin-top: -437px;
    border-radius: 48px; overflow: hidden; box-shadow: 0 0 0 12px #1c1c1e, 0 30px 80px rgba(0,0,0,0.3); }
  body.standalone { background: #e6ebef; }
}

/* Full screen (a phone, or the app's own page on a computer): the bar that leads out of the demo. */
.demo-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: calc(44px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--l) 0; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 0.5px solid var(--separator); font-size: 15px; }
.demo-bar-title { font-weight: 600; color: var(--secondary); }
.demo-exit { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--aqua); font-weight: 600; text-decoration: none; }
.demo-exit svg { width: 15px; height: 15px; }
body.has-exit .app { top: calc(44px + env(safe-area-inset-top)); }
@media (min-width: 700px) and (min-height: 700px) {
  /* On a computer the phone stands in the middle of the window; the bar runs above it. */
  body.standalone.has-exit .app { top: calc(50% + 22px); }
  body.standalone .demo-bar { background: none; border-bottom: 0; }
}
