/* CAIRN app — design tokens + base styles
   Dark theme. Mobile-first. Max width 420px. Monospace labels. */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300..700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* ── Legacy tokens (kept for backward compat — values updated to CAIRN palette) ── */
  --bg:           #0D0C07;
  --bg-card:      #161510;
  --bg-elevated:  #201E18;
  --border:       #252320;
  --text:         #ECEAE6;
  --text-dim:     #928D83;
  --text-faint:   #56524A;

  --accent-green:  #3D7A5C;
  --accent-amber:  #B8A44A;
  --accent-blue:   #7A9ED4;
  --accent-purple: #9A3A9A;

  /* ── CAIRN semantic colour tokens ── */
  --color-bg:             #0D0C07;
  --color-surface-01:     #161510;
  --color-surface-02:     #201E18;
  --color-surface-03:     #2A2820;
  --color-border-subtle:  #252320;
  --color-border-default: #3D3A34;
  --color-border-strong:  #56524A;
  --color-text-primary:   #ECEAE6;
  --color-text-secondary: #928D83;
  --color-text-disabled:  #56524A;
  --color-text-dim:       #928D83;
  --color-interactive:        #3D7A5C;
  --color-interactive-hover:  #558F71;
  --color-interactive-active: #306249;
  --color-accent:         #3D7A5C;
  --color-accent-subtle:  #0B1912;
  --color-accent-muted:   #173124;

  /* ── Zone colours ── */
  --zone-1: #7A9ED4;
  --zone-2: #3D7A5C;
  --zone-3: #B8A44A;
  --zone-4: #D47A3A;
  --zone-5: #C44A4A;
  --zone-6: #9A3A9A;

  /* ── Status tokens (dark mode) ── */
  --status-success-bg:     #0F1F18;
  --status-success-text:   #7AAD91;
  --status-success-border: #244A37;
  --status-warning-bg:     #1F1700;
  --status-warning-text:   #E0B44A;
  --status-warning-border: #7A5100;
  --status-error-bg:       #1F0F0C;
  --status-error-text:     #D97B6C;
  --status-error-border:   #7A2A1F;

  /* ── Typography ── */
  --font-body: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* ── Font scale ── */
  --text-body-sm: 0.8125rem;   /* 13px */
  --text-body:    0.9375rem;   /* 15px */
  --text-body-lg: 1.0625rem;   /* 17px */
  --text-h4:      1.0625rem;   /* 17px */
  --text-h3:      1.25rem;     /* 20px */
  --text-h2:      1.5rem;      /* 24px */
  --text-label:   0.75rem;     /* 12px */
  --text-caption: 0.75rem;     /* 12px */
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --max-w: 420px;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 16px;
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 100vh;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 16px;
}

/* ── CAIRN mark (inline SVG helper classes) ── */
.cairn-mark {
  display: block;
  flex-shrink: 0;
}

/* ── Brand lockup: mark + wordmark side by side ── */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-lockup-lg {
  justify-content: center;
  margin-bottom: 4px;
}

.brand {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  text-align: center;
}

.brand-sub {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  margin-bottom: 32px;
  text-align: center;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 12px 14px;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-interactive);
}

.form { display: flex; flex-direction: column; gap: 4px; }
.form > * + label { margin-top: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 120ms;
  width: 100%;
  margin-top: 12px;
}

.btn:hover  { background: var(--border); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-interactive);
  border-color: var(--color-interactive);
  color: var(--color-bg);
  font-weight: 600;
}
.btn-primary:hover { background: var(--color-interactive-hover); }

.btn-google { background: var(--bg-elevated); }

.divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider span { padding: 0 12px; }

.status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-mono);
  line-height: 1.5;
}
.status[data-kind="ok"] {
  background: var(--status-success-bg);
  border: 1px solid var(--status-success-border);
  color: var(--status-success-text);
}
.status[data-kind="error"] {
  background: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--status-error-text);
}

