/* ChairGlow site styles.
   Base text is 18px. Every interactive control is at least 44px tall.
   Colours are tokens; dark mode swaps the tokens. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --line: #d5dde6;
  --text: #1b2631;
  --muted: #4a5867;
  --primary: #145fa0;
  --primary-strong: #0f4a7d;
  --on-primary: #ffffff;
  --accent: #8a4b0f;
  --accent-bg: #fff4e5;
  --ok: #1d6b3a;
  --ok-bg: #e9f6ee;
  --err: #a3261b;
  --err-bg: #fdecea;
  --warn-bg: #fff8e1;
  --warn-line: #e0b84a;
  --focus: #c25e00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 60, .06), 0 6px 18px rgba(20, 40, 60, .07);
  --maxw: 1080px;
  --tap: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10161d; --surface: #18212b; --surface-2: #1f2a36; --line: #33414f;
    --text: #eef2f6; --muted: #b6c2ce; --primary: #8cc4f2; --primary-strong: #b5daf8;
    --on-primary: #0b2238; --accent: #f3c27f; --accent-bg: #2d2416;
    --ok: #8fdcaa; --ok-bg: #16301f; --err: #ffaba3; --err-bg: #3a1a17;
    --warn-bg: #2f2814; --warn-line: #8a7230; --focus: #ffb366;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10161d; --surface: #18212b; --surface-2: #1f2a36; --line: #33414f;
  --text: #eef2f6; --muted: #b6c2ce; --primary: #8cc4f2; --primary-strong: #b5daf8;
  --on-primary: #0b2238; --accent: #f3c27f; --accent-bg: #2d2416;
  --ok: #8fdcaa; --ok-bg: #16301f; --err: #ffaba3; --err-bg: #3a1a17;
  --warn-bg: #2f2814; --warn-line: #8a7230; --focus: #ffb366;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.3);
  color-scheme: dark;
}

/* Text size control: 18px default, then 20px and 22.5px */
html { font-size: 112.5%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-size="l"] { font-size: 125%; }
html[data-size="xl"] { font-size: 140.625%; }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6; overflow-wrap: break-word;
}
img, video, svg { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-family: Georgia, "Times New Roman", serif; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem); margin-top: 1.4em; }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }
a { color: var(--primary); text-underline-offset: .15em; }
a:hover { color: var(--primary-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.prose { max-width: 68ch; }
.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: 8px; top: -60px; background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: 8px; z-index: 100; min-height: var(--tap); }
.skip-link:focus { top: 8px; }

/* ---------- header ---------- */
.prefs-bar { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.prefs-bar .wrap { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: flex-end; padding-top: 4px; padding-bottom: 4px; }
.prefs-group { display: flex; align-items: center; gap: 6px; }
.prefs-group > span { font-size: .85rem; color: var(--muted); }
.pref-btn {
  min-width: var(--tap); min-height: var(--tap); padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer;
}
.pref-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: relative; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-height: var(--tap); font-family: Georgia, serif; font-weight: 700; font-size: 1.35rem; }
.brand img, .brand svg { width: 40px; height: 40px; }
.nav-toggle { display: none; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; align-items: center; }
.main-nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.main-nav a:hover, .main-nav a[aria-current="page"] { background: var(--surface-2); color: var(--primary); }
.main-nav a.nav-cta { background: var(--primary); color: var(--on-primary); }
.main-nav a.nav-cta:hover { background: var(--primary-strong); color: var(--on-primary); }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); z-index: 20; }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .main-nav a { width: 100%; min-height: 52px; }
}

