/* ============================================================================
   Health cockpit — dark scientific dashboard
   Design language: Vercel / Linear surfaces + shadcn tokens + Recharts charts.
   Structure: tokens → base → header → sticky toolbar → cards → bento blocks →
   charts → tables → responsive.
   ========================================================================== */

/* ---------------------------------------------------------------- type ---- */
/* Self-hosted Fira Sans (UI/latin) + Fira Code (numerals). CJK falls back to
   the system stack — Fira has no CJK coverage. */
/* Text faces come from the main site (zhubao315.github.io): Inter for
   reading, Manrope for display, self-hosted variable files. Fira Code stays
   the numeral/table face — CJK falls back to the system stack. */
@font-face {
  font-family: 'Inter Variable';
  src: url('./fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter Variable';
  src: url('./fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope Variable';
  src: url('./fonts/manrope-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope Variable';
  src: url('./fonts/manrope-latin-ext-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fira Code';
  src: url('./fonts/fira-code-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Fira Code';
  src: url('./fonts/fira-code-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

/* -------------------------------------------------------------- tokens ---- */
:root {
  /* surfaces — unified four-site palette */
  --bg: #07111f;
  --bg-soft: #0a1424;
  --surface-1: #13263d;
  --card: #102a43;
  --card-grad: linear-gradient(180deg, rgba(22, 42, 66, 0.62) 0%, rgba(16, 42, 67, 0.95) 100%);
  --card-border: rgba(247, 250, 255, 0.16);
  --card-border-strong: rgba(247, 250, 255, 0.32);
  --card-shadow: inset 0 1px 0 0 rgba(248, 250, 252, 0.05), 0 8px 24px -6px rgba(2, 8, 20, 0.6);

  /* text */
  --text: #f7faff;
  --text-strong: #f7faff;
  --muted: #94a3b8;
  --subtle: #8fa6bd;

  /* lines */
  --border: rgba(247, 250, 255, 0.16);
  --border-strong: rgba(247, 250, 255, 0.32);
  --grid: rgba(247, 250, 255, 0.1);

  /* data palette (semantic, one hue per metric) */
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --indigo: #6366f1;
  --purple: #a855f7;
  --rose: #f43f5e;
  --emerald: #34d399;
  --amber: #fbbf24;
  --periwinkle: #818cf8;
  --slate: #64748b;

  /* status */
  --ok: #34d399;
  --warn: #f59e0b;
  --err: #f43f5e;

  /* geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --font-sans: 'Inter Variable', 'Manrope Variable', 'Noto Sans CJK SC',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-display: 'Manrope Variable', 'Inter Variable', 'Noto Sans CJK SC',
    'PingFang SC', sans-serif;
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.4);
  --header-h: var(--active-header-h, 64px); /* shared ACTIVE header token */

  /* overlays: a veil of the surface's own colour, so the light theme can
     darken them instead of lightening */
  --overlay-1: rgba(255, 255, 255, 0.02);
  --overlay-2: rgba(255, 255, 255, 0.025);
  --overlay-3: rgba(255, 255, 255, 0.03);
  --overlay-4: rgba(255, 255, 255, 0.04);
  --overlay-5: rgba(255, 255, 255, 0.045);
  --overlay-6: rgba(255, 255, 255, 0.05);
  --overlay-7: rgba(255, 255, 255, 0.06);
  --overlay-8: rgba(255, 255, 255, 0.07);
  --overlay-9: rgba(255, 255, 255, 0.08);
  --overlay-10: rgba(255, 255, 255, 0.1);
  --overlay-11: rgba(255, 255, 255, 0.12);
  --overlay-12: rgba(255, 255, 255, 0.14);

  /* charts read these, so the canvas follows the page */
  --chart-text: #e6eaf0;
  --chart-muted: #8b95a5;
  --chart-axis: #64748b;
  --chart-grid: rgba(255, 255, 255, 0.05);
  --chart-line: #c7d2fe;
  --chart-line-dim: #7c8795;
  --chart-sleep: #6366f1;
  --chart-hrv: #10b981;
  --chart-rhr: #f43f5e;
  --chart-stress: #f59e0b;
  --chart-load: #38bdf8;
  --chart-purple: #a855f7;
  --chart-periwinkle: #818cf8;
  --chart-slate: #64748b;

  /* the glass tooltip card */
  --tip-bg: rgba(15, 19, 24, 0.88);
  /* the accent as text: readable on the dark surfaces, darkened for the
     light ones where the bright cyan would disappear */
  --accent-text: #a5f3fc;
  /* text on a filled accent chip */
  --on-accent: #06202a;
  /* the colour a heatmap cell fades into */
  --cell-blend: #0d131a;
  --cell-blend-2: #151d26;
  --text-secondary: #cbd5e1;
  /* the bars that float over the page */
  --bar-bg: rgba(7, 17, 31, 0.88);
  --bar-bg-strong: rgba(7, 17, 31, 0.97);
  --bar-bg-soft: rgba(7, 17, 31, 0.8);
  --tip-border: rgba(255, 255, 255, 0.12);
  --tip-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* The light theme is the same dashboard read on a white page: the same
   semantic palette, a darker accent and darker chart colours where the
   bright ones would not read on white. */
[data-theme='light'] {
  color-scheme: light;

  --bg: #f7faff;
  --bg-soft: #eef2f7;
  --surface-1: #ffffff;
  --card: #ffffff;
  --card-grad: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(243, 248, 252, 0.96) 100%
  );
  --card-border: rgba(16, 24, 40, 0.14);
  --card-border-strong: rgba(16, 24, 40, 0.3);
  --card-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.9),
    0 8px 24px -12px rgba(15, 35, 60, 0.3);

  --text: #101828;
  --text-strong: #101828;
  --muted: #5b6d80;
  --subtle: #5c6b7c;

  --border: rgba(16, 24, 40, 0.14);
  --border-strong: rgba(16, 24, 40, 0.3);
  --grid: rgba(15, 35, 60, 0.1);

  --accent: #0284c7;
  --accent-2: #0369a1;
  --indigo: #4f46e5;
  --purple: #7e22ce;
  --rose: #e11d48;
  --emerald: #059669;
  --amber: #b45309;
  --periwinkle: #4f46e5;
  --slate: #64748b;

  --ok: #059669;
  --warn: #b45309;
  --err: #dc264f;

  --overlay-1: rgba(15, 35, 60, 0.02);
  --overlay-2: rgba(15, 35, 60, 0.025);
  --overlay-3: rgba(15, 35, 60, 0.03);
  --overlay-4: rgba(15, 35, 60, 0.04);
  --overlay-5: rgba(15, 35, 60, 0.045);
  --overlay-6: rgba(15, 35, 60, 0.05);
  --overlay-7: rgba(15, 35, 60, 0.06);
  --overlay-8: rgba(15, 35, 60, 0.07);
  --overlay-9: rgba(15, 35, 60, 0.08);
  --overlay-10: rgba(15, 35, 60, 0.1);
  --overlay-11: rgba(15, 35, 60, 0.12);
  --overlay-12: rgba(15, 35, 60, 0.14);

  --chart-text: #0e1b29;
  --chart-muted: #5b6d80;
  --chart-axis: #64748b;
  --chart-grid: rgba(15, 35, 60, 0.1);
  --chart-line: #4338ca;
  --chart-line-dim: #64748b;
  --chart-sleep: #4f46e5;
  --chart-hrv: #059669;
  --chart-rhr: #e11d48;
  --chart-stress: #b45309;
  --chart-load: #0284c7;
  --chart-purple: #7e22ce;
  --chart-periwinkle: #4f46e5;
  --chart-slate: #64748b;

  --tip-bg: rgba(255, 255, 255, 0.94);
  --accent-text: #0369a1;
  --on-accent: #ffffff;
  --cell-blend: #ffffff;
  --cell-blend-2: #e6ecf2;
  --text-secondary: #38495b;
  --bar-bg: rgba(255, 255, 255, 0.9);
  --bar-bg-strong: rgba(255, 255, 255, 0.97);
  --bar-bg-soft: rgba(255, 255, 255, 0.82);
  --tip-border: rgba(15, 35, 60, 0.16);
  --tip-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-pop: 0 20px 50px -16px rgba(15, 35, 60, 0.35),
    0 2px 8px rgba(15, 35, 60, 0.12);
}

/* ---------------------------------------------------------------- base ---- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* soft cyan ambient light behind the first screen (Linear-style) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(56, 189, 248, 0.09), transparent 70%),
    radial-gradient(ellipse 50% 30% at 90% 0%, rgba(56, 189, 248, 0.05), transparent 70%);
}

.site-header,
.sticky-bar,
.main,
.footer {
  position: relative;
  z-index: 1;
}

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

/* cross-site jump (health → running / cycling / hiking) */
.sport-link {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  color: var(--accent);
  border-bottom: 1px dotted rgba(56, 189, 248, 0.5);
  white-space: nowrap;
}

.sport-link:hover {
  color: var(--accent-text);
  border-bottom-style: solid;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection {
  background: rgba(56, 189, 248, 0.28);
  color: var(--text-strong);
}

.num,
.value,
.metric-value,
.bucket-val,
.tip-val,
.kpi-value,
.pill-meta,
.hmonth-title {
  font-variant-numeric: tabular-nums;
}

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

.small {
  font-size: 0.78rem;
}

/* -------------------------------------------------------------- header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: var(--bar-bg);
  backdrop-filter: blur(16px) saturate(1.2);
}

.header-inner,
.main,
.footer-inner,
.sticky-inner,
.section-nav {
  width: min(var(--active-shell, 1440px), 100% - 2 * var(--active-gutter, 1rem));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: calc(var(--header-h) - 1px); /* +1px header border = --header-h total */
  padding: 0.5rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand > span {
  max-width: 16rem;
  overflow: hidden;
  font-size: 0.94rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-logo {
  flex: none;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 0 rgba(248, 250, 252, 0.06);
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: none;
}

.dot.stale {
  background: var(--warn);
  box-shadow: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem;
}

/* Each site carries a Chinese label above its English name: the word a
   person reads first, and the name the site is known by. */
.nav a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 0.3rem 0.6rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.nav a .nav-zh {
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.nav a .nav-en {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.1em;
  opacity: 0.72;
}

.nav a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.nav a[aria-current='page'] {
  color: var(--accent);
  background: transparent;
  border-bottom-color: var(--accent);
  font-weight: 600;
  box-shadow: none;
}

.nav a[aria-current='page'] .nav-en {
  opacity: 1;
}

.nav a[aria-current='page']:hover {
  color: var(--accent);
  background: var(--overlay-2);
  border-bottom-color: var(--accent);
}

/* The light/dark switch, same shape on all four sites: an icon button.
   The icon says what the button will do (sun = switch to light, moon =
   switch to dark); the words live in the aria-label and the tooltip, so
   the button stays readable for a screen reader without taking space in
   the header. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  inline-size: 40px;
  block-size: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--overlay-2);
}

.theme-toggle:active {
  transform: scale(0.94);
}

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

.theme-icon {
  inline-size: 18px;
  block-size: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon-moon {
  display: none;
}

:root[data-theme='light'] .theme-icon-sun {
  display: none;
}

:root[data-theme='light'] .theme-icon-moon {
  display: block;
}

/* header metadata pills */
.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.pill-meta {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--overlay-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.pill-meta b,
.pill-meta strong {
  color: var(--text);
  font-weight: 500;
}

/* --------------------------------------------------- sticky toolbar ------- */
.sticky-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 48;
  padding: 0.45rem 0 0;
  border-bottom: 1px solid var(--border);
  background: var(--bar-bg-soft);
  backdrop-filter: blur(16px) saturate(1.2);
}

.sticky-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
}

.window-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wl-prefix {
  color: var(--subtle);
}

/* segmented pill track: range presets + section nav share the same groove */
.range,
.section-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--overlay-7);
  border-radius: 10px;
  background: var(--overlay-4);
}

.range button,
.section-nav a {
  position: relative;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.range button {
  padding: 0.3rem 0.72rem;
}

.range button:hover,
.section-nav a:hover {
  color: var(--text);
  background: var(--overlay-5);
}

.range button.active {
  color: var(--accent-text);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.22), rgba(56, 189, 248, 0.1));
  border-color: rgba(56, 189, 248, 0.32);
  font-weight: 600;
  box-shadow: inset 0 1px 0 var(--overlay-12);
}

.section-nav {
  display: flex;
  width: min(var(--active-shell, 1440px), 100% - 2 * var(--active-gutter, 1rem));
  margin: 0.4rem auto 0.45rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-nav::-webkit-scrollbar {
  display: none;
}

.section-nav a {
  flex: none;
  padding: 0.26rem 0.66rem;
}

.section-nav a[aria-current='true'] {
  color: var(--text-strong);
  background: var(--overlay-8);
  border-color: var(--overlay-9);
  box-shadow: inset 0 1px 0 var(--overlay-10);
}

/* floating custom range (phones) needs a solid surface above content */
.custom-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.custom-range[hidden] {
  display: none;
}

.custom-range input[type='date'] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.custom-range input[type='date']:focus {
  border-color: rgba(56, 189, 248, 0.5);
  outline: none;
}

/* ------------------------------------------------------------------ main -- */
.main {
  padding: 1.2rem 0 3.5rem;
}

/* compact hero */
.hero {
  margin-top: 0.6rem;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-grad);
  box-shadow: var(--card-shadow);
}

.hero-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  margin: 0.4rem 0 0.9rem;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(56, 189, 248, 0.07), transparent 55%),
    var(--card-grad);
}

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

h1 {
  margin: 0 0 0.25rem;
  color: var(--text-strong);
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero-sub {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.72rem;
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.08);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  white-space: nowrap;
}

.hero-meta {
  display: none;
}

/* -------------------------------------------------------- section heads --- */
.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  align-items: baseline;
  justify-content: space-between;
  margin: 1.6rem 0 0.75rem;
}

.section-head h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-head h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 0.85em;
  margin-right: 0.5rem;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), transparent);
  vertical-align: -0.06em;
}

