/* Mobile-first: everything must work one-handed at 375px. */
:root {
  --bg: #fff;
  --fg: #16181d;
  --muted: #5b6270;
  --accent: #0b6e4f;
  --border: #d9dde3;
  --border-strong: #6b7280;
  --accent-strong: #0b6e4f;
  --on-accent: #fff;
  --danger: #b3261e;
  --focus: #1a56db;
  --tap: 44px; /* minimum touch target */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --fg: #eceef2;
    --muted: #9aa2b1;
    --accent: #4cc79a;
    --border: #2b303a;
    --border-strong: #8a93a3;
    --accent-strong: #4cc79a;
    --on-accent: #0c1a14;
    --danger: #ff8a80;
    --focus: #8ab4ff;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, sans-serif;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 { font-size: 1.5rem; line-height: 1.2; }

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

button, input, select, textarea {
  font: inherit;
  min-height: var(--tap);
}

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

.error { color: var(--danger); margin: 0.25rem 0 0; }

.field { margin-bottom: 1rem; }

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--fg);
}

input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent-strong);
  border-radius: 0.5rem;
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button.secondary, .button.secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}

.actions { display: grid; gap: 0.75rem; }

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

.lead { font-size: 1.25rem; }

.notice {
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent-strong);
  border-radius: 0.5rem;
}

.signout { margin-top: 2rem; }

/* Signed-in layout: title on top, tabs within thumb reach at the bottom. */
body.app { padding-bottom: calc(3.5rem + env(safe-area-inset-bottom)); }

/* When the browser scrolls something into view (keyboard focus, an anchor),
   keep it clear of the sticky top bar and the fixed tab bar. */
html:has(body.app) {
  scroll-padding-top: 4rem;
  scroll-padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { max-width: 38rem; margin: 0 auto; font-size: 1.25rem; }

.tabs {
  position: fixed;
  inset: auto 0 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  border-top: 3px solid transparent;
}

.tabs a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }

.hint { color: var(--muted); font-size: 0.875rem; margin: 0.25rem 0 0; }

textarea { resize: vertical; }

.list { list-style: none; margin: 1rem 0; padding: 0; border-top: 1px solid var(--border); }

.list li { border-bottom: 1px solid var(--border); }

/* the whole row is the link, so the touch target is the full width */
.list li > a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 3.5rem;
  padding: 0.5rem 0;
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.list-title { font-weight: 600; }

.empty { text-align: center; padding: 2rem 0; }

.empty h2 { font-size: 1.25rem; }

.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }

h2 { font-size: 1.25rem; line-height: 1.3; }

.search { margin: 1rem 0; }

/* A row of radio buttons drawn as one segmented control. Each input covers
   its whole segment, so the touch target is the segment itself. */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.segmented legend { padding: 0; font-weight: 600; margin-bottom: 0.25rem; }

.segmented label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  margin: 0;
  font-weight: 600;
  border: 1px solid var(--border-strong);
}

.segmented label + label { border-left: 0; }
.segmented label:first-of-type { border-radius: 0.5rem 0 0 0.5rem; }
.segmented label:last-of-type { border-radius: 0 0.5rem 0.5rem 0; }

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented label:has(input:checked) { background: var(--accent-strong); color: var(--on-accent); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* htmx adds this class to <body> when it starts: the submit button is only
   needed when the list cannot update by itself. */
.htmx-ready .no-js-only { display: none; }

.badge {
  display: inline-block;
  padding: 0 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 1rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.no-results { padding: 1rem 0; }

.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.profile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.badge-active { color: var(--accent); border-color: var(--accent); }

.contact { list-style: none; margin: 0 0 1rem; padding: 0; }

.contact a, .note-actions a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  min-width: var(--tap);
  overflow-wrap: anywhere;
}

.callout {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-strong);
  border-left-width: 0.375rem;
  border-radius: 0.5rem;
}

