:root {
  /* typography */
  --wl-font-family-primary: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  /* Every number (durations, hours, °C, knots, dates in tables, value axes)
     sets in the mono companion with tabular figures — see DESIGN.md. */
  --wl-font-family-mono: "Atkinson Hyperlegible Mono", ui-monospace, monospace;
  --wl-font-size-base: 16px;
  --wl-font-size-sm: 14px;
  --wl-font-size-xs: 12px;

  /* color — chip */
  /* Location chips are actions, so they're Wave: 8% / 16% / 30% tints over
     white, the selected chip is the primary fill. */
  --wl-color-chip-bg-default: #EEF4F7;        /* Wave 8%; primary-deep text 6.1:1 */
  --wl-color-chip-bg-hover: #DCE9EF;          /* Wave 16%; primary-deep text 5.4:1 */
  --wl-color-chip-bg-selected: #267698;       /* Wave (--rz-primary); white text 5.09:1 */
  --wl-color-chip-text-default: #1F6280;      /* primary-deep (location name) */
  --wl-color-chip-text-distance: #3E4C55;     /* muted (distance), 8.0:1 on the chip */
  --wl-color-chip-text-selected: #FFFFFF;
  --wl-color-chip-border-default: #BED6E0;    /* Wave 30%, border only */

  /* color — text */
  --wl-color-text-primary: #0F1B22;           /* ink (sport+date+duration), 17.5:1 on paper */
  --wl-color-text-secondary: #3E4C55;         /* muted (admin label), 8.9:1 on paper */
  --wl-color-text-tertiary: #5E6D75;          /* bullets and small captions, 5.4:1 on paper, 4.7:1 on band */
  --wl-color-text-muted: #4B5563;             /* gray-600 (distance, truncation) */

  /* color — surfaces */
  --wl-color-surface-card: #FFFFFF;
  --wl-color-surface-thumbnail-fallback: #F3F4F6;  /* gray-100 */
  --wl-color-border-subtle: #E5E7EB;          /* gray-200 */
  --wl-color-border-divider: #F3F4F6;         /* gray-100 */

  /* radii */
  --wl-radius-card: 8px;
  --wl-radius-pill: 9999px;
  --wl-radius-button: 4px;
  --wl-radius-thumbnail: 6px;

  /* motion */
  --wl-motion-row-drain-duration: 300ms;
  --wl-motion-widget-collapse-duration: 200ms;
  --wl-motion-saved-pulse-duration: 1500ms;
  --wl-motion-easing: ease-out;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --wl-motion-row-drain-duration: 0ms;
    --wl-motion-widget-collapse-duration: 0ms;
    --wl-motion-saved-pulse-duration: 0ms;
  }
}

/* DR6 — override Radzen's font to use the Atkinson Hyperlegible Next stack everywhere.
   Radzen reads --rz-text-font-family for body via `:root:has(.rz-layout) body`,
   which has higher specificity than a plain `body { font-family: ... }`, so the
   override has to flow through Radzen's own variable. --rz-font-family-sans-serif
   is kept for any code path that reads it directly. */
