/* Regiment brand kit: Night, Bone, Ember, Steel; Barlow and Barlow Condensed (served from this site). Dark, and light
   when the computer or phone is set to light (W4). Colours are the app's (src/theme.ts): every text pair passes 4.5:1.
   Never write a colour outside these tokens. */
@font-face { font-family: 'Barlow'; font-weight: 400 500; src: url('/fonts/Barlow_500Medium.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Barlow'; font-weight: 600; src: url('/fonts/Barlow_600SemiBold.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Barlow'; font-weight: 700 800; src: url('/fonts/Barlow_700Bold.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; src: url('/fonts/BarlowCondensed_700Bold.ttf') format('truetype'); font-display: swap; }

:root {
  color-scheme: dark;
  --night: #0b0b0c;
  --card: #161618;
  --line: #2a2a2e;
  --bone: #e8e4da;
  --steel: #a8a49b;
  --ember: #e5683f;
  --ember-deep: #b5482a;
  --on-ember: #0b0b0c;
  --danger: #f2708a;
  --good: #6fcf8e;
  --hover: #1d1d20;
  --rule: #1f1f22;
  --danger-bg: rgba(242, 112, 138, 0.12);
  --good-bg: rgba(111, 207, 142, 0.12);
  --good-line: rgba(111, 207, 142, 0.4);
  --radius: 12px;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --night: #eeeae1;
    --card: #fbfaf7;
    --line: #cfc9bc;
    --bone: #0b0b0c;
    --steel: #5e5a53;
    --ember: #a84124;
    --ember-deep: #a84124;
    --on-ember: #ffffff;
    --danger: #b3243f;
    --good: #1a7544;
    --hover: #e3ded3;
    --rule: #e3ded3;
    --danger-bg: #f6dde2;
    --good-bg: #d8efe2;
    --good-line: rgba(26, 117, 68, 0.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--night); color: var(--bone); }
body { font: 500 16px/1.5 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: 'Barlow Condensed', 'Barlow', sans-serif; font-weight: 700; letter-spacing: 0.01em; margin: 0 0 12px; }
h1 { font-size: 32px; line-height: 1.1; }
h2 { font-size: 22px; }
a { color: var(--ember); }
b, .strong { font-weight: 700; }
.muted { color: var(--steel); }
.small { font-size: 14px; }
.lede { color: var(--steel); margin: -4px 0 18px; }

.mark .mark-solid { fill: var(--bone); }
.mark .mark-outline { fill: none; stroke: var(--ember); stroke-width: 5; }
.wordmark { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 30px; letter-spacing: 0.08em; line-height: 1; }

/* Signed out, and first-time setup */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-sub { color: var(--steel); font-size: 14px; margin-top: 4px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.auth-foot { color: var(--steel); font-size: 13px; margin-top: 18px; }

/* Forms */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 14px; font-weight: 600; color: var(--steel); margin-bottom: 6px; }
.field-hint { display: block; font-size: 13px; color: var(--steel); margin-top: 4px; }
input[type='text'], input[type='email'], input[type='password'], input[type='date'], input:not([type]) {
  width: 100%; font: inherit; color: var(--bone); background: var(--night); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; min-height: 48px;
}
input:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; color: var(--steel); font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ember); }

.btn { font: inherit; font-weight: 700; border-radius: 10px; padding: 12px 18px; min-height: 48px; cursor: pointer; border: 1px solid transparent; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--ember); color: var(--on-ember); width: 100%; }
.page .btn-primary, .row .btn-primary, .card .btn-primary { width: auto; }
.btn-secondary { background: transparent; color: var(--bone); border-color: var(--line); }
.btn-link { background: none; color: var(--ember); padding: 6px 0; min-height: 0; font-weight: 600; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0; }

.notice { border-radius: 10px; padding: 10px 12px; margin: 4px 0 14px; font-size: 15px; }
.notice-error { background: var(--danger-bg); color: var(--danger); }
.notice-ok { background: var(--good-bg); color: var(--good); }

/* Signed in */
.shell { min-height: 100vh; }
.top { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--night); z-index: 1; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--bone); text-decoration: none; }
.small-mark { font-size: 22px; }
.business { color: var(--steel); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--steel); text-decoration: none; font-weight: 700; padding: 10px 14px; border-radius: 10px; }
.nav a.on { color: var(--bone); background: var(--card); }