.hint {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.55;
}

/* in-card notice when one module fails but the rest of the cockpit renders */
.degraded-note {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.7rem;
  border: 1px dashed var(--card-border);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.55;
}

/* ----------------------------------------------------------------- cards -- */
.card,
.kpi,
.exec-card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-grad);
  box-shadow: var(--card-shadow);
}

.card {
  padding: 1.05rem 1.1rem 1.15rem;
  margin-bottom: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.grid .card {
  margin-bottom: 0;
}

.card.wide {
  grid-column: span 2;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.card-head h2,
.card-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.card-tools {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}

/* small segmented switch (body module time axis) — same groove as .range but
   sized for a card header instead of the sticky top bar */
.subrange {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--overlay-7);
  border-radius: 9px;
  background: var(--overlay-4);
}

.subrange button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.subrange button:hover {
  color: var(--text);
  background: var(--overlay-5);
}

.subrange button.active {
  color: var(--accent-text);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.22), rgba(56, 189, 248, 0.1));
  border-color: rgba(56, 189, 248, 0.32);
  font-weight: 600;
}

.tool {
  min-height: 26px;
  padding: 0.24rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--overlay-2);
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.tool:hover {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.06);
}

.tool[aria-expanded='true'],
.tool.active {
  color: var(--accent-text);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.12);
}