:root {
  --rz-font-family-sans-serif: var(--wl-font-family-primary);
  --rz-text-font-family: var(--wl-font-family-primary);

  /* Heading weight contrast: Radzen's defaults are all 400. .rz-text-h{1..6}
     selectors win over plain h1/h2 selectors in app.css, so we have to set the
     weights through Radzen's own design tokens. */
  /* Atkinson Hyperlegible Next is loaded at 400 and 700 only, so every
     heading level takes 700; a 500/600 would fall back to the nearest file. */
  --rz-text-h1-font-weight: 700;
  --rz-text-h2-font-weight: 700;
  --rz-text-h3-font-weight: 700;
  --rz-text-h4-font-weight: 700;
  --rz-text-h5-font-weight: 700;
  --rz-text-h6-font-weight: 700;

  /* Sizes from DESIGN.md. Pages style their h1 at H3 and their section titles
     at H4/H5, so those steps carry the title (2rem) and section (1.375rem)
     sizes; Radzen's own scale ran 42px and 30px. */
  --rz-text-h3-font-size: 2rem;
  --rz-text-h3-line-height: 1.2;
  --rz-text-h4-font-size: 1.375rem;
  --rz-text-h4-line-height: 1.25;
  --rz-text-h4-letter-spacing: 0;
  --rz-text-h5-font-size: 1.125rem;
  --rz-text-h5-line-height: 1.3;
  --rz-text-h6-font-size: 1rem;
  --rz-text-h6-letter-spacing: 0;

  /* Brand re-key: Wave (#267698), a mid-tone sea blue replacing the original
     indigo (#4340D2). Cascades through Radzen's --rz-primary chain to the top
     app bar (--rz-header-background-color = var(--rz-primary)), primary CTA
     buttons, .rz-color-primary text, and the active nav-item highlight. The
     four derived shades match Radzen's naming convention:
       light/lighter -> tints (lighter = 12% alpha for hover/wash backgrounds)
       dark/darker  -> shades (used for hover/active states on solid surfaces)
     --rz-on-primary stays #ffffff (white). Wave started at #2E86AB, but white
     on it is only 4.11:1, under WCAG AA's 4.5:1 for the 14-16px button and
     header text it carries. #267698 is the lightest shade of the same hue
     that clears AA both as a fill under white text (5.09:1) and as link text
     on the #F5F5F5 page background (4.67:1). */
  --rz-primary: #267698;
  --rz-primary-light: #5BA8C9;
  --rz-primary-lighter: rgba(38, 118, 152, 0.12);
  --rz-primary-dark: #1F6280;
  --rz-primary-darker: #1B5068;

  /* Link color: route through the brand primary so breadcrumbs, body links,
     and Radzen .rz-link pick up Wave instead of the default magenta secondary
     (#e31c65). Keeps single-accent discipline. */
  --rz-link-color: var(--rz-primary);
  --rz-link-hover-color: var(--rz-primary-dark);

  /* Brand re-key follow-up: --rz-on-primary-lighter is the text/foreground
     color for elements sitting on a --rz-primary-lighter (12% alpha primary)
     tint. Radzen Material defaults this to the OLD indigo (#4340D2) — a
     hardcoded literal, NOT a var(--rz-primary) reference. The pilot brand
     re-key didn't reach it, leaving indigo leaks on every active sidebar
     nav item, dropdown selected highlight, switch toggle, and any other
     surface that uses .rz-state-highlight or panel-menu-item-active. This
     points it at primary-deep, so the active nav item reads deep Wave on the
     Wave tint. */
  --rz-on-primary-lighter: var(--rz-primary-dark);

  /* Semantic fills. Radzen Material's defaults put white text on #4caf50
     (2.78:1), #f44336 (3.68:1), #2196f3 (3.12:1) and #ff9800 (2.16:1), and
     its tinted (Shade.Lighter) alerts reuse the base hue as text, 1.8-2.8:1.
     These are the Material 700/900 steps of the same hues, chosen so white
     text clears WCAG AA. Warning keeps its orange fill and takes dark text
     instead: no orange dark enough for white still reads as a warning. */
  --rz-success: #2E7D32;
  --rz-success-dark: #1B5E20;
  --rz-success-darker: #144A18;
  --rz-success-lighter: rgba(46, 125, 50, 0.16);
  --rz-on-success-lighter: #1B5E20;

  --rz-danger: #D32F2F;
  --rz-danger-dark: #B71C1C;
  --rz-danger-darker: #8E1515;
  --rz-danger-lighter: rgba(211, 47, 47, 0.2);
  --rz-on-danger-lighter: #B71C1C;

  /* Info is slate, not a second blue: Wave is the only blue in the app, and an
     info message is neutral status. White on #3E4C55 is 8.9:1; ink on the
     12% tint is 14.5:1. */
  --rz-info: #3E4C55;
  --rz-info-light: #6B7A82;
  --rz-info-dark: #2C3840;
  --rz-info-darker: #0F1B22;
  --rz-info-lighter: rgba(62, 76, 85, 0.12);
  --rz-on-info-lighter: #0F1B22;

  /* Secondary is slate too: Radzen's magenta default (#e31c65) was a second
     accent. It now only colors the neutral Retired / Inactive / Archived
     badges; secondary buttons use ButtonStyle.Light (paper, ink outline). */
  --rz-secondary: #3E4C55;
  --rz-secondary-light: #6B7A82;
  --rz-secondary-dark: #2C3840;
  --rz-secondary-darker: #0F1B22;
  --rz-secondary-lighter: rgba(62, 76, 85, 0.12);
  --rz-on-secondary-lighter: #0F1B22;

  --rz-on-warning: #212121;
  --rz-on-warning-lighter: #8A4B00;
}

/* DESIGN.md "chart table in daylight": white paper, ink text, cool slate
   rules and bands, one attention fill. Ratios are against paper unless noted. */
