/* garmin-coach — base stylesheet
 *
 * Colour system, three layers:
 *   1. Palette  (--wada-*)  raw colours from Sanzo Wada's "A Dictionary of Color Combinations" (1933).
 *                           Hex values are digital approximations of the printed plates.
 *   2. Roles    (--bg, --text, --primary, ...)  what a colour is FOR. Components use ONLY these.
 *   3. Zones    (--zone-1 .. --zone-5)  heart-rate zones; the same Wada set reused for charts.
 * Dark mode later = one block that re-maps the role tokens (see bottom of :root section). Nothing else changes.
 */

/* ---------- Fonts (self-hosted, SIL OFL — see /static/fonts/OFL.txt) ---------- */
@font-face {
  font-family: "Barlow";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/static/fonts/barlow-400.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/static/fonts/barlow-600.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow Condensed";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/static/fonts/barlow-condensed-600.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("/static/fonts/barlow-condensed-700.woff2") format("woff2");
}

:root {
  /* 1. Palette — Sanzo Wada */
  --wada-prussian-blue: #1d3a48;
  /* main: ink */
  --wada-peacock-blue: #1b6a78;
  /* main: action */
  --wada-gull-gray: #e8ecea;
  /* main: paper */
  --wada-white: #fbfcfb;
  --wada-scarlet: #c63b2b;
  /* complementary to peacock blue */
  --wada-sulphur-yellow: #e5c23f;
  /* complementary highlight */
  --wada-cossack-green: #4a7d2a;
  /* support: success, zone 3 */
  --wada-cerulean-blue: #4f9ad9;
  /* zone 1 */
  --wada-antwerp-blue: #0d5f99;
  /* zone 2 */
  --wada-yellow-ocher: #d6a12c;
  /* zone 4 */
  --wada-glaucous-blue: #9db3bd;
  /* support: quiet, input borders */
  --wada-slate: #4c6470;
  /* support: secondary text */
  --wada-pale-slate: #c9d3d4;
  /* support: borders */

  /* 2. Roles — light theme (default) */
  color-scheme: light;
  --bg: var(--wada-gull-gray);
  --surface: var(--wada-white);
  --surface-strong: var(--wada-prussian-blue);
  /* dark panels */
  --on-surface-strong: var(--wada-gull-gray);
  --text: var(--wada-prussian-blue);
  --text-muted: var(--wada-slate);
  --border: var(--wada-pale-slate);
  --primary: var(--wada-peacock-blue);
  --primary-hover: var(--wada-prussian-blue);
  --on-primary: var(--wada-white);
  --accent: var(--wada-scarlet);
  --highlight: var(--wada-sulphur-yellow);
  --danger: var(--wada-scarlet);
  --success: var(--wada-cossack-green);
  --focus: var(--wada-sulphur-yellow);

  /* 3. Heart-rate zones (Z1 easy … Z5 max). Validated with the dataviz palette checker on the light
        surface: lightness band, chroma, colour-blind and normal-vision separation all pass. Contrast of
        Z1/Z4 is below 3:1, so zone charts always carry a visible legend or table. */
  --zone-1: var(--wada-cerulean-blue);
  --zone-2: var(--wada-antwerp-blue);
  --zone-3: var(--wada-cossack-green);
  --zone-4: var(--wada-yellow-ocher);
  --zone-5: var(--wada-scarlet);

  /* Type — scale ratio 1.25 on a 1rem base */
  --font-body: "Barlow", system-ui, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --step--1: 0.8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.815rem;

  /* Space & shape */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
  --radius: 3px;
  --content: 96rem;
}

/* Future dark mode: uncomment and tune. Only role tokens change.
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:         #12232b;
  --surface:    var(--wada-prussian-blue);
  --text:       var(--wada-gull-gray);
  --text-muted: var(--wada-glaucous-blue);
  --border:     #2c4a57;
  --primary:    #4fa3b0;
  --on-primary: var(--wada-prussian-blue);
}
*/

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* header / main / footer — footer always at the bottom */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  margin: 0 0 var(--space-3);
}

p {
  margin: 0 0 var(--space-3);
  max-width: 60ch;
}

a {
  color: var(--primary);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--primary-hover);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Header (partial) ---------- */