/* ---------- layout bits ---------- */
main { display: block; padding-bottom: 48px; }
.hero { padding: 40px 0 24px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 46ch; }
.section { padding: 24px 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-2 { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin-bottom: .3em; }
.card a.card-link { display: block; text-decoration: none; color: inherit; min-height: var(--tap); }
.card a.card-link:hover h3 { color: var(--primary); text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.chip { display: inline-block; font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.lvl-1 { background: var(--ok-bg); color: var(--ok); }
.chip.lvl-3 { background: var(--accent-bg); color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px;
  border-radius: 12px; border: 2px solid var(--primary); background: var(--primary); color: var(--on-primary);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: var(--on-primary); }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.secondary:hover { background: var(--surface-2); color: var(--primary-strong); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }

.notice { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface-2); margin: 16px 0; }
.notice.safety { background: var(--warn-bg); border-color: var(--warn-line); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--text); }
.notice.err { background: var(--err-bg); border-color: var(--err); color: var(--text); }
.notice strong:first-child { display: block; margin-bottom: 4px; }
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type="text"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.hp { position: absolute; left: -9999px; }
.form-status { margin-top: 12px; }
.form-status:empty { display: none; }
.check-row { display: flex; gap: 10px; align-items: center; min-height: var(--tap); }
.check-row input { width: 26px; height: 26px; flex: none; }
.check-row label { margin: 0; font-weight: 400; }

/* filters */
.filters { display: grid; gap: 12px; }
.filter-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.filter-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.filter-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-opts button {
  min-height: var(--tap); padding: 6px 14px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; cursor: pointer; text-align: left;
}
.filter-opts button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.filter-note { font-size: .95rem; }
.results-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0; }
details.filters-panel > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 700; }

/* ---------- video cards ---------- */
.yt { position: relative; aspect-ratio: 16 / 9; background: #0d1114; border-radius: 12px; overflow: hidden; }
.yt img { width: 100%; height: 100%; object-fit: cover; }
.yt button { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.yt button span { background: rgba(0,0,0,.72); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 1rem; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vid-meta { font-size: .9rem; color: var(--muted); margin: 8px 0 0; }
.vid-title { font-size: 1.05rem; margin: 10px 0 0; font-family: inherit; }

/* exercise detail */
.ex-media { background: var(--surface-2); border-radius: 12px; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; color: var(--muted); overflow: hidden; }
.ex-media video { width: 100%; height: 100%; object-fit: contain; }
.steps { padding-left: 1.4em; }
.steps li { margin-bottom: .5em; }
.skip-list li { margin-bottom: .6em; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 1em; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0; }

/* session player */
.player { text-align: center; }
.player .timer { font-size: clamp(3rem, 2rem + 8vw, 6rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; margin: 12px 0; }
.player .phase { font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.player .phase.rest { color: var(--ok); }
.progress { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: var(--primary); width: 0; transition: width .3s; }
.player-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0; }
.player-controls .btn { min-width: 120px; }
.session-list { counter-reset: s; list-style: none; padding: 0; }
.session-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.session-list li::before { counter-increment: s; content: counter(s); flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.session-list li.current { background: var(--surface-2); border-radius: 10px; padding-left: 8px; }

/* programs */
.day-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.day.done { border-color: var(--ok); background: var(--ok-bg); }
.day h3 { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin: 0 0 .3em; }
.day .done-badge { font-family: inherit; font-size: .85rem; color: var(--ok); font-weight: 700; }
.progress-summary { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.progress-summary .progress { flex: 1 1 200px; }

/* assessment */
.score-band { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 0; text-align: center; font-size: .9rem; }
.score-band div { padding: 8px 4px; border-radius: 8px; background: var(--surface-2); border: 2px solid transparent; }
.score-band div.you { border-color: var(--primary); font-weight: 700; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
th { background: var(--surface-2); }
.table-scroll { overflow-x: auto; max-width: 100%; }
.q-list { list-style: none; padding: 0; }
.q-list li { border-bottom: 1px solid var(--line); padding: 8px 0; }

/* footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 32px 0 24px; margin-top: 32px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.site-footer ul a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 8px; }
.disclaimer { font-size: .9rem; color: var(--muted); margin-top: 20px; }

/* Inline links in running text: vertical padding on an inline element enlarges the tap area
   to 44px+ without changing the line spacing. */
main p a:not(.btn), main li a:not(.btn):not(.card-link), main dd a, main td a, footer p a, .notice a { padding-block: 12px; }

@media (max-width: 480px) {
  .btn { width: 100%; }
  .btn-row .btn { width: 100%; }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .prefs-bar, .site-header, .site-footer, .btn-row, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}

.crumb { margin: 16px 0 0; }
details.more-filters > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--primary); }
details.more-filters[open] > summary { margin-bottom: 8px; }
details.more-filters .filter-group { margin-bottom: 12px; }