:root {
  --wl-color-paper: #FFFFFF;
  --wl-color-band: #EDF1F3;
  --wl-color-ink: #0F1B22;                    /* 17.5:1 */
  --wl-color-muted: #3E4C55;                  /* 8.9:1, 7.8:1 on band */
  --wl-color-rule: #C3CDD3;                   /* dividers only, never text */
  --wl-color-control-edge: #6B7A82;           /* input/segmented borders, 4.4:1 (3:1 needed) */
  --wl-color-attention: #F2C300;              /* fill only, ink text on it 10.5:1 */
  --wl-color-on-attention: #0F1B22;
  --wl-shadow-overlay: 0 4px 16px rgba(15, 27, 34, 0.18);

  /* The ends of the one-hue chart ramp (YearSeriesPalette interpolates
     between the same two): Wave 25% toward white, 3.2:1 on white, and a deep
     Wave, 14.6:1. Wave itself sits between them. */
  --wl-color-chart-light: #5C98B2;
  --wl-color-chart-dark: #0E2C3A;

  --rz-body-background-color: var(--wl-color-paper);
  --rz-text-color: var(--wl-color-ink);
  --rz-text-title-color: var(--wl-color-ink);
  --rz-text-secondary-color: var(--wl-color-muted);
  --rz-text-tertiary-color: var(--wl-color-muted);
  --rz-grid-stripe-background-color: var(--wl-color-band);
  --rz-grid-cell-border: 1px solid var(--wl-color-rule);

  /* Column headers: 13px bold muted labels over a 1.5px ink rule. */
  --rz-grid-header-font-size: 0.8125rem;
  --rz-grid-header-font-weight: 700;
  --rz-grid-header-color: var(--wl-color-muted);
  --rz-grid-header-cell-border-bottom: 1.5px solid var(--wl-color-ink);

  /* Focus: a visible 3px Wave outline, offset 2px, on every control. */
  --rz-outline-width: 3px;
  --rz-outline-offset: 2px;
  --rz-outline-color: var(--rz-primary);

  /* Inputs and other bordered controls: 1.5px control-edge (4.4:1, 3:1 needed). */
  --rz-border-normal: 1.5px solid var(--wl-color-control-edge);

  --wl-touch-target: 48px;

  /* Rows: 40px on desktop (48px on phones, below). Radzen's 0.625rem cell
     padding around the 32px row buttons made rows 51px. */
  --rz-grid-cell-padding: 0.25rem 1rem;

  /* Disabled controls stay legible: 45%, not Radzen's 20%. */
  --rz-button-disabled-opacity: 0.45;

  /* Radzen's warm Material greys re-pointed at the cool slate family, so its
     internal surfaces (hovers, panels, dividers) match the rest of the page. */
  --rz-base-50: #F6F8F9;
  --rz-base-100: #EDF1F3;
  --rz-base-200: #E2E7EA;
  --rz-base-300: #C3CDD3;
  --rz-base-400: #9AA7AE;
  --rz-base-500: #6B7A82;
  --rz-base-600: #5E6D75;
  --rz-base-700: #3E4C55;
  --rz-base-800: #2A363D;
  --rz-base-900: #0F1B22;

  /* Spacing: the 4px scale from DESIGN.md. Related items sit 8-12px apart,
     sections 32-48px. */
  --wl-space-1: 4px;
  --wl-space-2: 8px;
  --wl-space-3: 12px;
  --wl-space-4: 16px;
  --wl-space-5: 24px;
  --wl-space-6: 32px;
  --wl-space-7: 48px;

  /* Flat: no shadows on cards, panels, buttons, alerts or the app bar. The
     --rz-shadow-N scale feeds both Radzen's component variables and the
     rz-shadow-N utility classes in markup, so zeroing it here flattens both.
     Cards take a 1px rule instead so they still read against white paper. */
  --rz-shadow-1: none;
  --rz-shadow-2: none;
  --rz-shadow-3: none;
  --rz-shadow-4: none;
  --rz-shadow-5: none;
  --rz-shadow-6: none;
  --rz-shadow-7: none;
  --rz-shadow-8: none;
  --rz-shadow-9: none;
  --rz-shadow-10: none;

  /* Overlays float above the page, so they keep the one shadow: an offset
     and a soft blur, never a zero-offset glow. */
  --rz-dialog-shadow: var(--wl-shadow-overlay);
  --rz-dropdown-panel-shadow: var(--wl-shadow-overlay);
  --rz-overlay-shadow: var(--wl-shadow-overlay);
  --rz-context-menu-box-shadow: var(--wl-shadow-overlay);
  --rz-datepicker-panel-shadow: var(--wl-shadow-overlay);
  --rz-timespanpicker-popup-shadow: var(--wl-shadow-overlay);
  --rz-splitbutton-menu-shadow: var(--wl-shadow-overlay);
  --rz-notification-shadow: var(--wl-shadow-overlay);
  --rz-tooltip-shadow: var(--wl-shadow-overlay);
}