/* App-shell utilities */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-sm {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px 10px;
  cursor: pointer;
}
.btn-icon:hover { color: var(--text); border-color: var(--text-faint); }

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

.mono-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ---------- Wizard ---------- */
.wizard-header {
  margin-bottom: 16px;
}
.wizard-header .mono-label {
  margin-bottom: 6px;
}
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-interactive);
  width: 0%;
  transition: width 200ms ease;
}

.step-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}
.step-help {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
}

.wizard-nav {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.wizard-nav .btn {
  margin-top: 0;
}

/* ---------- Checkbox group ---------- */
.checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
}
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-interactive);
  cursor: pointer;
}
.checkbox-item label {
  font-family: var(--font-body);
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin: 0;
  cursor: pointer;
  flex: 1;
}

/* ---------- Multi-add (goals/injuries) ---------- */
.multi-add {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.multi-add-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.multi-add-item .multi-add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.multi-add-item label {
  margin-top: 8px;
}
.multi-add-item textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px;
  width: 100%;
  resize: vertical;
}

.btn-add {
  margin-top: 12px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
}
.btn-add:hover { color: var(--text); border-color: var(--text-faint); background: transparent; }

.btn-tiny {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  text-transform: uppercase;
}
.btn-tiny:hover { color: var(--color-text-secondary); border-color: var(--color-border-default); }

/* ---------- Review ---------- */
.review-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.review-section:last-child { border-bottom: 0; }
.review-section .mono-label { display: block; margin-bottom: 4px; }
.review-section > div { font-size: 14px; }

/* ---------- Bottom nav + tabs ---------- */
body.has-bottom-nav { padding-bottom: 72px; }

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 4px;
  cursor: pointer;
}
.nav-icon { font-size: 18px; line-height: 1; }
.nav-btn.active { color: var(--color-accent); }

.tab-section { padding-bottom: 16px; }

/* ---------- Profile tab ---------- */
.profile-hello .profile-name {
  font-size: 22px;
  font-weight: 600;
  margin: 4px 0 0;
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.kv-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kv-l {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kv-v { font-size: 14px; color: var(--text); }

.kv-list {
  list-style: none;
  margin: 0; padding: 0;
}
.kv-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.kv-list li:last-child { border-bottom: 0; }
.kv-list .kv-l { font-size: 12px; }
.kv-list .kv-v { font-family: var(--font-mono); }

.goal-item, .injury-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.goal-item:last-child, .injury-item:last-child { border-bottom: 0; }
.goal-d { font-size: 14px; margin-bottom: 4px; }
.goal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.injury-notes {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
}

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid;
}
.pill-green  { color: var(--color-accent);  border-color: var(--color-accent);  background: rgba(61,122,92,.12); }
.pill-amber  { color: var(--accent-amber);  border-color: var(--accent-amber);  background: rgba(200,137,42,.10); }
.pill-blue   { color: var(--accent-blue);   border-color: var(--accent-blue);   background: rgba(74,126,200,.10); }
.pill-purple { color: var(--accent-purple); border-color: var(--accent-purple); background: rgba(136,88,192,.10); }

/* ---------- Secondary button ---------- */
.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-secondary:hover { color: var(--text); }

/* ---------- Session items (Log tab) ---------- */
.session-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.session-item:last-child { border-bottom: 0; }

.session-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-title {
  font-size: 14px;
  flex: 1;
  text-transform: capitalize;
}
.session-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.session-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 2px;
}
.session-notes {
  font-size: 12px;
  line-height: 1.4;
  padding-left: 2px;
}

/* ---------- Coach prompts ---------- */
.coach-actions {
  display: flex;
  gap: 8px;
}
.btn-coach {
  flex: 1;
  font-size: 13px;
  padding: 9px 10px;
  margin-top: 0;
}
.btn-coach-ask {
  margin-top: 8px;
}
.coach-response-text {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text);
}
.coach-response-text.loading {
  color: var(--text-dim);
  font-style: italic;
}