.site-header {
  background: var(--surface-strong);
  color: var(--on-surface-strong);
  /* Stays at the top of the window while the page scrolls. Below the phone sidebar panel (z-index 40). */
  position: sticky;
  top: 0;
  z-index: 30;
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3.5rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-2);
  letter-spacing: 0.01em;
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  color: var(--highlight);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.site-nav a,
.site-nav .link-button {
  color: var(--on-surface-strong);
  font-weight: 600;
}

.site-nav a:hover,
.site-nav .link-button:hover {
  color: var(--highlight);
}

.site-nav__user {
  color: var(--wada-glaucous-blue);
}

.site-nav a {
  text-decoration: none;
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  border-bottom-color: currentColor;
}

.site-nav a[aria-current="page"] {
  border-bottom-color: var(--highlight);
}

@media (max-width: 40rem) {
  .site-header__bar {
    flex-wrap: wrap;
    padding-block: var(--space-2);
  }

  .site-nav {
    gap: var(--space-3);
    flex-wrap: wrap;
  }

  .site-nav__user {
    display: none;
  }
}

/* ---------- Sidebar (partial) ---------- */
/* Desktop: a column of about 20% beside the page. Mobile: the sidebar is out of the way until the header's
   menu button adds .site-sidebar--open (static/js/sidebar.js). Without JS it simply stays above the page. */
.site-body {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.site-sidebar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
}

.site-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.site-sidebar__close {
  display: none;
  margin-left: auto;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: var(--step-1);
  line-height: 1;
  cursor: pointer;
}

.site-sidebar__close:hover {
  background: var(--bg);
  color: var(--primary-hover);
}

.site-sidebar__nav a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.site-sidebar__nav a:hover {
  background: var(--bg);
  color: var(--primary-hover);
}

.site-sidebar__nav a[aria-current="page"] {
  border-left-color: var(--primary);
  background: var(--bg);
  color: var(--primary);
}

.site-sidebar__heading {
  margin: var(--space-3) 0 var(--space-1);
  padding-inline: var(--space-3);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.menu-toggle {
  display: none;
  padding: var(--space-1) var(--space-3);
  border: 1px solid currentColor;
  border-radius: var(--radius);
  background: transparent;
  color: var(--on-surface-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.menu-toggle:hover {
  color: var(--highlight);
}

.site-main {
  min-width: 0;
}

/* The sidebar column needs a wide screen: below 87.5rem (1400px at the default font size) it is the slide-in panel
   opened by the Menu button. Keep this and the min-width below in step. */
@media (max-width: 87.49rem) {
  .menu-toggle:not([hidden]) {
    display: inline-flex;
  }

  .js .site-sidebar {
    display: none;
  }

  .js .site-sidebar--open .site-sidebar__close:not([hidden]) {
    display: block;
  }

  .js .site-sidebar--open {
    display: block;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(80vw, 18rem);
    overflow-y: auto;
    border-bottom: 0;
    box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--text) 40%, transparent);
  }
}

@media (min-width: 87.5rem) {
  .site-body {
    flex-direction: row;
  }

  .site-sidebar {
    flex: 0 0 20%;
    min-width: 12rem;
    max-width: 20rem;
    border-bottom: 0;
    border-right: 1px solid var(--border);
    padding-block: var(--space-5);
  }

  .site-main {
    flex: 1 1 0;
  }
}

/* Five heart-rate zone colours — the signature stripe under the header */
.zone-stripe {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 6px;
}

.zone-stripe span:nth-child(1) {
  background: var(--zone-1);
}

.zone-stripe span:nth-child(2) {
  background: var(--zone-2);
}

.zone-stripe span:nth-child(3) {
  background: var(--zone-3);
}

.zone-stripe span:nth-child(4) {
  background: var(--zone-4);
}

.zone-stripe span:nth-child(5) {
  background: var(--zone-5);
}

/* ---------- Main ---------- */
.site-main {
  flex: 1 0 auto;
  padding-block: var(--space-5);
}

@media (min-width: 52rem) {
  .site-main {
    padding-block: var(--space-6);
  }
}

/* ---------- Footer (partial) ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--step--1);
  padding-block: var(--space-4);
}

.site-footer p {
  margin: 0;
  max-width: none;
}

/* ---------- Auth pages ---------- */
.auth {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  align-items: start;
}

/* Small screens: form first (people came here to log in), intro below it */
.auth .form {
  order: -1;
}

@media (min-width: 52rem) {
  .auth {
    grid-template-columns: 1.15fr 1fr;
    gap: var(--space-6);
  }

  .auth .form {
    order: 0;
  }
}

.auth__title {
  font-size: var(--step-4);
  max-width: 14ch;
}

@media (min-width: 52rem) {
  .auth__title {
    font-size: var(--step-5);
  }
}

.auth__lead {
  color: var(--text-muted);
  font-size: var(--step-1);
  line-height: 1.45;
}

/* Sample extracted session: shows what the app reads from a screenshot */
.sample {
  margin: var(--space-5) 0 0;
  max-width: 30rem;
  border-left: 4px solid var(--primary);
  padding-left: var(--space-4);
}

.sample__caption {
  color: var(--text-muted);
  font-size: var(--step--1);
  margin-bottom: var(--space-2);
}

.sample__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-2);
  margin: 0 0 var(--space-3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: start;
  gap: var(--space-3) var(--space-5);
  margin: 0 0 var(--space-4);
}