/* Focus on everything Radzen's outline vars don't reach (plain links, nav
   anchors, chips): the same 3px Wave outline, offset 2px. */
:focus-visible {
  outline: 3px solid var(--rz-primary);
  outline-offset: 2px;
}

/* An invalid field's 1.5px border turns error; the message sits under it. */
.rz-form-field:has(.invalid) .rz-form-field-content {
  border-color: var(--rz-danger);
}

/* Form labels sit above the input: 13px bold, like the column headers. The
   size needs !important: Radzen sets 0.75rem through selectors up to five
   classes deep. Color stays Radzen's: muted (the placeholder token), Wave on
   focus, error on an invalid field. */
.rz-form-field-label {
  font-size: 0.8125rem !important;
  font-weight: 700;
}

/* Radzen 11.5.1's .rz-card rule never reads --rz-card-border, so the 1px rule
   that replaces the card shadow is set here. Pages still built from cards read
   as ruled panels on white until they move to plain sheets. */
.rz-card {
  border: 1px solid var(--wl-color-rule);
}

/* The one "needs you" mark: flag-yellow fill, ink mono text. Used only for the
   Inbox count, unresolved/unmapped tags and today on the calendar; never as
   text color, never in alerts (warning orange owns those). */
.wl-attention-marker {
  display: inline-block;
  background-color: var(--wl-color-attention);
  color: var(--wl-color-on-attention);
  font-family: var(--wl-font-family-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  padding: 0 6px;
  border-radius: var(--wl-radius-button);
}

.wl-nav-count {
  margin-left: 8px;
}

/* Today in the calendar's month and year views (Calendar.razor SlotRender). */
.wl-today-slot .rz-slot-title {
  display: inline-block;
  background-color: var(--wl-color-attention);
  color: var(--wl-color-on-attention);
  font-family: var(--wl-font-family-mono);
  font-weight: 500;
  padding: 0 6px;
  border-radius: var(--wl-radius-button);
}

/* Numbers line up down a column like a log. A horizontal bar chart swaps
   Radzen's axis classes (the names sit on .rz-value-axis, the numbers on
   .rz-category-axis), so the numeric axis is picked per chart type. */
.wl-num,
.wl-num *:not(.rzi):not(.material-icons),
.rz-scheduler .rz-slot-title,
.rz-chart:not(:has(.rz-bar-series)) .rz-value-axis .rz-tick-text,
.rz-chart:has(.rz-bar-series) .rz-category-axis .rz-tick-text {
  font-family: var(--wl-font-family-mono);
  font-variant-numeric: tabular-nums;
}

.rz-grid-table tbody > tr.rz-data-row > td {
  height: 40px;
}

.rz-button.rz-state-disabled,
.rz-button:disabled {
  cursor: not-allowed;
}

/* Running text keeps a readable measure; tables and charts still run full width. */
main p,
main .rz-text-body1,
main .rz-text-subtitle1 {
  max-width: 68ch;
}

/* Zebra rows on every grid. Hover keeps Radzen's own highlight. */
.rz-grid-table tbody > tr.rz-data-row:nth-child(even):not(:hover) > td {
  background-color: var(--wl-color-band);
}

/* Secondary buttons are paper with an ink outline, not Radzen's grey fill.
   Icon-only row buttons (edit) take the quieter control edge. */
.rz-button.rz-light:not(.rz-variant-text) {
  background-color: var(--wl-color-paper);
  color: var(--wl-color-ink);
  border: 1.5px solid var(--wl-color-ink);
}

.rz-button.rz-light.rz-button-icon-only:not(.rz-variant-text) {
  border-color: var(--wl-color-control-edge);
}

@media (max-width: 640px) {
  /* Wet hands at the beach: 48px rows and touch targets on a phone. */
  .rz-grid-table tbody > tr.rz-data-row > td {
    height: var(--wl-touch-target);
  }

  .rz-button,
  .rz-header a {
    min-height: var(--wl-touch-target);
  }

  .rz-header a {
    display: inline-flex;
    align-items: center;
  }

  .rz-button.rz-button-icon-only {
    min-width: var(--wl-touch-target);
  }

  /* The dropdown clear (x) sits inside a 38px input: grow its tap area to the
     touch target without growing the input. */
  .rz-dropdown-clear-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--wl-touch-target);
    min-height: var(--wl-touch-target);
    margin-block: -5px;
  }
}