select {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.76rem;
}

select:hover {
  border-color: rgba(56, 189, 248, 0.3);
}

/* ------------------------------------------------------- exec summary ----- */
.exec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.7rem;
}

.exec-card {
  --tone: var(--slate);
  position: relative;
  padding: 0.85rem 0.95rem 0.9rem;
  overflow: hidden;
}

.exec-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tone), transparent);
  opacity: 0.5;
}

.exec-card.good {
  --tone: var(--emerald);
}

.exec-card.warn {
  --tone: var(--amber);
}

.exec-card.neutral {
  --tone: var(--accent);
}

.exec-card.muted {
  --tone: var(--slate);
}

.exec-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.exec-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  color: var(--tone);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 25%, transparent);
}

.exec-icon svg {
  width: 13px;
  height: 13px;
}

.exec-title {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.exec-body {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.7;
}

.exec-body .hl {
  padding: 0 0.28rem;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.exec-card.skeleton {
  min-height: 96px;
  background: linear-gradient(
    100deg,
    var(--overlay-3) 20%,
    var(--overlay-8) 38%,
    var(--overlay-3) 56%
  );
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}

/* ------------------------------------------------------------- KPI bento -- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.kpi {
  --tone: var(--slate);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.9rem 0.75rem;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tone), transparent);
  opacity: 0.65;
}

.kpi::after {
  content: '';
  position: absolute;
  inset: -40% -30% auto auto;
  width: 60%;
  height: 120%;
  background: radial-gradient(circle, color-mix(in srgb, var(--tone) 12%, transparent), transparent 65%);
  opacity: 0.5;
  pointer-events: none;
}

.kpi-good {
  --tone: var(--emerald);
}

.kpi-warn {
  --tone: var(--amber);
}

.kpi-flat,
.kpi-neutral {
  --tone: var(--slate);
}

.kpi-head {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: space-between;
  min-height: 1.4rem;
}

.kpi-name {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.kpi-pill {
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-pill.good {
  background: rgba(16, 185, 129, 0.14);
  color: var(--emerald);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.22);
}

.kpi-pill.warn {
  background: rgba(245, 158, 11, 0.14);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.22);
}

.kpi-pill.flat,
.kpi-pill.neutral {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

.kpi-sub {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 0.3rem;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.kpi-basis {
  color: var(--muted);
}

.kpi-value {
  margin: 0.1rem 0 0.1rem;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

/* bullet track: normal-range band + 28d tick + 7d tick + day dot */
.bullet {
  position: relative;
  display: block;
  height: 16px;
  margin: 0.45rem 0 0.1rem;
}

.bullet-track {
  position: absolute;
  top: 5px;
  right: 0;
  left: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--overlay-5);
  box-shadow: inset 0 0 0 1px var(--overlay-4);
}

.bullet-band {
  position: absolute;
  top: 5px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}

.bullet-tick {
  position: absolute;
  top: 2px;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  border-radius: 2px;
}

.bullet-tick.base {
  background: rgba(226, 232, 240, 0.45);
}

.bullet-tick.week {
  top: 3px;
  height: 10px;
  background: rgba(226, 232, 240, 0.8);
}

.bullet-dot {
  position: absolute;
  top: 3px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 22%, transparent),
    0 0 12px color-mix(in srgb, var(--tone) 45%, transparent);
}