.callout h2 { margin: 0 0 0.25rem; font-size: 1rem; }
.callout p { margin: 0 0 0.5rem; }
.callout-warning { border-left-color: var(--danger); }

.timeline { list-style: none; margin: 1rem 0; padding: 0; border-top: 1px solid var(--border); }
.timeline > li { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.timeline-meta { margin: 0; color: var(--muted); font-size: 0.875rem; }
.timeline .prewrap { margin: 0.25rem 0; }

.note-actions { display: flex; gap: 1.5rem; margin: 0; }

/* A group of related fields with a heading. */
.group { margin: 0 0 1rem; padding: 0.75rem 1rem 0; border: 1px solid var(--border); border-radius: 0.5rem; }
.group legend { padding: 0 0.25rem; font-weight: 600; }
.group > .hint { margin-bottom: 1rem; }

/* A checkbox whose input covers the whole label, so the label is the touch
   target; the visible box is drawn before the text. */
.check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--tap);
  margin: 0;
}

.check input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.check span::before {
  content: "";
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border-strong);
  border-radius: 0.25rem;
  color: var(--on-accent);
  font-weight: 700;
  line-height: 1;
}

.check span { display: flex; align-items: center; gap: 0.75rem; }
.check input:checked + span::before { content: "✓"; background: var(--accent-strong); border-color: var(--accent-strong); }
.check input:focus-visible + span::before { outline: 3px solid var(--focus); outline-offset: 2px; }
.check input[aria-invalid="true"] + span::before { border-color: var(--danger); }

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

button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: var(--bg); }
.button.secondary.danger { background: transparent; color: var(--danger); border-color: var(--danger); }

/* A list row with text on the left and one action on the right. */
.list li.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
  padding: 0.5rem 0;
}

.list li.list-row > div { display: flex; flex-direction: column; overflow-wrap: anywhere; }
.list li.list-row form { flex: none; }
.list li.list-row button { width: auto; }

.settings-links { margin-top: 2rem; }

/* A field shown only while the select that controls it has a given value
   (app.js); without JavaScript it stays visible. */
.field[hidden] { display: none; }

/* Two fields side by side, e.g. a from–to range. */
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.75rem; }
.pair input { min-width: 0; }

/* A link inside running text or a list row, still a full-size touch target. */
.inline-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  min-width: var(--tap);
}

section + section { margin-top: 2rem; }

/* The calendar: one section per day of the week. */
.week-nav { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.week-nav h2 { margin: 0; font-size: 1rem; text-align: center; }
.week-nav .button { width: auto; padding: 0; font-size: 1.5rem; line-height: 1; }

.day { margin-top: 0; padding: 0.75rem 0 0.25rem; border-top: 1px solid var(--border); }
section + section.day { margin-top: 0; }
.day h3 { margin: 0; font-size: 1.0625rem; }
.day .hint { margin: 0; }
.day .list { margin: 0.5rem 0 0; }
.day-today { border-top: 3px solid var(--accent); }

.cancelled .list-title { text-decoration: line-through; }

/* Start times of a day, as a wrapping row of chips. */
.slots { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 0.5rem 0 0.75rem; padding: 0; }
.slots li { padding: 0.25rem 0.625rem; border: 1px solid var(--border-strong); border-radius: 0.5rem; font-variant-numeric: tabular-nums; }

/* Bookable start times on the client's booking page: one tappable chip each. */
.slot-links { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 0.5rem 0 0.75rem; padding: 0; }
.slot-links a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.slot-links button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.5rem 1rem;
  font-variant-numeric: tabular-nums;
}
.slot-links small { font-weight: 400; font-size: 0.75rem; color: var(--muted); }

/* Client portal: the trainer's name sits above the page. */
.book-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

button[hidden] { display: none; }

.booking-link { overflow-wrap: anywhere; font-weight: 600; user-select: all; }

.outcomes { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.list .outcomes { padding: 0 1rem 1rem; margin: 0; }
.outcomes form { margin: 0; }
.needs-marking { border-left: 3px solid var(--accent); }
