/* Sign-in and OAuth controls. Shared values live in tokens.css. */

.btn, .fields {
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-filter); backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-card);
}

/* ── btn: a quiet capsule. Ink for the one main action. ─────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--control-md); padding: var(--space-0) var(--space-5);
  border: 0; border-radius: var(--radius-full); color: var(--text-primary);
  font: var(--weight-medium) var(--text-sm) / var(--leading-none) var(--font-body);
  letter-spacing: var(--tracking-normal);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), background var(--duration-fast) ease, box-shadow var(--duration-base) var(--ease-out);
}
.btn:hover { background: var(--glass-fill-strong); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn--primary, .btn--primary:hover {
  background: var(--glass-fill-ink); color: var(--text-on-inverse); box-shadow: var(--shadow-ink);
}
.btn--primary:hover { background: var(--ink); }
.btn--block { width: 100%; }
.btn--grow { flex: 1; }

/* ── fields: rows share one white sheet, divided by hairlines; each row is
      a small label over a borderless input. ─────────────────────────────── */
.fields { display: flex; flex-direction: column; border-radius: var(--radius-lg); }
.field {
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-3) var(--space-4); border-top: var(--hairline) solid var(--border);
  transition: background var(--duration-fast) ease;
}
/* The group is not overflow-clipped. Each end field carries the card's radius
   so its inset focus ring follows the corner instead of being cut square. */
.field:first-child {
  border-top: 0;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.field:last-child {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}
.field:focus-within { background: var(--glass-fill-strong); box-shadow: inset 0 0 0 2px var(--focus); }
.field > label {
  font: var(--weight-medium) var(--text-xs) / var(--leading-snug) var(--font-body);
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--text-quiet);
}
.field > input {
  width: 100%; padding: var(--space-0); border: 0; outline: none; background: transparent;
  color: var(--text-primary); font: var(--text-md) / var(--leading-snug) var(--font-body);
}
.field__error { font: var(--text-sm) / var(--leading-normal) var(--font-body); color: var(--danger); }

/* ── alert: flash messages ──────────────────────────────────────────────── */
.alerts { display: flex; flex-direction: column; gap: var(--space-2); }
.alert {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--positive) 10%, var(--surface-card)); font-size: var(--text-sm);
}
.alert--error { background: color-mix(in srgb, var(--danger) 10%, var(--surface-card)); }

/* ── logo: the app icon, the zone-matrix B. */
.logo {
  display: block; flex: none;
  width: var(--logo); height: var(--logo);
  background: url("../favicon.8ff8c0e07bb3.svg") center / contain no-repeat;
}

/* ── public pages: home and the white paper ─────────────────────────────── */
.logo--hero { width: var(--orb-sm); height: var(--orb-sm); filter: drop-shadow(0 var(--space-3) var(--space-6) color-mix(in srgb, var(--ink) 22%, transparent)); }
.logo--sm { width: var(--control-sm); height: var(--control-sm); }

.home {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-6); padding: var(--space-12) var(--gutter); text-align: center;
}
.home__line {
  max-width: var(--measure-narrow);
  font: var(--weight-light) var(--text-xl) / var(--leading-snug) var(--font-display);
  letter-spacing: var(--tracking-tight); color: var(--text-quiet);
}
.home__links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
.home__links .btn { text-decoration: none; }

.paper-bar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--measure-wide); margin-inline: auto; padding: var(--space-4) var(--gutter);
}
.paper-bar__link { font-size: var(--text-sm); color: var(--text-quiet); text-decoration: none; }
.paper-bar__link:hover { color: var(--text-primary); }

.paper-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: var(--space-12);
  max-width: var(--measure-wide); margin-inline: auto; padding: var(--space-8) var(--gutter) var(--space-18);
}

.toc {
  position: sticky; top: var(--space-8); align-self: start;
  max-height: calc(100dvh - var(--space-12)); overflow-y: auto;
  font-size: var(--text-sm); line-height: var(--leading-snug);
}
.toc__title { color: var(--text-faint); margin-bottom: var(--space-3); }
.toc__list, .toc__sub { list-style: none; margin: var(--space-0); padding: var(--space-0); }
.toc__list > li + li { margin-top: var(--space-2); }
.toc__sub { padding-left: var(--space-3); margin-top: var(--space-1); }
.toc__sub li + li { margin-top: var(--space-1); }
.toc__sub a { color: var(--text-faint); }
.toc a { color: var(--text-quiet); text-decoration: none; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--text-primary); }
.toc a[aria-current="true"] { font-weight: var(--weight-medium); }