.spark-wrap {
  position: relative;
  margin-top: auto;
  padding-top: 0.55rem;
}

.spark {
  display: block;
  width: 100%;
  height: 36px;
}

.spark-dot {
  animation: pulse-dot 2.6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.spark-note {
  display: block;
  margin-top: 0.15rem;
  color: var(--subtle);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

.kpi.skeleton {
  min-height: 150px;
  background: linear-gradient(
    100deg,
    var(--overlay-3) 20%,
    var(--overlay-8) 38%,
    var(--overlay-3) 56%
  );
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}

@keyframes skeleton {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -80% 0;
  }
}

/* ---------------------------------------------------------------- charts -- */
.chart-box {
  position: relative;
  height: 280px;
}

.chart-box.small {
  height: 150px;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-box canvas:hover {
  cursor: crosshair;
}

.data-table {
  margin-top: 0.7rem;
  max-height: 300px;
  overflow: auto;
}

/* ------------------------------------------------------- glass tooltip ----- */
.chart-tip {
  position: fixed;
  z-index: 90;
  min-width: 186px;
  max-width: 300px;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--tip-border);
  border-radius: 10px;
  background: var(--tip-bg);
  box-shadow: var(--shadow-pop), var(--tip-shadow);
  backdrop-filter: blur(12px) saturate(1.25);
  pointer-events: none;
  font-size: 0.74rem;
  animation: tip-in 0.12s ease-out;
}

.chart-tip[hidden] {
  display: none;
}

@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tip-head {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding-bottom: 0.45rem;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid var(--overlay-9);
}

.tip-date {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tip-wd {
  color: var(--muted);
  font-size: 0.75rem;
}

.tip-badge {
  margin-left: auto;
  padding: 0.04rem 0.4rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.tip-badge.up {
  background: rgba(16, 185, 129, 0.16);
  color: var(--emerald);
}

.tip-badge.down {
  background: rgba(245, 158, 11, 0.16);
  color: var(--amber);
}

.tip-rows {
  display: grid;
  gap: 0.28rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tip-rows li {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
}

.tip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  box-shadow: none;
}

.tip-name {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tip-val {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
}

.tip-foot {
  display: grid;
  gap: 0.22rem;
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--overlay-9);
}

.tip-delta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.tip-snapshot {
  color: var(--subtle);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* legacy selectors from the previous tooltip implementation */
.sync-tip {
  display: none !important;
}

/* --------------------------------------------------------------- heatmap --- */
.heat-months {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem 1.3rem;
}

.hmonth {
  flex: 0 0 auto;
}

.hmonth-title {
  margin-bottom: 0.25rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.hweek,
.hgrid {
  display: grid;
  grid-template-columns: repeat(7, 20px);
  gap: 3px;
}

.hweek {
  margin-bottom: 2px;
  color: var(--subtle);
  font-size: 0.7rem;
  text-align: center;
}

.hblank {
  display: block;
}

.hcell {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--overlay-6);
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) calc(var(--v, 0) * 52%), var(--cell-blend));
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.hcell:hover,
.hcell:focus-visible {
  z-index: 2;
  border-color: rgba(56, 189, 248, 0.6);
  color: var(--text-strong);
  transform: scale(1.15);
  box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.hcell.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.45), 0 6px 18px -6px rgba(56, 189, 248, 0.6);
}

.hcell.nodata {
  background: repeating-linear-gradient(
    45deg,
    var(--cell-blend),
    var(--cell-blend) 4px,
    var(--cell-blend-2) 4px,
    var(--cell-blend-2) 8px
  );
  color: transparent;
}

.heat-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.9rem;
  width: 100%;
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.heat-legend-unit {
  color: var(--text);
}

.heat-legend-scale {
  display: inline-flex;
  gap: 2px;
}

.heat-legend-scale i {
  display: block;
  width: 16px;
  height: 8px;
  border-radius: 3px;
}

.heat-legend-scale .lo {
  background: color-mix(in srgb, var(--accent) 12%, var(--cell-blend));
}

.heat-legend-scale .mid {
  background: color-mix(in srgb, var(--accent) 50%, var(--cell-blend));
}

.heat-legend-scale .hi {
  background: var(--accent);
}

.heat-legend-span {
  font-family: var(--font-mono);
}

.heat-legend-gap {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}

.nodata-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, var(--cell-blend), var(--cell-blend) 3px, var(--cell-blend-2) 3px, var(--cell-blend-2) 6px);
}

