/* BioRecall Wearables — design system
   One stylesheet for every page. Tokens first, then base, layout, components,
   charts, and page-specific pieces. Colours for data were validated with the
   dataviz palette checks (CVD separation, contrast) in both themes. */

/* ------------------------------------------------------------------ fonts */

@font-face {
  font-family: "Red Hat Text";
  src: url("../fonts/red-hat-text-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Red Hat Text";
  src: url("../fonts/red-hat-text-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ----------------------------------------------------------------- tokens */

:root {
  color-scheme: light;
  --font: "Red Hat Text", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* surfaces and ink */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #edf1f5;
  --line: #dfe5ec;
  --line-strong: #c9d2dd;
  --ink: #0c1a2e;
  --ink-2: #3d4d63;
  --ink-3: #5f6e84;
  --ink-inverse: #ffffff;

  /* brand: JYU navy and flame */
  --rail: #002855;
  --rail-ink: #c8d5e6;
  --rail-ink-muted: #8fa3c0;
  --rail-hover: rgba(255, 255, 255, 0.07);
  --rail-active: rgba(255, 255, 255, 0.12);
  --accent: #f0543c;
  --accent-ink: #c23a22;
  --accent-wash: rgba(240, 84, 60, 0.12);
  --primary: #002855;
  --primary-hover: #0b3a70;
  --on-primary: #ffffff;

  /* status (fixed meaning, always with icon + label) */
  --good: #0ca30c;
  --good-wash: #e8f6e8;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-wash: #fef4de;
  --serious: #ec835a;
  --serious-wash: #fdeee7;
  --critical: #d03b3b;
  --critical-wash: #fbeaea;
  --neutral-wash: #edf1f5;

  /* data: one hue per domain */
  --sleep: #2a78d6;
  --activity: #eb6834;
  --recovery: #1baf7a;
  --heart: #e87ba4;
  --workout: #6250d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --stage-deep: #184f95;
  --stage-light: #3987e5;
  --stage-rem: #86b6ef;
  --stage-wake: #f0a08f;
  --cov-0: #edf1f5;
  --cov-1: #93a9cc;
  --cov-2: #5274a8;
  --cov-3: #143769;
  --diverge-up: #2a78d6;
  --diverge-down: #e34948;
  --grid: #e8edf2;
  --axis: #c9d2dd;

  /* shape, depth, motion */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-pop: 0 12px 32px -12px rgba(12, 26, 46, 0.28), 0 2px 6px rgba(12, 26, 46, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 160ms;
  --rail-width: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #070f1c;
    --surface: #0e1a2c;
    --surface-2: #122136;
    --surface-3: #18293f;
    --line: #22344d;
    --line-strong: #2e4562;
    --ink: #e9eef5;
    --ink-2: #b3c0d1;
    --ink-3: #8a9ab0;
    --ink-inverse: #07142a;
    --rail: #001a3d;
    --rail-ink: #b9c7da;
    --rail-ink-muted: #7f93b1;
    --accent: #ff7b61;
    --accent-ink: #ff8a72;
    --accent-wash: rgba(255, 123, 97, 0.14);
    --primary: #dce6f3;
    --primary-hover: #ffffff;
    --on-primary: #07142a;
    --good-wash: rgba(12, 163, 12, 0.16);
    --good-ink: #3fcf3f;
    --warning-wash: rgba(250, 178, 25, 0.15);
    --serious-wash: rgba(236, 131, 90, 0.16);
    --critical-wash: rgba(208, 59, 59, 0.2);
    --neutral-wash: #18293f;
    --sleep: #3987e5;
    --activity: #d95926;
    --recovery: #199e70;
    --heart: #d55181;
    --workout: #9085e9;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --stage-deep: #256abf;
    --stage-light: #5598e7;
    --stage-rem: #9ec5f4;
    --stage-wake: #e9876f;
    --cov-0: #18293f;
    --cov-1: #3a5e92;
    --cov-2: #6e90c4;
    --cov-3: #b3c8e8;
    --diverge-up: #3987e5;
    --diverge-down: #e66767;
    --grid: #1a2b42;
    --axis: #2e4562;
    --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070f1c;
  --surface: #0e1a2c;
  --surface-2: #122136;
  --surface-3: #18293f;
  --line: #22344d;
  --line-strong: #2e4562;
  --ink: #e9eef5;
  --ink-2: #b3c0d1;
  --ink-3: #8a9ab0;
  --ink-inverse: #07142a;
  --rail: #001a3d;
  --rail-ink: #b9c7da;
  --rail-ink-muted: #7f93b1;
  --accent: #ff7b61;
  --accent-ink: #ff8a72;
  --accent-wash: rgba(255, 123, 97, 0.14);
  --primary: #dce6f3;
  --primary-hover: #ffffff;
  --on-primary: #07142a;
  --good-wash: rgba(12, 163, 12, 0.16);
  --good-ink: #3fcf3f;
  --warning-wash: rgba(250, 178, 25, 0.15);
  --serious-wash: rgba(236, 131, 90, 0.16);
  --critical-wash: rgba(208, 59, 59, 0.2);
  --neutral-wash: #18293f;
  --sleep: #3987e5;
  --activity: #d95926;
  --recovery: #199e70;
  --heart: #d55181;
  --workout: #9085e9;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --stage-deep: #256abf;
  --stage-light: #5598e7;
  --stage-rem: #9ec5f4;
  --stage-wake: #e9876f;
  --cov-0: #18293f;
  --cov-1: #3a5e92;
  --cov-2: #6e90c4;
  --cov-3: #b3c8e8;
  --diverge-up: #3987e5;
  --diverge-down: #e66767;
  --grid: #1a2b42;
  --axis: #2e4562;
  --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------------- base */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: 1.625rem; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.0625rem; line-height: 1.35; }
h3 { font-size: 0.9375rem; line-height: 1.4; }
p { margin: 0; }
p + p { margin-top: 0.75em; }
small { font-size: 0.8125rem; }

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }

::selection { background: var(--accent-wash); color: var(--ink); }

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

img, svg { display: block; max-width: 100%; }

table { font-variant-numeric: tabular-nums; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

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

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 14px; background: var(--surface); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.skip-link:focus { top: 12px; }

.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ----------------------------------------------------------------- layout */

.app { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--rail) var(--rail-width), transparent var(--rail-width)); }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px 16px;
  background: var(--rail);
  color: var(--rail-ink);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; color: #fff; text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name strong { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.brand-name span { font-size: 12.5px; color: var(--rail-ink-muted); font-weight: 450; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 0 12px;
  border-radius: var(--radius);
  color: var(--rail-ink); text-decoration: none;
  font-size: 14.5px; font-weight: 500;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-link:hover { background: var(--rail-hover); color: #fff; }
.nav-link[aria-current="page"] { background: var(--rail-active); color: #fff; }
.nav-link[aria-current="page"] .icon { color: var(--accent); }
.nav-section { margin: 18px 12px 6px; font-size: 12px; color: var(--rail-ink-muted); font-weight: 500; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.06); }
.theme-switch button { display: grid; place-items: center; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--rail-ink-muted); cursor: pointer; }
.theme-switch button:hover { color: #fff; }
.theme-switch button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); color: #fff; }

.who { display: flex; align-items: center; gap: 10px; padding: 2px 6px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; }
.who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who-text a { color: #fff; font-size: 13.5px; font-weight: 550; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text a:hover { text-decoration: underline; }
.who-text span { font-size: 12px; color: var(--rail-ink-muted); }
.who form { margin-left: auto; }
.rail-icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--rail-ink-muted); cursor: pointer; }
.rail-icon-btn:hover { background: var(--rail-hover); color: #fff; }
.version { padding: 0 8px; font-size: 11.5px; color: var(--rail-ink-muted); }

.page { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 32px 40px 72px; }

.demo-banner { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 16px; background: var(--warning-wash); color: var(--ink); font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--line); }
.demo-banner .icon { color: #b07400; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .lede { margin-top: 6px; color: var(--ink-3); font-size: 14.5px; max-width: 72ch; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--ink-3); font-size: 13.5px; font-weight: 500; text-decoration: none; }
.back-link:hover { color: var(--ink); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.panel + .toolbar, .tabs + .toolbar { margin-top: 24px; }
.tabs + .toolbar { margin-top: 0; }
.toolbar .search { width: min(320px, 100%); }
.toolbar .spacer { flex: 1; }

.stack > * + * { margin-top: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }

/* ------------------------------------------------------------- components */

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 550; text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--critical) 55%, var(--line)); color: var(--critical); }
.btn-danger:hover { background: var(--critical-wash); border-color: var(--critical); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn .icon { width: 16px; height: 16px; }
.btn.is-busy { pointer-events: none; opacity: 0.7; }
.btn.is-busy .icon { animation: spin 0.9s linear infinite; }

/* form fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label, .label { font-size: 13.5px; font-weight: 550; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.field .error-text { font-size: 12.5px; color: var(--critical); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14.5px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 0.8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.input[aria-invalid="true"] { border-color: var(--critical); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6e84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input-sm, .select-sm { min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: 13.5px; }
.input-mono { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.field-row .field + .field { margin-top: 0; }
.field + .field-row, .field-row + .field { margin-top: 16px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.password-field { position: relative; }
.password-field .input { padding-right: 44px; }
.password-field button { position: absolute; right: 4px; top: 50%; translate: 0 -50%; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); cursor: pointer; }
.password-field button:hover { color: var(--ink); background: var(--surface-3); }

/* segmented control (date ranges, toggles) */
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--surface-3); }
.segmented::-webkit-scrollbar { display: none; }
.segmented > * { flex: none; }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13.5px; font-weight: 550; text-decoration: none; cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented a:hover, .segmented button:hover { color: var(--ink); }
.segmented [aria-current="true"], .segmented [aria-pressed="true"], .segmented [aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(12, 26, 46, 0.12); }