/* ---------- Week plan (Home tab) ---------- */
.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.plan-day {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.plan-day:last-child { border-bottom: 0; }
.plan-day.today { background: rgba(61,122,92,0.06); margin: 0 -24px; padding: 10px 24px; }
.plan-day.today .plan-day-name { color: var(--color-accent); }

.plan-day-hd {
  width: 52px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}
.plan-day-name {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.plan-day-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
}

.plan-day-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.plan-session {
  font-size: 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  cursor: pointer;
}
.plan-session:active { opacity: 0.7; }
.plan-mode-btn {
  flex: 1;
  padding: 7px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.plan-mode-btn.active {
  background: rgba(61,122,92,0.12);
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.plan-time-of-day {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}
.plan-session.move-selected {
  border: 1px solid var(--color-accent);
  border-radius: 6px;
  padding: 3px 6px;
  background: rgba(61,122,92,0.1);
}
.plan-session-meta { color: var(--text-dim); font-size: 12px; }
.plan-rest {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px;
  padding: 3px 8px;
  display: inline-block;
}
.plan-day.past { opacity: 0.45; }
.plan-day.preview-changed { background: rgba(200,137,42,0.08); margin: 0 -24px; padding: 6px 24px; border-radius: 0; }
.plan-day.preview-changed .plan-day-name { color: var(--accent-amber); }
.plan-logged {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-accent);
  letter-spacing: 0.5px;
}

/* ---------- Workout modal (bottom sheet) ---------- */
.workout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.workout-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.workout-modal-sheet {
  background: var(--bg-elevated);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  position: relative;
}
.workout-modal-overlay.open .workout-modal-sheet {
  transform: translateY(0);
}
.workout-modal-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 4px;
}
.workout-modal-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
}
.workout-modal-body {
  padding: 12px 20px 8px;
}
.workout-modal-footer {
  padding: 8px 20px 16px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg-elevated);
}
.workout-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.workout-modal-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.workout-modal-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 4px;
}
.workout-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  margin: 14px 0 6px;
}
.session-plan-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  padding: 10px 12px;
  background: var(--color-accent-subtle);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 6px 6px 0;
  margin-bottom: 4px;
}
.exercise-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.exercise-item:last-child { border-bottom: 0; }
.exercise-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}
.exercise-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-accent);
}
.exercise-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.4;
}
.workout-pacing-item {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.workout-pacing-item:last-child { border-bottom: 0; }
.workout-pacing-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  width: 80px;
  flex-shrink: 0;
  padding-top: 3px;
  text-transform: uppercase;
}
.workout-pacing-val {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.workout-alert {
  background: var(--status-warning-bg);
  border-left: 3px solid var(--status-warning-border);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--color-text-primary);
  line-height: 1.5;
  margin: 10px 0;
}
.workout-tailor-response {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
  margin-top: 14px;
}

/* ── Coach UI: Daily Brief (CAIRN 11.1) ── */
.cairn-brief {
  background: var(--color-surface-01);
  border: 1px solid var(--color-border-subtle);
  border-left: 3px solid var(--color-accent);
  border-radius: 12px;
  padding: 14px 16px;
}
.cairn-brief-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cairn-brief-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.cairn-brief-refresh {
  font-size: 14px;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}
.cairn-brief-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-primary);
  max-height: 220px;
  overflow-y: auto;
}
.cairn-brief-body.stale { opacity: 0.5; }

/* ── Coach UI: Nutrition Card (CAIRN 11.2) ── */
.cairn-nutrition {
  background: var(--color-surface-01);
  border: 1px solid var(--color-border-subtle);
  border-left: 3px solid var(--color-border-strong);
  border-radius: 12px;
  padding: 14px 16px;
}
.cairn-nutrition-divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: 10px 0;
}
.cairn-nutrition-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}
.cairn-nutrition-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-primary);
}