/* ------------------------------------------------------- day detail ------- */
.day-detail {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(56, 189, 248, 0.07), transparent 60%),
    rgba(11, 15, 20, 0.7);
}

.day-detail[hidden] {
  display: none;
}

.dd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.dd-head b {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.dd-grid {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.65;
}

.dd-grid b {
  margin-right: 0.35rem;
  color: var(--text);
}

.tag {
  display: inline-block;
  margin: 0.12rem 0.3rem 0.12rem 0;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.71rem;
}

/* ±3 day context table */
.ctx-wrap {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.ctx-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.7rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
}

.ctx-table {
  font-size: 0.71rem;
}

.ctx-table td,
.ctx-table th {
  padding: 0.3rem 0.55rem;
  white-space: nowrap;
}

.ctx-table tr.ctx-today td {
  background: rgba(56, 189, 248, 0.08);
  color: var(--text);
}

.ctx-mark {
  padding: 0 0.3rem;
  border-radius: 3px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-text);
  font-size: 0.7rem;
}

.ctx-sport {
  color: var(--muted);
}

.ctx-date {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- correlation ---- */
.corr-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.corr-body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
  margin-top: 0.4rem;
}

.corr-plot .chart-box {
  margin: 0;
}

.bucket-panel {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--overlay-1);
}

.bucket-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.bucket-head h4 {
  margin: 0;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.bucket-head .hint {
  margin: 0;
  font-size: 0.75rem;
}

.bucket-lead {
  margin: 0 0 0.7rem;
  color: var(--text);
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.65;
}

.bucket-empty,
.bucket-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.6;
}

.bucket-note {
  margin-top: 0.55rem;
}

.bucket-bars {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.bucket-row {
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr) 4.2rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.72rem;
}

.bucket-label {
  color: var(--muted);
  white-space: nowrap;
}

.bucket-label small {
  display: block;
  font-size: 0.7rem;
  opacity: 0.75;
}

.bucket-bar {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--overlay-6);
  box-shadow: inset 0 0 0 1px var(--overlay-4);
  overflow: hidden;
}