.range-form { display: inline-flex; align-items: center; gap: 8px; }
.range-form .input { width: auto; min-height: 34px; padding: 4px 10px; font-size: 13.5px; }

/* status chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px 0 8px;
  border-radius: 999px; background: var(--neutral-wash); color: var(--ink);
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.chip .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.chip-good { background: var(--good-wash); }
.chip-good .icon { color: var(--good); }
.chip-warning { background: var(--warning-wash); }
.chip-warning .icon { color: #c98700; }
.chip-serious { background: var(--serious-wash); }
.chip-serious .icon { color: var(--serious); }
.chip-critical { background: var(--critical-wash); }
.chip-critical .icon { color: var(--critical); }
.chip-neutral .icon { color: var(--ink-3); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 550; }

/* panels: the one container, hairline-bound */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 22px 0; }
.panel-head p { margin-top: 3px; font-size: 13px; color: var(--ink-3); }
.panel-head .panel-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.panel-body { padding: 18px 22px 22px; }
.panel-body.flush { padding: 0; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.panel-title { display: flex; align-items: center; gap: 9px; }
.panel-title .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* figures: headline numbers separated by hairlines, not boxed */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.figure { padding: 20px 24px 22px; min-width: 0; }
.figure + .figure { border-left: 1px solid var(--line); }
.figure-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 550; color: var(--ink-2); }
.figure-label .dot { width: 8px; height: 8px; border-radius: 50%; }
.figure-value { margin-top: 10px; font-size: 2.6rem; line-height: 1; font-weight: 300; letter-spacing: -0.035em; color: var(--ink); white-space: nowrap; }
.figure-value .unit { margin-left: 3px; font-size: 1rem; font-weight: 450; letter-spacing: 0; color: var(--ink-3); }
.figure-value .of { font-size: 1.25rem; font-weight: 400; color: var(--ink-3); letter-spacing: -0.01em; }
.figure-meta { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.figure-meta .icon { width: 15px; height: 15px; }
.delta-up { color: var(--good-ink); }
.delta-down { color: var(--critical); }

/* tables */
.table-wrap { overflow-x: auto; }
.panel > .table-wrap, .panel-body.flush > .table-wrap { border-radius: inherit; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 16px; text-align: left;
  background: var(--surface-2); color: var(--ink-3);
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background var(--fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .n { text-align: right; white-space: nowrap; }
.table .code { font-weight: 600; color: var(--ink); text-decoration: none; }
.table a.code:hover { text-decoration: underline; }
.table-compact td { padding-top: 8px; padding-bottom: 8px; }
.table caption { text-align: left; padding: 0 0 8px; color: var(--ink-3); font-size: 13px; }
.row-link { cursor: pointer; }
.table tbody tr[aria-selected="true"] { background: var(--surface-3); }
.table tbody tr[aria-selected="true"] td:first-child { font-weight: 600; }

/* flash messages */
.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.flash .icon { margin-top: 1px; }
.flash-success { background: var(--good-wash); border-color: transparent; }
.flash-success .icon { color: var(--good); }
.flash-error { background: var(--critical-wash); border-color: transparent; }
.flash-error .icon { color: var(--critical); }
.flash-warning { background: var(--warning-wash); border-color: transparent; }
.flash-warning .icon { color: #c98700; }
.flash-info .icon { color: var(--ink-3); }
.flash button { margin-left: auto; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 0; }

/* copyable values: connection links, invitation codes */
.copy-field { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }
.copy-field input { flex: 1; min-width: 0; border: 0; padding: 9px 12px; background: transparent; color: var(--ink); font: inherit; font-size: 13.5px; }
.copy-field input:focus { outline: none; }
.copy-field button { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border: 0; border-left: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; }
.copy-field button:hover { background: var(--surface-3); }
.copy-field button.copied { color: var(--good-ink); }
.code-display { font-size: 1.75rem; font-weight: 500; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; color: var(--ink); }

/* empty states teach the next step */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 28px 24px; color: var(--ink-2); font-size: 14px; max-width: 60ch; }
.empty h3 { font-size: 15px; }
.empty .icon { width: 22px; height: 22px; color: var(--ink-3); }
.empty-center { align-items: center; text-align: center; margin: 0 auto; padding: 48px 24px; }

/* tabs (participant pages) */
.tabs { display: flex; gap: 2px; margin: 0 0 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px 11px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--ink-3); font-size: 14px; font-weight: 550; text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; }

/* description lists */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; font-size: 14px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }

/* dialogs */
dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(7, 15, 28, 0.45); backdrop-filter: blur(2px); }
.dialog-body { padding: 22px 24px 8px; }
.dialog-body p { margin-top: 8px; color: var(--ink-2); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 20px; }