.stats div {
  margin: 0;
}

@media (min-width: 30rem) {
  .stats {
    grid-template-columns: repeat(3, auto);
  }
}

.stats dt {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stats dd small {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--text-muted);
}

/* Time in heart-rate zones: widths set inline from data; 2px surface gap between segments */
.zones {
  display: flex;
  gap: 2px;
  height: 10px;
  border-radius: var(--radius);
  overflow: hidden;
}

.zones span {
  display: block;
}

.zones .z1 {
  background: var(--zone-1);
}

.zones .z2 {
  background: var(--zone-2);
}

.zones .z3 {
  background: var(--zone-3);
}

.zones .z4 {
  background: var(--zone-4);
}

.zones .z5 {
  background: var(--zone-5);
}

.zones-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: var(--step--1);
}

.zones-legend li::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: var(--space-1);
  border-radius: 1px;
  vertical-align: baseline;
}

.zones-legend .z1::before {
  background: var(--zone-1);
}

.zones-legend .z2::before {
  background: var(--zone-2);
}

.zones-legend .z3::before {
  background: var(--zone-3);
}

.zones-legend .z4::before {
  background: var(--zone-4);
}

.zones-legend .z5::before {
  background: var(--zone-5);
}

/* ---------- Forms ---------- */
.form {
  background: var(--surface);
  border-top: 4px solid var(--surface-strong);
  padding: var(--space-5) var(--space-4);
  max-width: 26rem;
  width: 100%;
}

@media (min-width: 52rem) {
  .form {
    padding: var(--space-5);
    justify-self: end;
  }
}

.form__title {
  font-size: var(--step-3);
}

.field {
  margin-bottom: var(--space-4);
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.field__hint {
  display: block;
  color: var(--text-muted);
  font-size: var(--step--1);
  margin-top: var(--space-1);
}

.input {
  display: block;
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--wada-glaucous-blue);
  border-radius: var(--radius);
}

/* Input with a button inside on the right (show/hide password) */
.input-group {
  position: relative;
}

.input-group .input {
  padding-right: 4.5rem;
}

.input-group__toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  padding: 0 var(--space-3);
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--primary);
}

.input-group__toggle:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.input-group__toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.input-group__toggle[hidden] {
  display: none;
}

.input:hover {
  border-color: var(--text-muted);
}

.input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  border-color: var(--text);
}