.bucket-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.bucket-bar i.b-low {
  background: linear-gradient(90deg, #334155, #64748b);
}

.bucket-bar i.b-mid {
  background: #38bdf8;
  box-shadow: none;
}

.bucket-bar i.b-high {
  background: #10b981;
  box-shadow: none;
}

.bucket-val {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: right;
  white-space: nowrap;
}

.bucket-val small {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}

.bucket-table {
  margin-top: 0;
  font-size: 0.71rem;
}

.bucket-table th {
  text-transform: none;
  letter-spacing: 0.02em;
}

.hypotheses {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.85;
}

.hypotheses b {
  color: var(--text);
}

/* ---------------------------------------------------------------- tables --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.coverage,
.table-inline {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.coverage th,
.coverage td,
.table-inline th,
.table-inline td {
  padding: 0.52rem 0.45rem;
  border-bottom: 1px solid var(--overlay-6);
  color: var(--muted);
  text-align: left;
}

.coverage tbody tr:hover td,
.table-inline tbody tr:hover td {
  background: var(--overlay-1);
}

.coverage th,
.table-inline th {
  color: var(--subtle);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.coverage td.num,
.coverage th.num,
.table-inline td.num,
.table-inline th.num {
  font-family: var(--font-mono);
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.coverage td:last-child,
.coverage th:last-child,
.table-inline td:last-child,
.table-inline th:last-child {
  text-align: right;
}

.coverage td:first-child,
.coverage th:first-child,
.table-inline td:first-child,
.table-inline th:first-child {
  text-align: left;
}

.coverage tr.active td,
.table-inline tr.active td {
  color: var(--accent-text);
}

.coverage caption {
  padding: 0.5rem 0.2rem 0;
  color: var(--subtle);
  font-size: 0.7rem;
  text-align: left;
  caption-side: bottom;
}

/* daily table: sticky header + sticky date column */
#daily-table-wrap {
  max-height: 70vh;
  overflow-y: auto;
}

#daily-table {
  min-width: 760px;
}

#daily-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f131a;
  box-shadow: inset 0 -1px 0 var(--overlay-9);
}

#daily-table thead th:first-child,
#daily-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #0c1015;
  box-shadow: 1px 0 0 var(--overlay-7);
}

#daily-table thead th:first-child {
  z-index: 4;
  background: #0f131a;
}

#daily-table .col-date {
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* compact mode: date / sleep / HRV / resting HR / steps */
#daily-table.compact th:nth-child(3),
#daily-table.compact td:nth-child(3),
#daily-table.compact th:nth-child(4),
#daily-table.compact td:nth-child(4),
#daily-table.compact th:nth-child(5),
#daily-table.compact td:nth-child(5),
#daily-table.compact th:nth-child(6),
#daily-table.compact td:nth-child(6),
#daily-table.compact th:nth-child(7),
#daily-table.compact td:nth-child(7),
#daily-table.compact th:nth-child(9),
#daily-table.compact td:nth-child(9),
#daily-table.compact th:nth-child(10),
#daily-table.compact td:nth-child(10),
#daily-table.compact th:nth-child(12),
#daily-table.compact td:nth-child(12),
#daily-table.compact th:nth-child(14),
#daily-table.compact td:nth-child(14),
#daily-table.compact th:nth-child(15),
#daily-table.compact td:nth-child(15),
#daily-table.compact th:nth-child(16),
#daily-table.compact td:nth-child(16) {
  display: none;
}

#daily-table.compact {
  min-width: 0;
}

#daily-table td.cell-warn {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber);
}

#daily-table td.cell-good {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald);
}

#daily-table td.cell-dim {
  color: var(--subtle);
  opacity: 0.85;
}

#daily-table tbody tr:hover td.cell-warn,
#daily-table tbody tr:hover td.cell-good {
  filter: brightness(1.2);
}

.scroll-hint {
  display: none;
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.71rem;
}

.scroll-hint[data-visible='true'] {
  display: block;
}

.load-more {
  margin-top: 0.6rem;
}

/* ------------------------------------------------ body composition ------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem;
  margin: 0.5rem 0 0.4rem;
}

.metric-card {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--overlay-1);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.metric-card:hover {
  border-color: rgba(56, 189, 248, 0.22);
  background: rgba(56, 189, 248, 0.035);
}

.metric-name {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.metric-value {
  display: block;
  margin-top: 0.12rem;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.metric-value small {
  margin-left: 0.2rem;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0;
}

.metric-meta {
  display: block;
  margin-top: 0.1rem;
  color: var(--subtle);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.metric-card .spark {
  height: 20px;
  margin-top: 0.3rem;
  opacity: 0.8;
}

.derived {
  padding: 0 0.25rem;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--amber);
  font-size: 0.7rem;
  letter-spacing: 0;
}

.metric-note,
.body-comp-note,
.body-empty {
  margin: 0.3rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.6;
}

#body-card .body-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

#body-card .body-charts .chart-box {
  height: 240px;
}

/* legacy profile strip (section was folded into the header pills) */
.profile-card {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
}

.profile-main,
.profile-item {
  display: flex;
  flex: 1 1 180px;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 1.1rem;
  background: var(--card);
}