/* Alerts here are status and empty states, not things to dismiss: RadzenAlert
   defaults AllowClose to true, so the close icon is hidden in one place rather
   than on each alert. Action buttons inside an alert (Retry) are unaffected. */
.rz-alert > .rz-button.rz-button-icon-only.rz-variant-text {
  display: none;
}

/* Below Radzen's md breakpoint, SizeMD columns stack, so a header button that
   sat right of the title wraps under it and should line up left. Only layout
   columns: right-aligned grid header cells carry the same class and must keep
   lining up with their numbers. (This replaces ~30 pasted per-page copies that
   also caught the th cells.) */
@media (max-width: 768px) {
  [class*="rz-col"].rz-text-align-right {
    text-align: left !important;
  }
}

/* Present for screen readers, not drawn. */
.wl-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ruled sheets (DESIGN.md: "one sheet per page"). A page section is a stretch
   of the white page under a 1px rule, not a box: no border, no fill, content
   flush with the page title. Cards remain only for Inbox rows, dialogs and
   form containers. Applied to RadzenCard so section markup stays as it is. */
.rz-card.wl-sheet {
  background-color: transparent;
  border: 0;
  border-top: 1px solid var(--wl-color-rule);
  border-radius: 0;
  padding: 24px 0 0;
}

/* A section that opens a form container (Strava, Garmin settings) needs no
   rule against the container's own edge. */
.rz-card:not(.wl-sheet) > .rz-stack > .rz-card.wl-sheet:first-child,
.rz-card:not(.wl-sheet) > .rz-card.wl-sheet:first-child {
  border-top: 0;
  padding-top: 0;
}

/* Inline code (setup tips) in ink, not Bootstrap's pink. */
code {
  color: var(--wl-color-ink);
}

/* Summary row: a ruled line of labelled figures instead of KPI tiles. */
.wl-summary-row {
  border-top: 1px solid var(--wl-color-rule);
  border-bottom: 1px solid var(--wl-color-rule);
}

.rz-card.wl-summary-cell {
  background-color: transparent;
  border: 0;
  border-radius: 0;
  padding: 16px 0;
}

.wl-summary-cell .rz-text-overline {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--wl-font-size-xs);
  font-weight: 700;
  color: var(--wl-color-muted);
}

.wl-summary-cell .rz-text-h4 {
  font-family: var(--wl-font-family-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* Chart statistics panels: one neutral band, ink title. They used five
   different tints (info, warning, success, secondary, primary) for one role. */
.rz-card.wl-stats-panel {
  background-color: var(--wl-color-band);
}

.wl-stats-title {
  color: var(--wl-color-ink);
}

/* Restraint pass (partial): page H1/H2 use Wave through Class="rz-color-primary"
   in markup. That gave the page-top heading the same color as primary CTAs and
   active nav, flattening hierarchy. Override Wave → near-black ONLY when the
   class lands on the page-top heading sizes (rz-text-h3/h4 = the H1/H2 we
   render). Card-section H5 titles keep Wave so they still read as section
   anchors. Standalone .rz-color-primary on links, badges, breadcrumb anchors
   keeps Wave too — only the heading combo is restrained.
   !important matches the precedent: Radzen's own .rz-color-primary uses
   !important in material-base.css, so without it the brand color wins
   regardless of source order or specificity.
   NOTE: the top-bar half of the restraint pass (white header + neutral
   wordmark) was reverted post-visual-review — the page read as bland
   without the Wave header anchoring brand identity. H1 desaturation alone
   gives enough hierarchy contrast against the Wave-colored CTAs. */
:root:has(.rz-layout) .rz-text-h3.rz-color-primary,
:root:has(.rz-layout) .rz-text-h4.rz-color-primary {
  color: var(--wl-color-text-primary) !important;
}

body {
  font-family: var(--wl-font-family-primary);
}

/* RadzenText sets its own body color, so text inside a filled alert stayed
   #424242 on the solid fill (2.0:1 on danger) instead of taking the alert's
   on-color. */
.rz-alert.rz-variant-filled.rz-shade-default [class*="rz-text-"] {
  color: inherit;
}