.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
.page.narrow { max-width: 640px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.section { margin-top: 36px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { margin-bottom: 4px; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; }
.empty p { color: var(--steel); margin: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--steel); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.cards { display: none; list-style: none; padding: 0; margin: 0; }
.client-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.client-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 10px 0; font-size: 15px; }
.client-card dt { color: var(--steel); }
.client-card dd { margin: 0; text-align: right; }
.list { list-style: none; padding: 0; margin: 0 0 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

.code-box { background: var(--card); border: 1px solid var(--ember); border-radius: 16px; padding: 28px 16px; text-align: center; margin: 8px 0 4px; }
.code { font-family: 'Barlow Condensed', monospace; font-weight: 700; font-size: 48px; letter-spacing: 0.14em; user-select: all; font-variant-numeric: tabular-nums; }
.bullets { color: var(--steel); padding-left: 20px; }
.bullets li { margin-bottom: 6px; }

.back { display: inline-block; color: var(--steel); text-decoration: none; font-weight: 600; margin-bottom: 10px; }
.back:hover { color: var(--bone); }
.client-link { color: var(--bone); text-decoration: none; }
.client-link:hover { color: var(--ember); text-decoration: underline; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { color: var(--steel); text-decoration: none; font-weight: 700; padding: 10px 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--bone); border-bottom-color: var(--ember); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { color: var(--steel); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 30px; line-height: 1.2; }
.card-quiet { background: transparent; }
.list-link { color: inherit; text-decoration: none; }
.list-link:hover { background: var(--hover); }
.more { display: inline-block; margin-top: 10px; font-weight: 700; text-decoration: none; }
.pill { display: inline-block; border: 1px solid var(--line); color: var(--steel); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill-good { color: var(--good); border-color: var(--good-line); }
.note { color: var(--steel); font-style: italic; margin: 6px 0 10px; white-space: pre-wrap; }
.exercise { border-top: 1px solid var(--line); padding: 14px 0 6px; }
.exercise-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.exercise-head a { color: var(--bone); text-decoration: none; }
.exercise-head a:hover { color: var(--ember); }
.sets { border-collapse: collapse; margin-top: 8px; min-width: 280px; }
.sets td { padding: 5px 16px 5px 0; font-variant-numeric: tabular-nums; }
.set-no { color: var(--steel); font-weight: 700; width: 84px; white-space: nowrap; }
.set-done { color: var(--good); }
.not-done td { color: var(--steel); }
.not-done .set-done { color: var(--steel); font-size: 13px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--night); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin: 8px 10px 8px 0; }
.seg button { font: inherit; font-weight: 700; font-size: 14px; color: var(--steel); background: none; border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.seg button.seg-on { background: var(--ember); color: var(--on-ember); }
.chart { margin: 8px 0 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--steel); font-size: 12px; font-family: 'Barlow', sans-serif; }
.chart-line { fill: none; stroke: var(--ember); stroke-width: 2.5; stroke-linejoin: round; }
.chart-dot { fill: var(--ember); stroke: var(--night); stroke-width: 1.5; }
.section-sm { font-size: 18px; margin-top: 20px; }
.records td:last-child { text-align: right; white-space: nowrap; }
.records td:nth-child(2) { white-space: nowrap; }
.plan { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.days { list-style: none; padding: 0; margin: 8px 0 0; }
.days li { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border-bottom: 1px solid var(--rule); }
.days li:last-child { border-bottom: 0; }
.workout-def { border-top: 1px solid var(--line); padding: 12px 0; }
.workout-def summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chart-axis { font-size: 24px; }
  .chart-line { stroke-width: 4; }
  .records td { padding: 10px 8px; }
  /* Phone header: the mark and the three pages on one row; the business's name is on Settings. */
  .top { padding: 10px 16px; gap: 8px; flex-wrap: nowrap; }
  .top .small-mark, .business { display: none; }
  .nav { margin-left: auto; gap: 2px; }
  .nav a { padding: 8px 10px; }
  /* Five client tabs fit 375 wide. */
  .tabs { gap: 0; }
  .tabs a { padding: 10px 5px; font-size: 14px; }
  .page { padding: 20px 16px 48px; }
  h1 { font-size: 28px; }
  .code { font-size: 36px; }
  .table-wrap { display: none; }
  .cards { display: block; }
}

/* Body (step M1) */
.body-group { margin-top: 6px; }
.body-group .seg { margin-top: 4px; }
.body-entry > summary { cursor: pointer; list-style: none; }
.body-entry > summary::-webkit-details-marker { display: none; }
.body-entry > summary:hover { background: var(--hover); }
.body-entry > summary .strong { white-space: nowrap; }
.body-entry > summary .muted { text-align: right; }
.body-entry > summary .muted::after { content: ' ›'; }
.body-entry[open] > summary .muted::after { content: ' ⌄'; }
.body-entry[open] > summary { border-bottom: 0; }
.body-details { padding: 0 14px 12px; border-bottom: 1px solid var(--line); }
.body-details .table { max-width: 420px; }

/* Entering measurements (step M2) */
.pill-quiet { margin-left: 8px; font-weight: 600; }
.body-form { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 10px; }
.body-form .stat-label { margin: 14px 0 6px; }
.body-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; }
.body-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; }
.body-field > span:first-child { flex: 1; min-width: 0; }
.body-input { display: inline-flex; align-items: center; gap: 6px; }
.body-input input { width: 84px; text-align: right; padding: 8px 10px; min-height: 40px; }
.body-field input[type='date'], .body-field select { max-width: 60%; }
.row-actions { display: inline-flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Library (W3) */
.grow { flex: 1; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 15px; text-decoration: none; display: inline-flex; align-items: center; }
.row-tools { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; justify-content: flex-end; }
.link-danger { color: var(--danger); }
.lib-row { border-bottom: 1px solid var(--line); }
.lib-row:last-child { border-bottom: 0; }
.lib-row .list-row { border-bottom: 0; }
.lib-row > .notice { margin: 0 14px 12px; }
.lib-panel { border-top: 1px dashed var(--line); padding: 4px 14px 6px; }
.card .lib-panel { padding: 4px 0 6px; margin-bottom: 8px; }
.look { margin: 0 14px 14px; padding-left: 22px; }
.look li { margin-bottom: 4px; }
.list-row-wrap { align-items: flex-start; flex-wrap: wrap; }
textarea, select { font: inherit; color: var(--bone); background: var(--night); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { width: 100%; resize: vertical; box-sizing: border-box; }
select { min-height: 44px; max-width: 100%; }
textarea:focus-visible, select:focus-visible, .icon-btn:focus-visible, input[type='checkbox']:focus-visible, input[type='radio']:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.check-sm { margin: 6px 0; font-size: 15px; color: var(--bone); }
.check input[type='radio'] { width: 20px; height: 20px; accent-color: var(--ember); }
.choice { border: 0; padding: 0; margin: 4px 0 14px; }
.choice legend { padding: 0; margin-bottom: 4px; }
.mini { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mini label { font-size: 13px; font-weight: 600; color: var(--steel); }
.mini input { padding: 9px 10px; min-width: 0; }
.mini-inline { margin: 6px 0 14px; max-width: 360px; }
.ex-list { list-style: none; padding: 0; margin: 0 0 16px; }
.ex-edit { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.ex-linked { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-left: 3px solid var(--ember); }
.ex-linked + .ex-edit { border-top-left-radius: 0; border-top-right-radius: 0; border-top-style: dashed; border-left: 3px solid var(--ember); }
.ex-edit-head { display: flex; align-items: flex-start; gap: 12px; }
.ex-label { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 22px; color: var(--ember); min-width: 34px; line-height: 1.2; }
.ex-name { flex: 1; min-width: 0; }
.ex-tools { display: flex; gap: 6px; }
.icon-btn { font: inherit; font-weight: 700; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--bone); cursor: pointer; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-danger { color: var(--danger); }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 12px 0 4px; }
.ex-checks { display: flex; flex-wrap: wrap; gap: 0 22px; }
.picker-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.picker-bar .field { margin-bottom: 0; }
.pick-list { max-height: 420px; overflow-y: auto; margin-top: 8px; }
.problems { margin: 0; padding-left: 20px; }
.problems-title { font-weight: 700; margin: 0 0 4px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--night); padding: 12px 0; margin-bottom: 0; border-top: 1px solid var(--line); }
.days-edit li { align-items: center; padding: 6px 0; }
.days-edit label { font-weight: 600; }
.days-edit select { min-width: 220px; }
.send .row { margin-bottom: 4px; }

@media (max-width: 640px) {
  .ex-grid { grid-template-columns: repeat(3, 1fr); }
  .lib-row .list-row { flex-wrap: wrap; }
  .lib-row .list-row > .grow { flex-basis: 100%; }
  .list-row-wrap { flex-wrap: wrap; }
  .list-row-wrap > .grow { flex-basis: 100%; }
  .ex-tools .icon-btn { width: 36px; height: 36px; }
  .row-tools { justify-content: flex-start; }
  .days-edit select { min-width: 0; width: 60%; }
}

.warn-note { border-left: 3px solid var(--ember); padding-left: 10px; margin: 0 0 16px; }
.following { margin: -4px 0 16px; }
.following .stat-label { margin-right: 6px; }

/* Notes (W4) */
.note-box { width: 100%; font: inherit; color: var(--bone); background: var(--night); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical; min-height: 96px; margin: 6px 0 8px; }
.note-box:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.note-list { background: var(--card); }
.note-list .note-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.note-list .note-item:last-child { border-bottom: 0; }
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 0; }
.danger-text { color: var(--danger); }