/* ── Coach UI: Chat messages (CAIRN 11.3) ── */
.chat-msg-user {
  align-self: flex-end;
  background: #244A37;
  border-radius: 10px 10px 2px 10px;
  padding: 8px 12px;
  max-width: 75%;
  font-size: 13px;
  line-height: 1.5;
  color: #A9CAB5;
}
.chat-msg-coach {
  align-self: flex-start;
  background: var(--color-surface-01);
  border: 1px solid var(--color-border-subtle);
  border-radius: 10px 10px 10px 2px;
  padding: 8px 12px;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-primary);
}
.coach-response-card {
  width: 100%;
  background: var(--color-surface-02);
  border: 1px solid var(--color-border-default);
  border-left: 3px solid var(--color-accent);
  border-radius: 12px;
  padding: 14px 16px;
  align-self: flex-start;
}
.coach-response-card-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border-subtle);
}
.coach-response-card-section:last-child { border-bottom: 0; }
.coach-response-card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

/* ── Session plan note (CAIRN 11.4) ── */
.session-plan-note {
  background: var(--color-accent-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: #7AAD91;
  margin-top: 8px;
}

/* ── Profile edit modal ── */
.btn-edit-profile {
  background: none;
  border: 1px solid var(--color-border-default);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
}
.btn-edit-profile:hover { border-color: var(--color-accent); color: var(--color-accent); }

.profile-edit-section { padding-bottom: 16px; border-bottom: 1px solid var(--color-border-subtle); }
.profile-edit-section:last-child { border-bottom: none; }

/* ── Event priority radios (shared: onboarding + profile edit) ── */
.event-priority-row {
  display: flex; gap: 8px; margin-top: 4px;
}
.event-priority-row label {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 8px; border: 1px solid rgba(255,255,255,0.12); border-radius: 8px;
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.event-priority-row input[type="radio"] { display: none; }
.event-priority-row label:has(input[value="A"]:checked) {
  border-color: var(--color-accent); background: rgba(61,122,92,0.14); color: var(--color-accent);
}
.event-priority-row label:has(input[value="B"]:checked) {
  border-color: var(--accent-blue,#4a7ec8); background: rgba(74,126,200,0.14); color: var(--accent-blue,#4a7ec8);
}
.event-priority-row label:has(input[value="C"]:checked) {
  border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.06);
}
.events-conflict {
  margin-top: 12px; padding: 10px 14px;
  background: rgba(200,137,42,0.12); border: 1px solid var(--accent-amber,#c8892a);
  border-radius: 8px; font-size: 0.8rem; color: var(--accent-amber,#c8892a); line-height: 1.4;
}

/* ── Plan proposal (CAIRN 11.5) ── */
.plan-proposal-card {
  width: 100%;
  background: var(--color-surface-02);
  border: 1px solid var(--color-border-default);
  border-left: 3px solid var(--color-accent);
  border-radius: 12px;
  padding: 14px 16px;
}
.plan-proposal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.plan-proposal-actions .btn {
  margin-top: 0;
  height: 44px;
  padding: 0 16px;
}

/* ── Coach message row: avatar + bubble ── */
.coach-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  align-self: flex-start;
  width: 100%;
}
.coach-msg-avatar {
  width: 26px;
  height: 26px;
  background: var(--color-accent-subtle);
  border: 1px solid var(--color-accent-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Drag-to-reorder ── */
.plan-session {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}
.plan-session:active { cursor: grabbing; }
.plan-day.drag-over > .plan-day-body {
  outline: 1px dashed var(--color-accent);
  outline-offset: 4px;
  border-radius: 4px;
  background: rgba(61,122,92,0.07);
}
.plan-session.drag-lifting {
  opacity: 0.25;
  pointer-events: none;
}

/* ── Analytics / Progress tab (Phase 30) ── */

/* Summary stat row */
.analytics-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 0;
}
.analytics-stat {
  background: var(--color-surface-01);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.analytics-stat-val {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1;
  font-family: var(--font-mono);
}
.analytics-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}
.analytics-stat-sub {
  font-size: 10px;
  color: var(--color-text-disabled);
  font-family: var(--font-mono);
}

/* Two-chart row (sport + effort side by side on wider screens) */
.analytics-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.analytics-half { flex: 1; }

/* Chart canvas wrappers — fixed heights so Chart.js sizes correctly */
.analytics-chart-wrap {
  position: relative;
  height: 200px;
}
.analytics-chart-sm {
  height: 160px;
}

/* ── Sidebar nav (desktop only — hidden on mobile) ── */
.sidebar-nav { display: none; }

/* ── Responsive desktop layout (≥768px) ── */
@media (min-width: 768px) {

  body.has-bottom-nav {
    padding-bottom: 0;
    padding-left: 200px; /* sidebar width */
  }

  /* Left-align main within the content area — do NOT use margin: 0 auto here,
     that would centre it in the post-sidebar space and create a huge left gap */
  main {
    max-width: 1280px;
    margin: 0;
    padding: 24px 32px;
  }

  /* Hide the mobile bottom nav */
  .bottom-nav { display: none !important; }

  /* ── Sidebar nav ── */
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 200px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 0;
    z-index: 200;
    overflow: hidden;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .sidebar-nav-items {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
  }
  .sidebar-nav-footer {
    border-top: 1px solid var(--border);
    padding: 8px 0;
    flex-shrink: 0;
  }
  .sidebar-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    border-radius: 0;
    transition: background 120ms, color 120ms;
  }
  .sidebar-nav-btn:hover { color: var(--text-dim); background: rgba(255,255,255,0.03); }
  .sidebar-nav-btn.active { color: var(--color-accent); }
  .sidebar-nav-btn.active .sidebar-nav-icon { color: var(--color-accent); }
  .sidebar-nav-icon { font-size: 16px; line-height: 1; flex-shrink: 0; }

  /* Main header — simplify on desktop (branding lives in sidebar) */
  .app-header .brand-lockup { display: none; }

  /* Home tab — two-column grid on desktop (only when visible) */
  /* Left column (col 1): plan card + phase card */
  /* Right column (col 2): everything else */
  .tab-section[data-tab="home"]:not([hidden]) {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 12px;
    align-items: start;
  }
  /* Neutralise inline margin-top on every direct child — gap handles spacing */
  .tab-section[data-tab="home"] > * {
    margin-top: 0 !important;
  }
  /* Column assignments */
  #home-plan-card  { grid-column: 1; }
  #home-phase-card { grid-column: 1; }
  #home-greeting,
  #home-readiness-card,
  #home-daily-brief-card,
  #home-recent-card,
  #home-coach-card {
    grid-column: 2;
  }

  /* Analytics charts — allow two side-by-side */
  .analytics-row { flex-direction: row; }
  .analytics-chart-sm { height: 200px; }

  /* Coach tab chat — wider message bubbles on desktop */
  .chat-msg-coach { max-width: 72%; }
  .chat-msg-user  { max-width: 60%; }

  /* Bottom sheet modals — constrain width on desktop */
  .workout-modal-sheet {
    max-width: 540px;
    margin: 0 auto;
    border-radius: 16px;
  }
  .workout-modal-overlay { align-items: center; }
}

/* ── Daily readiness check-in (Phase 25) ── */
.readiness-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.readiness-label {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  width: 62px;
  flex-shrink: 0;
}
.readiness-dots {
  display: flex;
  gap: 6px;
}
.readiness-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-subtle);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.readiness-dot:hover:not(.selected) {
  border-color: var(--color-text-secondary);
}
.readiness-dot.selected {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
}
.readiness-scale-hint {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--color-text-faint);
  white-space: nowrap;
  margin-left: 4px;
}