/* attention list */
.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 14px 22px; border-top: 1px solid var(--line); }
.attention li:first-child { border-top: 0; }
.attention .icon { margin-top: 2px; }
.attention .sev-serious .icon, .attention li.sev-serious > .icon { color: var(--serious); }
.attention li.sev-warning > .icon { color: #c98700; }
.attention li.sev-info > .icon { color: var(--ink-3); }
.attention strong { display: block; font-size: 14px; font-weight: 600; }
.attention span { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.attention a.code { font-size: 13px; font-weight: 600; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.attention a.code:hover { color: var(--ink); text-decoration: underline; }

/* ----------------------------------------------------------------- charts */

.chart { position: relative; width: 100%; min-height: 220px; }
.chart svg { width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.chart.is-loading svg { opacity: 0.45; transition: opacity var(--fast); }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--ink-3); font-size: 14px; text-align: center; padding: 16px; }

.axis text, .tick-label { fill: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.axis line, .axis path { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.crosshair { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.end-label { fill: var(--ink-2); font-size: 12px; font-weight: 550; }

.mark-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mark-area { stroke: none; opacity: 0.1; }
.mark-band { stroke: none; opacity: 0.16; }
.mark-dot { stroke: var(--surface); stroke-width: 2; }
.mark-bar { shape-rendering: geometricPrecision; transition: opacity var(--fast); }
.mark-bar:hover, .mark-bar.is-hover { opacity: 0.78; }
.mark-bar.is-partial { opacity: 0.45; }

.c-sleep { color: var(--sleep); } .c-activity { color: var(--activity); } .c-recovery { color: var(--recovery); }
.c-heart { color: var(--heart); } .c-workout { color: var(--workout); }
.c-s1 { color: var(--series-1); } .c-s2 { color: var(--series-2); } .c-s3 { color: var(--series-3); } .c-s4 { color: var(--series-4); }
.c-s5 { color: var(--series-5); } .c-s6 { color: var(--series-6); } .c-s7 { color: var(--series-7); } .c-s8 { color: var(--series-8); }
.c-deep { color: var(--stage-deep); } .c-light { color: var(--stage-light); } .c-rem { color: var(--stage-rem); } .c-wake { color: var(--stage-wake); }
.c-up { color: var(--diverge-up); } .c-down { color: var(--diverge-down); } .c-muted { color: var(--ink-3); }
.mark-line, .mark-dot { stroke: currentColor; }
.mark-dot, .mark-area, .mark-band, .mark-bar, .swatch-fill { fill: currentColor; }
.dot.c-sleep, .dot.c-activity, .dot.c-recovery, .dot.c-heart, .dot.c-workout { background: currentColor; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; background: currentColor; }
.legend-line { width: 16px; height: 2px; border-radius: 2px; background: currentColor; }
.legend-swatch.is-hollow { background: transparent; border: 1px dashed var(--line-strong); }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  min-width: 140px; max-width: 280px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-pop); font-size: 12.5px; color: var(--ink-2);
  opacity: 0; transform: translateY(4px); transition: opacity 120ms, transform 120ms var(--ease);
}
.tooltip.is-visible { opacity: 1; transform: none; }
.tooltip-title { margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.tooltip-row { display: flex; align-items: center; gap: 8px; }
.tooltip-row + .tooltip-row { margin-top: 3px; }
.tooltip-row .key { width: 12px; height: 2px; border-radius: 2px; background: currentColor; flex: none; }
.tooltip-row .key.is-box { height: 10px; width: 10px; border-radius: 2px; }
.tooltip-row strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip-row .label { margin-left: auto; padding-left: 10px; color: var(--ink-3); font-size: 12px; font-weight: 450; }

.table-toggle { border: 0; background: none; padding: 0; color: var(--ink-3); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.table-toggle:hover { color: var(--ink); }
.data-table-view { max-height: 320px; overflow: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.data-table-view .table { font-size: 13px; }
.data-table-view .table td, .data-table-view .table th { padding: 7px 12px; }

/* the 28-day ribbon (signature) */
.ribbon { --cell: 15px; --gap: 3px; display: grid; gap: 6px; }
.ribbon-head, .ribbon-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 14px; }
.ribbon-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ribbon-who { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); text-decoration: none; }
.ribbon-who:hover span { text-decoration: underline; }
.ribbon-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ribbon-who .icon { width: 14px; height: 14px; stroke-width: 2.2; flex: none; }
.ribbon-who .st-linked { color: var(--good); } .ribbon-who .st-reauthorize { color: var(--serious); } .ribbon-who .st-pending { color: var(--ink-3); }
.ribbon-cells { display: grid; grid-template-columns: repeat(var(--days, 28), minmax(4px, 1fr)); gap: var(--gap); }
.cell { height: 22px; border-radius: 4px; background: var(--cov-0); transition: transform var(--fast) var(--ease), box-shadow var(--fast); }
.cell.l1 { background: var(--cov-1); } .cell.l2 { background: var(--cov-2); } .cell.l3 { background: var(--cov-3); }
.cell.out { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 70%, transparent); }
.ribbon-large .cell.today { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--accent); }
.ribbon-scale .today-label { color: var(--accent-ink); font-weight: 600; }
.ribbon-note { display: flex; align-items: center; min-height: 22px; padding: 2px 10px; line-height: 1.3; border-radius: 4px; background: var(--surface-2); color: var(--ink-3); font-size: 12.5px; box-shadow: inset 0 0 0 1px var(--line); }
.cell.selected { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--ink); }
.cell[data-day]:hover { transform: scaleY(1.12); }
.ribbon-compact .cell { height: 16px; border-radius: 3px; }
.ribbon-compact .ribbon-cells { gap: 2px; }
.ribbon-large .cell { height: 34px; border-radius: 6px; cursor: pointer; }
.ribbon-reveal .cell { animation: cell-in 480ms var(--ease) both; }
.ribbon-reveal .cell:nth-child(2) { animation-delay: 12ms; }
.ribbon-reveal .cell:nth-child(3) { animation-delay: 24ms; }
.ribbon-reveal .cell:nth-child(4) { animation-delay: 36ms; }
.ribbon-reveal .cell:nth-child(5) { animation-delay: 48ms; }
.ribbon-reveal .cell:nth-child(6) { animation-delay: 60ms; }
.ribbon-reveal .cell:nth-child(7) { animation-delay: 72ms; }
.ribbon-reveal .cell:nth-child(8) { animation-delay: 84ms; }
.ribbon-reveal .cell:nth-child(9) { animation-delay: 96ms; }
.ribbon-reveal .cell:nth-child(10) { animation-delay: 108ms; }
.ribbon-reveal .cell:nth-child(11) { animation-delay: 120ms; }
.ribbon-reveal .cell:nth-child(12) { animation-delay: 132ms; }
.ribbon-reveal .cell:nth-child(13) { animation-delay: 144ms; }
.ribbon-reveal .cell:nth-child(14) { animation-delay: 156ms; }
.ribbon-reveal .cell:nth-child(15) { animation-delay: 168ms; }
.ribbon-reveal .cell:nth-child(16) { animation-delay: 180ms; }
.ribbon-reveal .cell:nth-child(17) { animation-delay: 192ms; }
.ribbon-reveal .cell:nth-child(18) { animation-delay: 204ms; }
.ribbon-reveal .cell:nth-child(19) { animation-delay: 216ms; }
.ribbon-reveal .cell:nth-child(20) { animation-delay: 228ms; }
.ribbon-reveal .cell:nth-child(21) { animation-delay: 240ms; }
.ribbon-reveal .cell:nth-child(22) { animation-delay: 252ms; }
.ribbon-reveal .cell:nth-child(23) { animation-delay: 264ms; }
.ribbon-reveal .cell:nth-child(24) { animation-delay: 276ms; }
.ribbon-reveal .cell:nth-child(25) { animation-delay: 288ms; }
.ribbon-reveal .cell:nth-child(26) { animation-delay: 300ms; }
.ribbon-reveal .cell:nth-child(27) { animation-delay: 312ms; }
.ribbon-reveal .cell:nth-child(28) { animation-delay: 324ms; }
.ribbon-window { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 12px; color: var(--ink-3); }
.ribbon-solo .ribbon-head, .ribbon-solo .ribbon-row { grid-template-columns: minmax(0, 1fr); }
.ribbon-solo .ribbon-head > span:first-child, .ribbon-solo .ribbon-who { display: none; }
.ribbon-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.ribbon-legend .cell { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -2px; margin-right: 6px; }

/* participant mini ribbon in tables */
.mini-ribbon { display: grid; grid-template-columns: repeat(28, 5px); gap: 2px; }
.mini-ribbon .cell { height: 18px; border-radius: 2px; }

/* hypnogram stage legend */
.stage-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }

