/* Components for the coaching side. Colours, radii, shadows and fonts
   all come from brand.css -- no hex codes below this line. */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--color-text-muted); }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  font-size: 1.05rem;
}
.sidebar-brand .logo-dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  flex-shrink: 0;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 12px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 2px;
  text-decoration: none;
}
.sidebar-nav a:hover { background: var(--color-surface-muted); color: var(--color-text); }
.sidebar-nav a.active {
  background: var(--color-primary-bg); color: var(--color-primary); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--color-primary);
}
.sidebar-nav .icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a.active .icon { color: var(--color-primary); }
.icon { display: inline-block; vertical-align: -0.18em; }
.btn .icon { vertical-align: 0; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--color-border); }

.main-col {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%;
}
.topbar .sidebar-toggle { display: inline-flex; }
.page-content { padding: 24px; flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.card-header h2, .card-header h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-cols-4 { grid-template-columns: repeat(2, 1fr); } .grid-cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; } }

.stat-card { padding: 16px 18px; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 0.8rem; color: var(--color-text-faint); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--color-surface-muted);
  color: var(--color-text);
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary {
  background: var(--color-primary); color: var(--color-on-primary);
  box-shadow: var(--shadow-inset-brand);
}
.btn-primary:hover { background: var(--color-primary-dark); filter: none; }
.btn-accent { background: var(--color-accent); color: var(--color-on-accent); }
.btn-accent:hover { background: var(--color-accent-dark); filter: none; }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-danger { background: var(--color-danger); color: var(--color-on-accent); }
.btn-outline { background: transparent; border-color: var(--color-border); }
.btn-sm { padding: 5px 11px; font-size: 0.82rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; color: var(--color-text); }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.92rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}
.field { margin-bottom: 16px; }
.field-hint { font-size: 0.78rem; color: var(--color-text-faint); margin-top: 4px; }
.field-error { font-size: 0.78rem; color: var(--color-danger); margin-top: 4px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--color-danger); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 180px; }
fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 16px; margin: 0 0 16px; }
legend { padding: 0 8px; font-weight: 700; font-size: 0.9rem; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.field ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.field ul li { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 500; }
.field ul li input { width: auto; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-gray { background: var(--color-surface-muted); color: var(--color-text-muted); }
.badge-green { background: var(--color-success-bg); color: var(--color-success); }
.badge-red { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-amber { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-blue { background: var(--color-primary-bg); color: var(--color-primary); }
.badge-cyan { background: var(--color-info-bg); color: var(--color-info); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th { color: var(--color-text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: var(--color-surface-muted); }
td.wrap, th.wrap { white-space: normal; }

/* ---------- Misc ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 18px; }
.muted { color: var(--color-text-muted); }
.faint { color: var(--color-text-faint); }
.text-sm { font-size: 0.85rem; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--color-text-muted); }
.empty-state .icon { font-size: 2.2rem; margin-bottom: 10px; }
.divider { height: 1px; background: var(--color-border); margin: 16px 0; border: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); overflow-x: auto; }
.tabs a {
  padding: 10px 14px;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a.active { color: var(--color-primary); border-color: var(--color-primary); }
.tabs span { padding: 10px 14px; color: var(--color-text-muted); font-weight: 600; font-size: 0.88rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs span.active { color: var(--color-primary); border-color: var(--color-primary); }

.progress-bar { height: 8px; background: var(--color-surface-muted); border-radius: 999px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--color-primary); border-radius: 999px; }

.modal-backdrop {
  position: fixed; inset: 0; background: var(--color-scrim);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: var(--color-surface); border-radius: var(--radius-lg);
  max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--color-border); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; }

.messages { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.message-toast {
  padding: 12px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  font-size: 0.88rem; font-weight: 500; background: var(--color-surface); border: 1px solid var(--color-border);
}
.message-toast.success { border-color: var(--color-success); background: var(--color-success-bg); color: var(--color-success); }
.message-toast.error { border-color: var(--color-danger); background: var(--color-danger-bg); color: var(--color-danger); }
.message-toast.info { border-color: var(--color-info); background: var(--color-info-bg); color: var(--color-info); }
.message-toast.warning { border-color: var(--color-warning); background: var(--color-warning-bg); color: var(--color-warning); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--color-primary-bg); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-col { margin-left: 0; }
  .topbar .sidebar-toggle { display: inline-flex; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 14px; }
}

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; padding-bottom: 6px; }
.cal-day {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  /* every day the same box: the grid stays square whatever is booked, and a
     busy Tuesday no longer makes its whole row taller than the others */
  height: 112px; padding: 7px; font-size: 0.78rem;
  display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal-day .cal-more { margin-top: auto; color: var(--color-text-faint); font-size: 0.7rem; }
.cal-title { white-space: nowrap; }
.cal-day.is-week { height: 200px; overflow-y: auto; }
@media (max-width: 720px) {
  .cal-day { height: 88px; padding: 5px; }
}
.cal-day.dim { opacity: 0.4; }
.cal-day.today { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.cal-day-num { font-weight: 700; margin-bottom: 2px; }
.cal-session-chip {
  display: block; padding: 2px 6px; border-radius: 5px; font-size: 0.72rem; font-weight: 600;
  background: var(--color-primary-bg); color: var(--color-primary); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-session-chip.completed { background: var(--color-success-bg); color: var(--color-success); }
.cal-session-chip.cancelled { background: var(--color-danger-bg); color: var(--color-danger); text-decoration: line-through; }
.cal-session-chip.no_show { background: var(--color-warning-bg); color: var(--color-warning); }
.cal-day-link { text-decoration: none; color: inherit; }
.cal-day-link:hover { text-decoration: none; }

/* ---------- HTMX in-flight feedback ---------- */
/* htmx adds this class to the requesting element for the request's
   duration -- gives a visual "processing" cue on real network latency
   (this app runs against a remote database in production, not the
   zero-latency local SQLite it's easy to test against). */
.htmx-request { opacity: 0.6; transition: opacity 0.15s ease; }
.htmx-request button[type="submit"] { cursor: wait; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-col { margin-left: 0 !important; }
  body { background: #fff; }
  .page-content { padding: 0; }
}

/* ---------- Skill ladders ---------- */
.meter { height: 7px; border-radius: 999px; background: var(--color-surface-muted); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--color-primary); transition: width .2s ease; }
.meter-fill.is-met { background: var(--color-success); }
.meter-fill.is-short { background: var(--color-warning); }

.ladder { display: flex; flex-direction: column-reverse; gap: 10px; }
.rung {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px;
  border: 1px solid var(--color-border); border-radius: 12px;
  padding: 12px 14px; background: var(--color-surface);
}
.rung-step {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  font-weight: 700; font-size: 0.85rem;
  background: var(--color-surface-muted); color: var(--color-text-muted);
}
.rung.is-achieved { border-color: var(--color-success); }
.rung.is-achieved .rung-step { background: var(--color-success-bg); color: var(--color-success); }
.rung.is-ready { border-color: var(--color-primary); }
.rung.is-ready .rung-step { background: var(--color-primary-bg); color: var(--color-primary); }
.rung.is-climbing { border-color: var(--color-warning); }
.rung.is-climbing .rung-step { background: var(--color-warning-bg); color: var(--color-warning); }
.rung.is-locked { opacity: 0.72; }

.component { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.component + .component { border-top: 1px dashed var(--color-border); }
.component-name { flex: 1; min-width: 0; font-size: 0.88rem; }
.component-sub { display: block; font-size: 0.76rem; color: var(--color-text-faint); }
.component .meter { flex: 0 0 140px; }
.component-value { flex: 0 0 auto; font-size: 0.82rem; color: var(--color-text-muted); text-align: right; white-space: nowrap; }
@media (max-width: 720px) {
  .component { flex-wrap: wrap; }
  .component .meter { flex: 1 0 100%; order: 3; }
}


/* ---------- Badges: readable, not decorative ---------- */
.badge { border: 1px solid transparent; }
.badge-green { border-color: color-mix(in srgb, var(--color-success) 22%, transparent); }
.badge-amber { border-color: color-mix(in srgb, var(--color-warning) 26%, transparent); }
.badge-red { border-color: color-mix(in srgb, var(--color-danger) 24%, transparent); }
.badge-blue { border-color: color-mix(in srgb, var(--color-primary) 22%, transparent); }
.badge-cyan { border-color: color-mix(in srgb, var(--color-info) 22%, transparent); }
.badge .icon { width: 13px; height: 13px; }

/* Streaks and other numbers that should feel like a small win. */
.flame { color: var(--color-accent); display: inline-flex; align-items: center; gap: 3px; }


/* ---------- Grouped nav, and a sidebar that collapses ---------- */
.nav-heading {
  margin: 14px 0 4px; padding: 0 12px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--color-text-faint);
}
.sidebar-nav > a:first-of-type { margin-top: 0; }
.sidebar-brand { text-decoration: none; color: inherit; }
.sidebar-brand:hover { text-decoration: none; }

.app-shell.is-collapsed .sidebar { width: 68px; }
.app-shell.is-collapsed .main-col { margin-left: 68px; }
.app-shell.is-collapsed .nav-label,
.app-shell.is-collapsed .brand-word,
.app-shell.is-collapsed .nav-heading { display: none; }
.app-shell.is-collapsed .sidebar-nav a { justify-content: center; padding: 11px 0; }
.app-shell.is-collapsed .sidebar-brand { justify-content: center; padding: 18px 0; }
.app-shell.is-collapsed .sidebar-footer { padding: 14px 10px; }
.app-shell.is-collapsed .nav-heading + a { margin-top: 10px; }
.sidebar, .main-col { transition: width 0.16s ease, margin-left 0.16s ease; }

/* ---------- Brand mark ---------- */
.logo { width: 28px; height: 28px; flex-shrink: 0; display: block; }
.logo-square { fill: var(--color-primary); }
.logo-bar { stroke: #fff; }

/* ---------- Charts ---------- */
.chart-box { position: relative; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.chart-box canvas { width: 100% !important; }
.chart-empty {
  margin: 0; text-align: center; color: var(--color-text-faint);
  font-size: 0.88rem;
}

/* ---------- Program weeks: a list, not fifty open cards ---------- */
.week-row { border-bottom: 1px solid var(--color-border); }
.week-row:last-child { border-bottom: 0; }
.week-row > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; list-style: none;
}
.week-row > summary::-webkit-details-marker { display: none; }
.week-row > summary:hover { background: var(--color-surface-muted); }
.week-row[open] > summary { background: var(--color-surface-muted); font-weight: 600; }
.week-num {
  min-width: 42px; font-weight: 700; font-size: 0.82rem; color: var(--color-primary);
}
.week-label { flex: 1; min-width: 0; font-size: 0.88rem; }
.week-body { padding: 4px 20px 14px 62px; }
.callout { border-left: 3px solid var(--color-accent); }

/* rows that open: blocks and weeks read as a list until you want the detail */
.stack-row { border-bottom: 1px solid var(--color-border); }
.stack-row:last-child { border-bottom: 0; }
.stack-row > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; list-style: none;
}
.stack-row > summary::-webkit-details-marker { display: none; }
.stack-row > summary:hover { background: var(--color-surface-muted); }
.stack-row[open] > summary { background: var(--color-surface-muted); }
.inline-tool { position: relative; }
.inline-tool > summary { list-style: none; cursor: pointer; }
.inline-tool > summary::-webkit-details-marker { display: none; }
.inline-tool-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 320px; padding: 12px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}

/* a workout block's table: columns only as wide as they need, actions tight */
.table-wrap table td:last-child, .table-wrap table th:last-child { text-align: right; white-space: nowrap; }
.table-wrap table td:last-child .btn { margin-left: 4px; }

/* ---------- Figures and splits: a number is often the better chart ---------- */
.figure { font-size: 2.4rem; font-weight: 700; line-height: 1.1; margin: 6px 0 10px; letter-spacing: -0.02em; }
.figure-unit { font-size: 1.1rem; font-weight: 600; color: var(--color-text-muted); margin-left: 2px; }

.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--color-surface-muted); margin: 10px 0; }
.split-seg { height: 100%; }
.split-seg.is-done { background: var(--color-success); }
.split-seg.is-going { background: var(--color-primary); }
.split-seg.is-paused { background: var(--color-warning); }
.split-seg.is-idle { background: var(--color-border); }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.legend li { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--color-text-muted); }
.legend strong { margin-left: auto; color: var(--color-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.is-done { background: var(--color-success); }
.dot.is-going { background: var(--color-primary); }
.dot.is-paused { background: var(--color-warning); }
.dot.is-idle { background: var(--color-border); }

/* ---------- Two levels of tabs ---------- */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 10px 0 0; }
.subtabs a {
  padding: 5px 11px; border-radius: 999px; font-size: 0.84rem; font-weight: 500;
  color: var(--color-text-muted); text-decoration: none;
}
.subtabs a:hover { background: var(--color-surface-muted); color: var(--color-text); text-decoration: none; }
.subtabs a.active { background: var(--color-primary-bg); color: var(--color-primary); font-weight: 600; }

/* ---------- A habit, seen from the client's page ---------- */
.habit-line { display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.habit-line + .habit-line { border-top: 1px solid var(--color-border); }
.dot-row { display: flex; gap: 3px; margin-top: 8px; }
.day-dot { width: 11px; height: 11px; border-radius: 3px; background: var(--color-surface-muted); }
.day-dot.is-done { background: var(--color-success); }
.day-dot.is-missed { background: var(--color-danger-bg); border: 1px solid var(--color-danger); }
.day-dot.is-today { background: var(--color-primary-bg); border: 1px solid var(--color-primary); }
.day-dot.is-off { background: transparent; border: 1px dashed var(--color-border); }

/* ---------- The picker ---------- */
.picker-field { display: flex; flex-direction: column; gap: 5px; }
.picker-button {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  width: 100%; min-height: 38px; padding: 8px 11px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text);
  font: inherit; font-size: 0.92rem; text-align: left; cursor: pointer;
}
.picker-button:hover { border-color: var(--color-border-strong, var(--color-primary)); }
.picker-button svg { flex-shrink: 0; color: var(--color-text-faint); }
.picker-button .is-placeholder { color: var(--color-text-faint); }
.picker-button > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picker-modal { position: fixed; inset: 0; z-index: 200; }
.picker-modal[hidden] { display: none; }
.picker-backdrop { position: absolute; inset: 0; background: var(--color-scrim); }
body.has-picker { overflow: hidden; }
.picker-panel {
  position: relative; margin: 8vh auto 0; width: min(640px, calc(100% - 32px));
  max-height: 78vh; display: flex; flex-direction: column;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.picker-search {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.picker-search svg { color: var(--color-text-faint); flex-shrink: 0; }
.picker-search input {
  flex: 1; border: 0; padding: 0; font-size: 1.05rem; background: transparent; color: var(--color-text);
}
.picker-search input:focus { outline: none; box-shadow: none; }
.picker-close {
  border: 0; background: transparent; color: var(--color-text-faint);
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.picker-filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--color-border); }
.picker-filters button {
  border: 1px solid var(--color-border); background: transparent; color: var(--color-text-muted);
  border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 0.8rem; cursor: pointer;
}
.picker-filters button.is-on { background: var(--color-primary-bg); border-color: var(--color-primary); color: var(--color-primary); font-weight: 600; }

.picker-results { overflow-y: auto; flex: 1; }
.picker-heading {
  margin: 0; padding: 10px 16px 4px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--color-text-faint);
}
.picker-list { list-style: none; margin: 0; padding: 4px 0; }
.picker-row {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 9px 16px; cursor: pointer;
}
.picker-row:hover, .picker-row.is-active { background: var(--color-primary-bg); }
.picker-row.is-active { box-shadow: inset 3px 0 0 var(--color-primary); }
.picker-row-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.picker-row-name { font-size: 0.94rem; font-weight: 500; }
.picker-row-meta { font-size: 0.78rem; color: var(--color-text-faint); }
.picker-empty { padding: 22px 16px; color: var(--color-text-muted); text-align: center; }
.picker-hint {
  margin: 0; padding: 9px 16px; border-top: 1px solid var(--color-border);
  font-size: 0.75rem; color: var(--color-text-faint); background: var(--color-surface-muted);
}
.picker-hint kbd {
  display: inline-block; padding: 1px 5px; margin-right: 2px;
  border: 1px solid var(--color-border); border-radius: 4px;
  background: var(--color-surface); font-size: 0.72rem; font-family: inherit;
}
@media (max-width: 640px) {
  .picker-panel { margin-top: 0; width: 100%; max-height: 100vh; height: 100%; border-radius: 0; }
}
.picker-row-contents { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.picker-chip {
  font-size: 0.72rem; color: var(--color-text-muted);
  background: var(--color-surface-muted); border-radius: 5px; padding: 2px 6px;
}
.picker-chip.is-more { color: var(--color-text-faint); }
.picker-row { align-items: flex-start; }
.picker-row .badge { margin-top: 2px; }

/* ---------- Sign-in page ----------
   Its own centred shell: the sign-in page is the one trainer page with no
   sidebar, because there is nothing yet to navigate to. */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; background: var(--color-bg); }
.auth-shell { width: 100%; max-width: 380px; }
/* A longer signed-out page than a sign-in card: the intake questionnaire,
   filled in on a phone. Same ground, room for a form row. */
.public-body { min-height: 100vh; padding: 28px 16px 64px; background: var(--color-bg); }
.public-shell { width: 100%; max-width: 720px; margin: 0 auto; }
.public-shell .auth-brand { margin-bottom: 26px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .logo { width: 34px; height: 34px; }
.auth-word { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-title { font-size: 1.15rem; margin: 0 0 4px; }
.auth-sub { font-size: 0.85rem; color: var(--color-text-muted); margin: 0 0 18px; }
.auth-error {
  background: var(--color-danger-bg); color: var(--color-danger);
  border-radius: var(--radius-md); padding: 10px 12px;
  font-size: 0.85rem; font-weight: 600; margin-bottom: 16px;
}
.auth-shell input[type="text"], .auth-shell input[type="password"] { width: 100%; }

.auth-foot { text-align: center; margin: 14px 0 0; font-size: 0.85rem; }
.auth-foot a { color: var(--color-text-muted); }
.auth-foot a:hover { color: var(--color-primary); }

/* ---------- A summary that opens a form in place ----------
   The browser's disclosure triangle is hidden here the way it is on every
   other summary in the app; without this, a nested <details> keeps the
   default marker and reads as a different kind of control than the row
   above it. */
.add-row > summary {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; list-style: none;
  font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted);
}
.add-row > summary::-webkit-details-marker { display: none; }
.add-row > summary:hover { color: var(--color-primary); }
.add-row[open] > summary { color: var(--color-text); }
/* At the foot of a card it carries the card's own inset, so it lines up
   with the content above instead of hugging the edge. */
.card > .add-row { padding: 12px 20px; border-top: 1px solid var(--color-border); }
/* The foot of a stacked card: what the rows above add up to, and the button
   that acts on it. Same inset as the rows, or it hugs the card edge. */
.card > .card-foot { padding: 14px 20px; border-top: 1px solid var(--color-border); }
.card > .card-foot > .card-foot-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card > .add-row:first-child { border-top: 0; }