.toc-mobile { display: none; }

.paper { max-width: var(--measure-prose); font-size: var(--text-lg); line-height: var(--leading-normal); }
.paper > * + * { margin-top: var(--space-4); margin-bottom: var(--space-0); }
.paper h2, .paper h3 { scroll-margin-top: var(--space-8); font-family: var(--font-display); }
.paper > h2 {
  margin-top: var(--space-18); font-size: var(--text-display); font-weight: var(--weight-light);
  line-height: var(--leading-tight); letter-spacing: var(--tracking-tight);
}
.paper > h3 { margin-top: var(--space-8); font-size: var(--text-lg); font-weight: var(--weight-medium); }
.paper > h2 + *, .paper > h3 + * { margin-top: var(--space-3); }
.paper .paper__title {
  font-size: var(--text-2xl); font-weight: var(--weight-light); line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight); text-transform: none;
}
.paper-lede { font-size: var(--text-xl); line-height: var(--leading-snug); color: var(--text-quiet); }
.paper ul { list-style: disc; padding-left: var(--space-6); }
.paper ol { padding-left: var(--space-6); }
.paper li + li { margin-top: var(--space-2); }
.paper a { color: var(--mark); text-underline-offset: 0.2em; text-decoration-thickness: var(--hairline); }
.paper code { font-family: var(--font-mono); font-size: var(--text-sm); }
.paper strong { font-weight: var(--weight-medium); }

.formula {
  margin: var(--space-0); padding: var(--space-4) var(--space-5); overflow-x: auto;
  background: var(--glass-fill-inset); border-radius: var(--radius-sm);
  font: var(--weight-regular) var(--text-sm) / var(--leading-normal) var(--font-mono);
}

.paper table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: var(--leading-snug); }
.paper th { text-align: left; font-weight: var(--weight-medium); color: var(--text-quiet); }
.paper th, .paper td { padding: var(--space-2) var(--space-3) var(--space-2) var(--space-0); border-bottom: var(--hairline) solid var(--border); vertical-align: top; }

.cite { font-size: var(--text-xs); line-height: var(--leading-none); }
.paper .cite a { text-decoration: none; }
.paper .cite a:hover { text-decoration: underline; }

.references { margin-top: var(--space-18); }
.references h2 {
  font-size: var(--text-display); font-weight: var(--weight-light); line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight); margin: var(--space-0) var(--space-0) var(--space-4);
}
.paper .references__list { font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--text-quiet); }
.references__list a { word-break: break-all; }

@media (max-width: 860px) {
  .paper-layout { grid-template-columns: minmax(0, 1fr); padding-top: var(--space-4); }
  .toc { display: none; }
  .toc-mobile {
    display: block; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
    background: var(--glass-fill-inset); font-size: var(--text-sm);
  }
  .toc-mobile summary { cursor: pointer; color: var(--text-quiet); }
  .toc-mobile .toc__list { margin-top: var(--space-3); }
  .paper > h2 { margin-top: var(--space-12); }
  .paper table { display: block; overflow-x: auto; }
}

/* ── shared by the landing page and the dashboard ─────────────────────────
   The serif voice for figures and headings, and the paints for rings,
   bars and charts (zone, stage and score colours as on iOS). */
.serif { font-family: var(--font-serif); font-weight: var(--weight-regular); letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow {
  font: var(--weight-medium) var(--text-xs) / var(--leading-snug) var(--font-body);
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--text-quiet);
}
.on-dark .eyebrow { color: var(--sky); }
.unit { font-size: var(--text-sm); color: var(--text-faint); }
.serif .unit { font-family: var(--font-body); }
.muted { color: var(--text-quiet); }
.brand { display: flex; align-items: center; gap: var(--space-3); color: var(--ink); text-decoration: none; }
.brand .logo { width: var(--tile-sm); height: var(--tile-sm); }
.brand__name { font: var(--weight-regular) var(--text-stat) / var(--leading-none) var(--font-serif); }
.dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: currentColor; flex: none; }
.progress { height: var(--progress-height); border-radius: var(--radius-full); background: var(--border); overflow: hidden; }
.progress__fill { display: block; width: 82%; height: 100%; border-radius: inherit; background: var(--progress-fill); }
.rows svg { width: 100%; height: var(--space-2); display: block; }
.swatch { width: var(--space-2); height: var(--space-2); border-radius: 2px; flex: none; }
.swatch--line { height: 2px; }
.swatch--ring { border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1px var(--ink-faint); }
.zone-rows { display: flex; flex-direction: column; justify-content: space-between; height: 100%; min-height: var(--chart-sm); font-size: var(--text-sm); }
.zone-row { display: grid; grid-template-columns: var(--space-8) 1fr var(--tile); align-items: center; gap: var(--space-3); }
.zone-row b { font-weight: var(--weight-medium); }
.zone-row span { text-align: right; font-variant-numeric: tabular-nums; }
.zone-row svg { width: 100%; height: var(--space-3); display: block; overflow: visible; }