/* route */
.route-svg path.route { fill: none; stroke: var(--workout); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.route-svg circle.start { fill: var(--good); stroke: var(--surface); stroke-width: 2; }
.route-svg circle.finish { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }

/* zone bars */
.zones { display: flex; flex-direction: column; gap: 8px; }
.zone-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 72px; align-items: center; gap: 12px; font-size: 13px; }
.zone-row .bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--workout); opacity: calc(0.35 + var(--z, 0) * 0.13); }
.zone-row .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------- participant header */

.person-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; margin-bottom: 20px; }
.person-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.person-title h1 { font-size: 2rem; letter-spacing: -0.03em; font-weight: 600; }
.person-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 13.5px; color: var(--ink-3); }
.person-meta span { display: inline-flex; align-items: center; gap: 6px; }
.person-meta .icon { width: 15px; height: 15px; }

.connect-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.qr { width: 132px; height: 132px; padding: 8px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; }

.summary-line { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.summary-line .figure-value { font-size: 2rem; }

/* score ring: only for real 1–100 scores */
.score { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; }
.score-ring { width: 96px; height: 96px; }
.score-ring .track { fill: none; stroke: var(--surface-3); stroke-width: 8; }
.score-ring .value { fill: none; stroke: currentColor; stroke-width: 8; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 900ms var(--ease); }
.score-ring text { fill: var(--ink); font-size: 26px; font-weight: 400; letter-spacing: -0.03em; text-anchor: middle; dominant-baseline: central; }

/* ----------------------------------------------------------- auth pages */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-side {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 48px; background: var(--rail); color: var(--rail-ink); overflow: hidden;
}
.auth-side .brand { padding: 0; }
.auth-side h2 { color: #fff; font-size: 2.1rem; line-height: 1.15; font-weight: 450; letter-spacing: -0.03em; max-width: 15ch; }
.auth-side p { margin-top: 14px; max-width: 42ch; font-size: 15px; color: var(--rail-ink); }
.auth-ribbon { display: grid; grid-template-columns: repeat(28, 1fr); gap: 4px; margin: 36px 0 12px; }
.auth-ribbon i { display: block; height: 30px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); }
.auth-ribbon i.l1 { background: #3a5e92; } .auth-ribbon i.l2 { background: #6e90c4; } .auth-ribbon i.l3 { background: #b3c8e8; }
.auth-ribbon i.now { box-shadow: 0 0 0 2px var(--rail), 0 0 0 4px var(--accent); }
.auth-logos { display: flex; align-items: center; gap: 28px; }
.auth-logos img { height: 44px; width: auto; opacity: 0.92; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card h1 { font-size: 1.75rem; }
.auth-card .lede { margin: 8px 0 28px; color: var(--ink-3); font-size: 14.5px; }
.auth-card .btn-primary { width: 100%; height: 42px; margin-top: 24px; }
.auth-alt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-3); }
.auth-alt a { color: var(--ink); font-weight: 550; }

/* ------------------------------------------- participant-facing pages */

.public { min-height: 100vh; background: var(--bg); }
.public-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 760px; margin: 0 auto; padding: 24px 20px 0; }
.public-top .logos { display: flex; align-items: center; gap: 22px; }
.public-top .logos img { height: 48px; width: auto; }
.lang-switch a { font-size: 15px; font-weight: 600; color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.lang-switch a[aria-current="true"] { background: var(--surface-3); color: var(--ink); }
.public-main { max-width: 760px; margin: 0 auto; padding: 28px 20px 64px; font-size: 18px; line-height: 1.6; }
.public-main h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -0.025em; }
.public-main .lede { margin-top: 12px; font-size: 19px; color: var(--ink-2); max-width: 60ch; }
.public-card { margin-top: 28px; padding: 26px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.public-card h2 { font-size: 1.2rem; margin-bottom: 10px; }
.public-card ol, .public-card ul { margin: 0; padding-left: 1.3em; }
.public-card li + li { margin-top: 8px; }
.public-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 30px; }
.btn-xl { height: 54px; padding: 0 26px; font-size: 18px; border-radius: 12px; }
.public-note { margin-top: 18px; font-size: 16px; color: var(--ink-3); }
.public-note .icon { display: inline-block; vertical-align: -3px; margin-right: 8px; color: var(--good); }
.result-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 18px; }
.result-ok { background: var(--good-wash); color: var(--good-ink); }
.result-error { background: var(--critical-wash); color: var(--critical); }
.result-icon .icon { width: 28px; height: 28px; stroke-width: 2; }