.profile-label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.profile-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
}

.profile-note {
  color: var(--muted);
  font-size: 0.7rem;
}

.profile-footnote {
  flex: 1 1 100%;
  margin: 0;
  padding: 0.7rem 1.1rem;
  background: var(--card);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.7;
}

/* ---------------------------------------------------------- cross-sport ---- */
.xsport-root {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.xs-career {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.xs-card {
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-grad);
}

.xs-card-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.xs-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.xs-num {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-variant-numeric: tabular-nums;
}

.xs-num small {
  margin-left: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.xs-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  gap: 0.35rem 0.8rem;
}

.xs-list dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.xs-list dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.xs-list em {
  color: var(--subtle);
  font-size: 0.75rem;
  font-style: normal;
}

.xs-share {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.xs-share span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.xs-share-label {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.xs-block {
  padding: 1rem 1.1rem;
}

.xs-year-table th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.xs-year-table th.xs-sorted {
  color: var(--accent);
}

.xs-year-table td em {
  display: block;
  color: var(--subtle);
  font-size: 0.75rem;
  font-style: normal;
}

.xs-share-cell {
  min-width: 110px;
}

.xs-year-table .xs-share {
  height: 6px;
  background: var(--surface-1);
}

.xs-months {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 0.3rem;
  align-items: end;
}

.xs-month {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.xs-month-stack {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  width: 100%;
  height: 96px;
}

.xs-month-stack span {
  display: block;
  width: 100%;
}

.xs-month > span {
  color: var(--muted);
  font-size: 0.7rem;
  writing-mode: vertical-rl;
}

.xs-month em {
  color: var(--subtle);
  font-size: 0.7rem;
  font-style: normal;
}

.xs-source {
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------- misc ----- */
.note {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.75;
}

.note a {
  color: var(--accent);
}

.tag-independent {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.08rem 0.42rem;
  border-radius: 5px;
  background: rgba(245, 158, 11, 0.14);
  color: var(--amber);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.dir-basis {
  color: var(--subtle);
  font-size: 0.75rem;
}

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1.2rem;
  z-index: 60;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: rgba(15, 19, 24, 0.85);
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.8);
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  color: var(--on-accent);
  background: var(--accent);
  transform: translateY(-2px);
}

.footer {
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 1.2rem 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.footer a:hover,
.nav a:hover {
  color: var(--accent);
}

/* keep anchored sections clear of the sticky toolbar */
main section[id] {
  scroll-margin-top: 120px;
}

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 1100px) {
  .corr-body {
    grid-template-columns: 1fr;
  }

  .corr-plot .chart-box {
    height: 260px;
  }
}

@media (max-width: 900px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card.wide {
    grid-column: span 1;
  }

  .header-meta {
    display: none;
  }

  .hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    order: -1;
  }

  .sticky-inner {
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sticky-inner::-webkit-scrollbar {
    display: none;
  }

  .window-label {
    flex: none;
    width: auto;
    font-size: 0.71rem;
  }

  .range {
    flex: none;
    flex-wrap: nowrap;
  }

  .range button {
    padding: 0.28rem 0.58rem;
  }

  .section-nav {
    margin-top: 0.3rem;
    margin-bottom: 0.35rem;
  }

  .section-nav a {
    padding: 0.22rem 0.52rem;
  }
}

@media (max-width: 900px), (pointer: coarse) {
  .range button,
  .tool,
  select {
    min-height: 40px;
  }

  .hcell {
    touch-action: manipulation;
  }
}

@media (max-width: 767px) {
  .hmonth {
    min-width: 100%;
  }

  .hgrid,
  .hweek {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }

  .hcell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    font-size: 0.7rem;
    line-height: 1;
  }

  #body-card .body-charts {
    grid-template-columns: 1fr;
  }

  .chart-box {
    height: 230px;
  }

  .back-to-top {
    right: 0.75rem;
    bottom: 0.9rem;
  }
}

@media (max-width: 720px) {
  /* The words stay on the phone: a phone header shows the mark, the mother
     brand, the site name and the theme switch. Only the rule and the small
     English site name give way. */
  .brand-rule,
  .brand-site-en {
    display: none;
  }

  .header-inner {
    padding: 0.45rem 0;
  }
}

@media (max-width: 560px) {
  .kpis {
    grid-template-columns: 1fr;
  }

  .hero-compact {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .hero-compact .badge {
    order: -1;
  }

  .hero-sub {
    display: none;
  }

  .sticky-inner {
    flex-wrap: wrap;
    row-gap: 0.3rem;
  }

  .window-label {
    display: none;
    flex: 0 0 100%;
    font-size: 0.71rem;
  }

  .sticky-bar.is-custom .window-label {
    display: block;
  }

  .range {
    flex: 1 1 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .range::-webkit-scrollbar {
    display: none;
  }

  .range button {
    flex: none;
    padding: 0.32rem 0.6rem;
  }

  .custom-range {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 30;
    margin: 0;
    padding: 0.6rem 1rem 0.7rem;
    border-bottom: 1px solid var(--border);
    background: var(--bar-bg-strong);
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.5);
  }

  .custom-range input[type='date'] {
    flex: 1 1 130px;
    min-width: 0;
  }

  .kpi {
    padding: 0.75rem 0.85rem 0.7rem;
  }

  .kpi-value {
    font-size: 1.6rem;
  }

  .spark {
    height: 30px;
  }

  .exec-card {
    padding: 0.75rem 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   ACTIVE — brand layer
   ----------------------------------------------------------------------------
   The dashboard keeps its own scientific tokens above; this block adds the
   mother brand: the mark, the sub-brand icons in the navigation, the mobile
   bottom bar and the generated backdrop. Colours still come from the tokens
   (--accent, --text, --border …), never from a literal in this file.
   ========================================================================== */

/* ------------------------------------------------------------- header ---- */
.brand-mark {
  flex: none;
  width: auto;
  height: 2rem;
  color: var(--text);
  /* the main site's hover: the mark tilts and grows a hair, on its easing */
  transition: transform 0.35s var(--active-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.brand:hover .brand-mark,
.brand:focus-visible .brand-mark,
.footer-brand:hover .brand-mark,
.footer-brand:focus-visible .brand-mark {
  transform: rotate(-3deg) scale(1.04);
}

/* GitHub in the top bar reads like the sport sites: mono, muted, small. */
.nav a.nav-plain {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

/* The profile pills live in the page body, not the header: the four sites
   share one header structure — brand on the left, nav and theme on the
   right, nothing in between. */
.header-meta {
  display: none;
}

/* The brand never collapses: on a phone the mark and the two words have to
   stay readable, whatever else the header is showing. */
.brand {
  flex: none;
}

.brand-wordmark,
.brand-site {
  flex: none;
}

.brand-wordmark {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.brand-rule {
  width: 1px;
  height: 1.1rem;
  background: var(--border-strong);
}

.brand-site {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1.15;
}

.brand-site-zh {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-site-en {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.site-icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  opacity: 0.82;
}

.nav a {
  flex-direction: row;
  gap: 0.4rem;
}

.nav-text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.15;
}

.nav a[aria-current='page'] .site-icon {
  opacity: 1;
}

/* ---------------------------------------------------------------- hero ---- */
.hero {
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -12%;
  right: 8%;
  bottom: -12%;
  left: 8%;
  background-image: url('./brand/hero-health.webp');
  background-size: cover;
  background-position: center;
  opacity: 0.3;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 26%, #000 74%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 26%, #000 74%, transparent);
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-brand-slash {
  opacity: 0.5;
}

:root[data-theme='light'] .hero::before {
  display: none;
}

/* ------------------------------------------------------- mobile bottom ---- */
.mobile-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bar-bg);
  backdrop-filter: blur(16px) saturate(1.2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--active-mobile-nav-height, 60px);
  padding: 0.45rem 0.25rem;
  color: var(--muted);
}

.mobile-nav a .site-icon {
  width: 1.375rem;
  height: 1.375rem;
}

.mobile-nav a span {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.mobile-nav a[aria-current='page'] {
  color: var(--accent);
}

@media (max-width: 768px) {
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 40rem;
    margin: 0 auto;
  }

  .main {
    padding-bottom: calc(60px + 1.5rem);
  }

  .nav {
    display: none;
  }

  .brand-rule,
  .brand-site-en {
    display: none;
  }

  .brand-wordmark {
    font-size: 0.88rem;
    letter-spacing: 0.12em;
  }

  .brand-site-zh {
    font-size: 0.78rem;
  }

  .hero::before {
    opacity: 0.16;
  }
}

/* ------------------------------------------------------------- footer ---- */
.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-brand-line {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

/* Mobile: the unified shell header is 56px tall on phones (the sticky bar
   offsets itself from the same token, so both move together). */
@media (max-width: 768px) {
  :root {
    --header-h: var(--active-header-h-sm, 56px);
  }
}

/* Between the phone bar and the desktop, the header has no room for the
   English sub-labels: drop them before the nav ever wraps to a second line
   (the unified header height must hold at every width ≥ 769px). */
@media (min-width: 769px) and (max-width: 1100px) {
  .brand-rule,
  .brand-site-en,
  .nav a .nav-en,
  .header-meta {
    display: none;
  }

  .nav {
    flex-wrap: nowrap;
  }

  .nav a {
    padding: 0.35rem 0.5rem;
  }
}

/* ---- ACTIVE unified shell: right-hand cluster and footer site nav -------- */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

@media (max-width: 768px) {
  .footer-nav {
    gap: 0.25rem 0.75rem;
  }
}

/* Impeccable: balanced headings, readable paragraph rag. */
h1,h2,h3,h4{text-wrap:balance;}
p{text-wrap:pretty;}

/* Skill fix: keep footer/nav links tappable on small screens. */
@media (max-width: 768px) {
  .footer-nav a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
}

@media (max-width: 768px) {
  .footer a,
  .footer-nav a,
  .mobile-nav a,
  .nav a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
}

/* Release marker (ACTIVE 2.0), aligned with the four sport sites. */
.footer-release {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.footer-release-tag {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.12em;
}