.ring-track { fill: none; stroke: var(--border); }
.ring-track--dark { fill: none; stroke: var(--rule-on-dark); }
.ring-value { fill: none; stroke-linecap: round; }
.ring-value--butt { stroke-linecap: butt; }
.ring-label { font-family: var(--font-serif); fill: var(--ink); text-anchor: middle; }
.ring-label--dark { fill: var(--paper); }
.ring-unit { font-family: var(--font-body); fill: var(--text-on-dark-quiet); text-anchor: middle; }
.ring-target { fill: none; stroke: var(--ink); stroke-linecap: round; }
.stroke-recovery-high { stroke: var(--score-recovery-high); }
.stroke-recovery-mid { stroke: var(--score-recovery-mid); }
.stroke-recovery-low { stroke: var(--score-recovery-low); }
.stroke-strain { stroke: var(--score-strain); }
.stroke-muscular { stroke: var(--score-strain-muscular); }
.stroke-sleep { stroke: var(--score-sleep); }
.stroke-sky { stroke: var(--sky); }
.stroke-mark { stroke: var(--mark); }
.stroke-quiet { stroke: var(--ink-faint); }
.bar-track { stroke: var(--wash-hover); stroke-linecap: round; }
.bar-value { stroke-linecap: round; }
.fill-zone-0, .zone-0 { fill: var(--zone-0); background: var(--zone-0); }
.fill-zone-1, .zone-1 { fill: var(--zone-1); background: var(--zone-1); }
.fill-zone-2, .zone-2 { fill: var(--zone-2); background: var(--zone-2); }
.fill-zone-3, .zone-3 { fill: var(--zone-3); background: var(--zone-3); }
.fill-zone-4, .zone-4 { fill: var(--zone-4); background: var(--zone-4); }
.fill-zone-5, .zone-5 { fill: var(--zone-5); background: var(--zone-5); }
.stroke-zone-1 { stroke: var(--zone-1); }
.stroke-zone-2 { stroke: var(--zone-2); }
.stroke-zone-3 { stroke: var(--zone-3); }
.stroke-zone-4 { stroke: var(--zone-4); }
.stroke-zone-5 { stroke: var(--zone-5); }
.fill-paper { fill: var(--paper); }
.stage-awake { fill: var(--stage-awake); background: var(--stage-awake); }
.stage-rem { fill: var(--stage-rem); background: var(--stage-rem); }
.stage-light { fill: var(--stage-light); background: var(--stage-light); }
.stage-deep { fill: var(--stage-deep); background: var(--stage-deep); }
.rate-0 { fill: var(--peach); }
.rate-1 { fill: var(--amber); }
.rate-2 { fill: var(--border); }
.rate-3 { fill: var(--sky); }
.rate-4 { fill: var(--mint); }
.marker { fill: var(--ink); }
.marker-bg { background: var(--ink); }
.chart-line { fill: none; stroke: var(--mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: url(#area-fade); }
.chart-area-stop-top { stop-color: var(--mint); stop-opacity: 0.16; }
.chart-area-stop-bottom { stop-color: var(--mint); stop-opacity: 0; }
.chart-grid { stroke: var(--border); }
.chart-avg { stroke: var(--ink-faint); stroke-dasharray: 3 4; }
.chart-dot { fill: var(--pebble); }
.chart-dot--focus { fill: var(--mark); }
.chart-axis { font-family: var(--font-body); font-size: var(--text-xs); fill: var(--text-faint); }
.icon-recovery { background: var(--mint); color: var(--white); }
.icon-danger { background: var(--coral); color: var(--white); }
.text-positive { color: var(--positive); }
.text-danger { color: var(--coral); }
.text-mark { color: var(--mark); }