.button {
  display: inline-block;
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-1);
  letter-spacing: 0.02em;
  color: var(--on-primary);
  background: var(--primary);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.button:hover {
  background: var(--primary-hover);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.form__switch {
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
}

.alert {
  border-left: 4px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
  font-weight: 600;
}

/* ---------- Home ---------- */
.empty {
  max-width: 36rem;
}

.empty__title {
  font-size: var(--step-4);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Page head, panels, notices ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.page-title {
  font-size: var(--step-4);
  margin: 0;
}

.page-sub {
  color: var(--text-muted);
  margin: var(--space-1) 0 0;
}

.button--inline {
  width: auto;
  text-decoration: none;
}

.button--inline:hover {
  color: var(--on-primary);
}

.notice {
  max-width: none;
  border-left: 4px solid var(--highlight);
  background: var(--surface);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-5);
}

.alert--info {
  border-left-color: var(--highlight);
  background: color-mix(in srgb, var(--highlight) 12%, var(--surface));
  color: var(--text);
  font-weight: 400;
}

.panel {
  background: var(--surface);
  border-top: 4px solid var(--surface-strong);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel__title {
  font-size: var(--step-2);
}

.panel__subtitle {
  font-size: var(--step-1);
  margin-top: var(--space-4);
}

.panel__note {
  color: var(--text-muted);
  font-size: var(--step--1);
  margin: var(--space-3) 0 0;
}

/* ---------- Dashboard ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin: 0 0 var(--space-5);
}

@media (min-width: 52rem) {
  .kpis {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi {
  margin: 0;
  border-left: 4px solid var(--primary);
  padding-left: var(--space-3);
}

.kpi dt {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.kpi dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-4);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.kpi dd small {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--step-0);
  color: var(--text-muted);
}

.kpi__delta {
  color: var(--text-muted);
  font-size: var(--step--1);
  margin: var(--space-1) 0 0;
}

.dash__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 var(--space-4);
}

@media (min-width: 52rem) {
  .dash__grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Training time per day: one series, one hue; bar height = --v minutes against a 150 min scale */
.days {
  --max: 150;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: var(--space-2);
  height: 11rem;
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--border);
}

.days li {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  height: 100%;
  position: relative;
}

.days__bar {
  width: min(100%, 2.25rem);
  height: calc(var(--v) / var(--max) * 100%);
  min-height: 2px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
}

.days li:hover .days__bar {
  background: var(--primary-hover);
}

.days__label {
  position: absolute;
  bottom: calc(-1 * var(--space-4) - 2px);
  color: var(--text-muted);
  font-size: var(--step--1);
}

.days__value {
  position: absolute;
  top: calc(100% - var(--v) / var(--max) * 100% - 1.4rem);
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.days+.panel__note {
  margin-top: var(--space-5);
}

.zones--lg {
  height: 16px;
  margin-bottom: var(--space-4);
}

.zone-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.zone-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 400;
  padding-bottom: var(--space-1);
}

.zone-table td {
  padding: var(--space-1) 0;
  border-top: 1px solid var(--border);
}

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  margin-right: var(--space-2);
  vertical-align: -0.05em;
}

.swatch.z1 {
  background: var(--zone-1);
}

.swatch.z2 {
  background: var(--zone-2);
}

.swatch.z3 {
  background: var(--zone-3);
}

.swatch.z4 {
  background: var(--zone-4);
}

.swatch.z5 {
  background: var(--zone-5);
}

/* ---------- Tables ---------- */
.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.table thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--step--1);
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.table--compact th {
  font-weight: 400;
  color: var(--text-muted);
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

/* Screenshots: thumbnails + a native <dialog> lightbox */
.shots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: var(--space-3);
}

.shots a {
  display: block;
}

.shots img {
  display: block;
  width: 100%;
  height: 12rem;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--border);
  background: var(--bg);
}

.shots a:hover img {
  border-color: var(--primary);
}

.lightbox {
  padding: 0;
  border: 0;
  max-width: min(96vw, 60rem);
  max-height: 96vh;
  background: var(--surface);
  overflow: auto;
}

.lightbox::backdrop {
  background: color-mix(in srgb, var(--text) 70%, transparent);
}

.lightbox img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  margin: 0 auto;
}

.lightbox__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

/* Manual daily readings form */
.day-picker {
  max-width: 28rem;
  margin-bottom: var(--space-4);
}

.day-picker label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.day-picker__row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.day-picker__row .input {
  flex: 1;
}

.form--wide {
  max-width: none;
  justify-self: stretch;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0 var(--space-4);
}

.field__unit {
  color: var(--text-muted);
  font-weight: 400;
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.button--secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.button--secondary:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--primary);
}

/* Daily readings with an icon (dashboard) */
.icon {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.readings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--space-3);
}

.reading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.reading__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.reading__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.reading__label {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.reading__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-1);
  font-variant-numeric: tabular-nums;
}