/* ------------------------------------------------------------- explore */

.explore-controls { display: grid; grid-template-columns: minmax(200px, 1.2fr) minmax(180px, 1fr) minmax(160px, 0.8fr) auto; gap: 14px; align-items: end; }
.dataset-list { list-style: none; margin: 0; padding: 0; }
.dataset-option { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-radius: var(--radius); cursor: pointer; }
.dataset-option:hover { background: var(--surface-2); }
.dataset-option input { margin-top: 3px; accent-color: var(--primary); }
.dataset-option strong { display: block; font-size: 14px; font-weight: 600; }
.dataset-option span { display: block; font-size: 13px; color: var(--ink-3); }
.dataset-group { margin: 14px 14px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.export-summary { font-size: 13.5px; color: var(--ink-2); }
#explore-form { margin-bottom: 24px; }
.preview-wrap { max-height: 560px; overflow: auto; border-top: 1px solid var(--line); }
.preview-wrap .table td, .preview-wrap .table th { white-space: nowrap; }

/* --------------------------------------------------------------- motion */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes cell-in { from { opacity: 0.35; transform: scaleY(0.5); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .figures, .summary-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .explore-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .rail { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 86vw); transform: translateX(-102%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-pop); }
  .rail.is-open { transform: none; }
  .topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: var(--rail); color: #fff; }
  .topbar .brand { padding: 0; }
  .topbar button { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
  .content { padding: 24px 16px 56px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 28px 24px; }
  .auth-side h2 { font-size: 1.6rem; }
  .auth-ribbon { margin: 24px 0 8px; }
  .person-head { grid-template-columns: minmax(0, 1fr); }
  .panel-head { flex-wrap: wrap; }
  .panel-head .panel-tools { width: 100%; }
  .ribbon-head, .ribbon-row { grid-template-columns: 96px minmax(0, 1fr); gap: 10px; }
}

@media (max-width: 600px) {
  .figures, .summary-line { grid-template-columns: minmax(0, 1fr); }
  .figure + .figure { border-left: 0; border-top: 1px solid var(--line); }
  .figure-value { font-size: 2.2rem; }
  .explore-controls { grid-template-columns: minmax(0, 1fr); }
  .connect-card { grid-template-columns: minmax(0, 1fr); }
  .score { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .page-head { align-items: flex-start; }
  .public-main { font-size: 17px; }
  .public-main h1 { font-size: 1.7rem; }
  .ribbon { --gap: 2px; }
  .cell { height: 18px; border-radius: 3px; }
}

@media print {
  .rail, .topbar, .page-actions, .toolbar, .theme-switch { display: none !important; }
  .app { display: block; }
  .panel, .figures { break-inside: avoid; }
}