.reading__day {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.badge {
  display: inline-block;
  padding: 0 var(--space-2);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
}

.link-button--danger {
  color: var(--danger);
}

.link-button--danger:hover {
  text-decoration-thickness: 2px;
}

/* Phones: each row becomes a card; the cell's data-label replaces the hidden header row */
@media (max-width: 40rem) {
  .table--cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table--cards,
  .table--cards tbody,
  .table--cards tr,
  .table--cards td {
    display: block;
  }

  .table--cards tr {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
  }

  .table--cards td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    border: 0;
    padding: var(--space-1) 0;
    white-space: normal;
  }

  .table--cards .table__action {
    justify-content: flex-end;
  }

  .table--cards td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--step--1);
  }

  .table--cards .num {
    text-align: right !important;
  }

  /* Admin logs on a phone: only time, user and the Details button; the rest is in the modal */
  .table--cards .log-hide-sm {
    display: none;
  }
}

/* ---------- Upload ---------- */
.upload .form {
  max-width: 28rem;
}

.input--file {
  padding: 0.5rem;
  background: var(--bg);
}

select.input {
  appearance: auto;
}

/* Original file name of an uploaded screenshot */
.shots__name {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--step--1);
  overflow-wrap: anywhere;
}

.file-name {
  max-width: 16rem;
  overflow-wrap: anywhere;
  white-space: normal !important;
}

/* Medical tests */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.chips a {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: var(--step--1);
}

.chips a:hover {
  border-color: var(--primary);
}

.chips a[aria-current="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.cell-note {
  display: block;
  color: var(--text-muted);
  font-size: var(--step--1);
}

.table__action {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.table__action form {
  margin: 0;
}

.badge--low {
  border-color: var(--accent);
  color: var(--accent);
}

.badge--normal {
  border-color: var(--success);
  color: var(--success);
}

.badge--high {
  border-color: var(--danger);
  color: var(--danger);
}

.group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4) 0;
  margin: 0 0 var(--space-4);
}

.group legend {
  font-weight: 600;
  padding-inline: var(--space-2);
}

.value-unit {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.value-unit .input {
  flex: 1;
  min-width: 0;
}

.value-unit select.input {
  flex: 0 0 auto;
  width: auto;
  max-width: 9rem;
}

.value-unit__fixed {
  color: var(--text-muted);
  white-space: nowrap;
}

textarea.input {
  resize: vertical;
}

/* Lightbox showing a PDF in a frame */
.lightbox [hidden] {
  display: none;
}

.lightbox--pdf[open] {
  display: flex;
  flex-direction: column;
  width: min(96vw, 64rem);
  height: 92vh;
}

.lightbox--pdf iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--bg);
}

.lightbox__open {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
}

.ocr-text {
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  max-height: 24rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--step--1);
  background: var(--bg);
  border: 1px solid var(--border);
}

.read-again {
  margin: var(--space-4) 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.history {
  margin: var(--space-1) 0 0;
  padding-left: var(--space-4);
}

details.cell-note summary {
  cursor: pointer;
}

/* Reports */
.report-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-4);
}

.report-nav__now {
  color: var(--text-muted);
}

.report-summary {
  margin: 0;
  padding-left: var(--space-4);
}

.report-summary li {
  margin-bottom: var(--space-1);
}

@media (min-width: 52rem) {
  .kpis--six {
    grid-template-columns: repeat(3, 1fr);
  }
}

.rbars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: var(--space-2);
  height: 13rem;
  border-bottom: 1px solid var(--border);
}

.rbars li {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rbars__col {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.rbars__bar {
  display: block;
  width: min(100%, 2.5rem);
  background: var(--primary);
  border-radius: 4px 4px 0 0;
}

.rbars__bar--peak {
  background: var(--accent);
}

.rbars__label,
.rbars__value {
  text-align: center;
  font-size: var(--step--1);
  color: var(--text-muted);
}

.rbars__value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.heat {
  list-style: none;
  margin: 0 0 var(--space-1);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.heat--head li {
  text-align: center;
  font-size: var(--step--1);
  color: var(--text-muted);
}

.heat__cell {
  min-height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
}

.heat__cell--blank {
  border-color: transparent;
}

.heat__cell--1 {
  background: color-mix(in srgb, var(--primary) 25%, var(--surface));
}

.heat__cell--2 {
  background: color-mix(in srgb, var(--primary) 55%, var(--surface));
}

.heat__cell--3 {
  background: var(--primary);
  color: var(--on-primary);
}

@media print {

  .site-header,
  .site-sidebar,
  .site-footer,
  .no-print {
    display: none !important;
  }

  .panel {
    break-inside: avoid;
    box-shadow: none;
  }

  .rbars__bar,
  .heat__cell {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

/* ---------- Tech page (public) ---------- */
/* .tech__inner { max-width: 60rem; } */
.tech__lede {
  font-size: var(--step-1);
  max-width: none;
}

.tech h2 {
  margin-top: var(--space-5);
}

.tech ul,
.tech ol {
  padding-left: var(--space-4);
  max-width: none;
}

.tech li {
  margin-bottom: var(--space-3);
}

.tech__stages {
  display: grid;
  gap: var(--space-2);
}

.tech__note {
  color: var(--text-muted);
  max-width: none;
}

.tech__shot {
  margin: var(--space-4) 0 0;
}

.tech__shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tech__shot figcaption {
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: var(--step--1);
}

.tech__pre {
  overflow-x: auto;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--step--1);
  line-height: 1.35;
}

.tech th[scope="row"] {
  white-space: nowrap;
  vertical-align: top;
}

/* ---------- Food ---------- */
.day-nav {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
}

.meal-list {
  display: grid;
  gap: var(--space-4);
}

.meal__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: baseline;
}

.meal__type {
  text-transform: capitalize;
}

.meal__head small {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 400;
}

.meal__actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.meal__actions form {
  margin: 0;
}

.meal__note {
  color: var(--text-muted);
}

.food-new__top {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.meal-rows {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.meal-rows legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: var(--space-2);
}

.meal-row {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: minmax(0, 3fr) minmax(5rem, 1fr) 3.5rem;
  align-items: center;
}

.meal-row__unit {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.food-check {
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  border-left: 4px solid var(--border);
  background: var(--bg);
}

.food-check--food {
  border-left-color: var(--success);
}

.food-check--not_food,
.food-check--error {
  border-left-color: var(--danger);
}

.food-check--unsure {
  border-left-color: var(--highlight);
}

.food-check__text {
  margin: 0 0 var(--space-2);
  max-width: none;
}

.food-check__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
}

.food-check__confirm {
  display: block;
  font-weight: 600;
}

.food-foods__lists {
  display: grid;
  gap: var(--space-4);
}

/* ---------- News ---------- */
.news__grid {
  display: grid;
  gap: var(--space-4);
  align-items: start;
}

.news__feeds {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 64rem) {
  .news__grid {
    grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
  }
}

.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.news-item {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.news-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.news-item__title {
  font-weight: 600;
  font-size: var(--step-1);
  line-height: 1.25;
}

.news-item__meta {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--step--1);
  max-width: none;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.feed-list__item {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: start;
}

.feed-list__item form {
  margin: 0;
}

.feed-list__url {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.news-detail {
  display: none;
}

.news-detail__title {
  font-size: var(--step-2);
  margin-right: var(--space-5);
}

.news-detail__text {
  max-width: none;
}

.news-detail__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
}

/* ---------- Weather widget (home) ---------- */
.weather {
  margin-bottom: var(--space-4);
}

.weather__body {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-5);
  align-items: center;
}

.weather__now {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
}

.weather__icon {
  font-size: var(--step-4);
  line-height: 1;
}

.weather__temp {
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 700;
  line-height: 1;
}

.weather__text small {
  color: var(--text-muted);
}

.weather__days {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.weather__days li {
  white-space: nowrap;
}

.weather__days small {
  color: var(--text-muted);
}

/* ---------- Private notes ---------- */
:root {
  --mood-sad: var(--wada-antwerp-blue);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
}

.filters .field {
  margin-bottom: 0;
  min-width: 10rem;
}

.filters__actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

/* Admin logs: the row's fields are listed in the table until JS can show them in the modal */
.row-detail {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-4);
  margin: 0;
}

.row-detail dt {
  font-weight: 600;
  color: var(--text-muted);
}

.row-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.row-detail pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: var(--step--1);
}

.log-js .table .row-detail {
  display: none;
}

/* Admin files below 1366px: only the upload time and the user stay in the table; the rest is in the Details modal */
.files-detail-cell {
  display: none;
}

@media (max-width: 1365px) {
  .table .files-hide {
    display: none;
  }

  .table .files-detail-cell {
    display: table-cell;
  }
}

@media (max-width: 40rem) {
  .table--cards .files-detail-cell {
    display: flex;
  }
}

/* Admin logs on a phone: the filters are folded away until the Filters button (JS) unfolds them */
.log-bar {
  display: none;
}

@media (max-width: 40rem) {
  .log-js .log-bar {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
  }

  .log-js .log-filters {
    display: none;
  }

  .log-js .log-filters--open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
}

.row-modal,
.news-modal {
  width: min(44rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: var(--space-4);
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-top: 4px solid var(--surface-strong);
  border-radius: var(--radius);
}

.row-modal::backdrop,
.news-modal::backdrop {
  background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
}

.row-modal__title {
  font-size: var(--step-2);
}

.row-modal__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-block: var(--space-3);
}

.pager__info {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.pager__off {
  color: var(--text-muted);
  opacity: 0.5;
  padding-inline: var(--space-3);
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.note__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.note__time {
  color: var(--text-muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.note__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.note__body {
  margin: 0 0 var(--space-3);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.input--area {
  min-height: 10rem;
  resize: vertical;
}

.badge[class*="badge--tag-"],
.badge[class*="badge--mood-"] {
  text-transform: capitalize;
}

/* Tag (priority) */
.badge--tag-urgent {
  border-color: var(--danger);
  color: var(--danger);
}

.badge--tag-medium {
  border-color: var(--highlight);
  color: var(--text);
  background: color-mix(in srgb, var(--highlight) 25%, var(--surface));
}

.badge--tag-low {
  border-color: var(--success);
  color: var(--success);
}

/* Sentiment (mood) */
.badge--mood-happy {
  border-color: var(--success);
  color: var(--success);
}

.badge--mood-calm {
  border-color: var(--primary);
  color: var(--primary);
}

.badge--mood-neutral {
  border-color: var(--border);
  color: var(--text-muted);
}

.badge--mood-sad {
  border-color: var(--mood-sad);
  color: var(--mood-sad);
}

.badge--mood-anxious {
  border-color: var(--highlight);
  color: var(--text);
  background: color-mix(in srgb, var(--highlight) 25%, var(--surface));
}

.badge--mood-depressed {
  border-color: var(--accent);
  color: var(--accent);
}

.note__body--locked {
  color: var(--text-muted);
  font-style: italic;
}

/* Privacy banner */
.privacy {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  background: var(--surface-strong);
  color: var(--on-surface-strong);
  border-left: 6px solid var(--highlight);
  border-radius: var(--radius);
}

.privacy p {
  margin: 0 0 var(--space-2);
}

.privacy__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-2);
}

.privacy__example {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--step-2);
  font-weight: 600;
  color: var(--highlight);
  overflow-wrap: anywhere;
  user-select: all;
}

.privacy__text {
  font-size: var(--step--1);
}

/* Note view dialog; the list shows a short preview once JS can open it */
.note__view {
  margin-top: var(--space-2);
}

.notes--js .note__body:not(.note__body--full) {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notes--js .note__actions {
  display: none;
}

.note-dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: var(--space-4);
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-top: 4px solid var(--surface-strong);
  border-radius: var(--radius);
}

.note-dialog::backdrop {
  background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
}

.note-dialog .note__head {
  margin-right: var(--space-5);
}

.note__body--full {
  font-size: var(--step-1);
}

.note-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.note-dialog__actions form {
  margin: 0;
}

.button--danger {
  color: var(--danger);
  border-color: var(--danger);
}

.button--danger:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

/* Cookie notice */
.cookie-banner {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  padding: var(--space-3) 0;
  background: var(--surface-strong);
  color: var(--on-surface-strong);
  border-top: 4px solid var(--highlight);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
}

.cookie-banner__text {
  margin: 0;
  flex: 1 1 24rem;
  font-size: var(--step--1);
}

.cookie-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media print {
  .cookie-banner {
    display: none !important;
  }
}

/* Profile */
.profile__password {
  margin-top: var(--space-4);
}

.profile__fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.profile__fieldset:disabled {
  opacity: 0.55;
}

.profile__fieldset:disabled .button {
  cursor: not-allowed;
}

.site-nav__user:hover {
  text-decoration: underline;
}