/* Tempo's look and feel, layered on Bootstrap 5.
 *
 * Tokens first (light, then dark), then Bootstrap overrides, then Tempo components.
 * Coral is the brand color. Text on coral uses --tempo-accent (a darker coral in
 * light mode, a lighter one in dark mode) so it keeps 4.5:1 contrast.
 * Chart palettes are validated for color blindness in both modes (see the
 * dataviz notes in docs/architecture.md). */

/* --- Tokens ------------------------------------------------------------------ */
:root,
[data-bs-theme="light"] {
  --tempo-font-display: "Nunito", system-ui, sans-serif;
  --tempo-font-body: "Nunito Sans", system-ui, sans-serif;

  --tempo-bg: #fbf8f5;
  --tempo-surface: #ffffff;
  --tempo-fill: #f4efea;
  --tempo-border: #e9e2dc;
  --tempo-text: #1f1b19;
  --tempo-text-2: #6b625d;
  --tempo-coral: #e8664a;
  --tempo-accent: #c24a31;
  --tempo-accent-hover: #9e3a25;
  --tempo-accent-soft: #fdebe5;
  --tempo-on-accent: #ffffff;
  --tempo-hero-bg: #1f1b19;
  --tempo-hero-text: #f7f2ee;
  --tempo-hero-muted: #d9d0ca;
  --tempo-hero-accent: #f08a6c;
  --tempo-radius: 20px;
  --tempo-radius-lg: 28px;

  /* Charts */
  --viz-surface: var(--tempo-surface);
  --viz-text: var(--tempo-text);
  --viz-text-muted: #8a817b;
  --viz-grid: #ede7e1;
  --viz-axis: #d9d0ca;
  --zone-1: #f0937a;
  --zone-2: #e8704f;
  --zone-3: #d4553a;
  --zone-4: #ac4029;
  --zone-5: #7f2e1c;
  --no-data: #d9d0ca;
  --activity-running: #eb6834;
  --activity-strength: #2a78d6;
  --activity-cycling: #1baf7a;
  --activity-walking: #4a3aa7;
  --activity-other: #a79d97;
  --load: #b9aea7;
  --status-serious: #ec835a;
}

[data-bs-theme="dark"] {
  --tempo-bg: #141110;
  --tempo-surface: #1f1b19;
  --tempo-fill: #2a2522;
  --tempo-border: #36302c;
  --tempo-text: #f7f2ee;
  --tempo-text-2: #a79d97;
  --tempo-coral: #f08a6c;
  --tempo-accent: #f08a6c;
  --tempo-accent-hover: #f7b7a3;
  --tempo-accent-soft: #3a2019;
  --tempo-on-accent: #1f1b19;
  --tempo-hero-bg: #2a2522;

  --viz-text-muted: #8a817b;
  --viz-grid: #2c2724;
  --viz-axis: #3d3632;
  --zone-1: #8a2e1c;
  --zone-2: #b3432a;
  --zone-3: #e0603f;
  --zone-4: #f08a6c;
  --zone-5: #f7b7a3;
  --no-data: #4a423d;
  --activity-running: #d95926;
  --activity-strength: #3987e5;
  --activity-cycling: #199e70;
  --activity-walking: #9085e9;
  --activity-other: #8a817b;
  --load: #5c534e;
}

/* --- Bootstrap overrides ------------------------------------------------------- */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-body-font-family: var(--tempo-font-body);
  --bs-body-bg: var(--tempo-bg);
  --bs-body-color: var(--tempo-text);
  --bs-emphasis-color: var(--tempo-text);
  --bs-secondary-color: var(--tempo-text-2);
  --bs-tertiary-bg: var(--tempo-fill);
  --bs-border-color: var(--tempo-border);
  --bs-link-color: var(--tempo-accent);
  --bs-link-color-rgb: 194, 74, 49;
  --bs-link-hover-color: var(--tempo-accent-hover);
  --bs-link-hover-color-rgb: 158, 58, 37;
  --bs-card-bg: var(--tempo-surface);
  --bs-border-radius: 12px;
  --bs-focus-ring-color: color-mix(in srgb, var(--tempo-coral) 35%, transparent);
}

[data-bs-theme="dark"] {
  --bs-link-color-rgb: 240, 138, 108;
  --bs-link-hover-color-rgb: 247, 183, 163;
}

body {
  background: var(--tempo-bg);
}

h1, h2, h3, h4, h5, h6,
.font-display {
  font-family: var(--tempo-font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
}

a {
  text-underline-offset: 0.2em;
}

.text-body-secondary {
  color: var(--tempo-text-2) !important;
}

.btn {
  --bs-btn-border-radius: 999px;
  --bs-btn-font-family: var(--tempo-font-display);
  --bs-btn-font-weight: 800;
  --bs-btn-padding-x: 1.25rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-sm {
  min-height: 36px;
  --bs-btn-padding-x: 0.9rem;
}

.btn-primary {
  --bs-btn-bg: var(--tempo-accent);
  --bs-btn-border-color: var(--tempo-accent);
  --bs-btn-color: var(--tempo-on-accent);
  --bs-btn-hover-bg: var(--tempo-accent-hover);
  --bs-btn-hover-border-color: var(--tempo-accent-hover);
  --bs-btn-hover-color: var(--tempo-on-accent);
  --bs-btn-active-bg: var(--tempo-accent-hover);
  --bs-btn-active-border-color: var(--tempo-accent-hover);
  --bs-btn-active-color: var(--tempo-on-accent);
}

.btn-outline-primary {
  --bs-btn-color: var(--tempo-accent);
  --bs-btn-border-color: var(--tempo-border);
  --bs-btn-hover-bg: var(--tempo-accent-soft);
  --bs-btn-hover-border-color: var(--tempo-accent);
  --bs-btn-hover-color: var(--tempo-accent);
  --bs-btn-active-bg: var(--tempo-accent-soft);
  --bs-btn-active-color: var(--tempo-accent);
}

.form-control,
.form-select,
main form input:not([type="checkbox"]):not([type="hidden"]):not([type="radio"]),
main form select,
main form textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--tempo-border);
  border-radius: 12px;
  background-color: var(--tempo-surface);
  color: var(--tempo-text);
}

.form-select-sm {
  min-height: 36px;
  border-radius: 999px;
}

main form input:focus,
main form select:focus,
main form textarea:focus,
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--tempo-coral);
  box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
}

.form-label {
  font-weight: 600;
}

.alert {
  border: none;
  border-radius: 16px;
}

.alert-info,
.alert-success {
  --bs-alert-bg: var(--tempo-accent-soft);
  --bs-alert-color: var(--tempo-text);
  --bs-alert-link-color: var(--tempo-accent);
}

.alert-warning {
  --bs-alert-bg: var(--tempo-fill);
  --bs-alert-color: var(--tempo-text);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--tempo-text);
  --bs-table-border-color: var(--tempo-border);
}

.table > thead th {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--tempo-text-2);
}

/* --- Layout ------------------------------------------------------------------------ */
.app-main {
  max-width: 1180px;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

.site-header {
  background: var(--tempo-surface);
  border-bottom: 1px solid var(--tempo-border);
}

.site-header .inner {
  max-width: 1180px;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--tempo-text);
  text-decoration: none;
}

.brand:hover {
  color: var(--tempo-text);
}

.brand .wordmark {
  font-family: var(--tempo-font-display);
  font-weight: 900;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.nav-pills-tempo {
  display: flex;
  gap: 0.25rem;
}

.nav-pills-tempo a {
  padding: 0.55rem 1rem;
  border-radius: 999px;
  color: var(--tempo-text);
  font-weight: 600;
  text-decoration: none;
}

.nav-pills-tempo a:hover {
  background: var(--tempo-fill);
}

.nav-pills-tempo a[aria-current="page"] {
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
  font-weight: 700;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--tempo-text);
  color: var(--tempo-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--tempo-font-display);
  font-weight: 800;
  text-decoration: none;
}

.avatar:hover {
  color: var(--tempo-bg);
  opacity: 0.9;
}

/* Bottom tab bar on phones. */
.tab-bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1030;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--tempo-surface);
  border-top: 1px solid var(--tempo-border);
}

.tab-bar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--tempo-text-2);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
}

.tab-bar a[aria-current="page"] {
  color: var(--tempo-accent);
  font-weight: 800;
}

@media (max-width: 767.98px) {
  body.has-tab-bar {
    /* The tab bar plus the coach chat's floating button above it. */
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 768px) {
  body.has-tab-bar {
    padding-bottom: 6rem; /* room for the coach chat's floating button */
  }
}

/* Sign in / sign up. */
.layout-entrance .app-main {
  max-width: 460px;
  padding-top: 3rem;
}

.entrance-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.layout-entrance .entrance-card {
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
  border-radius: var(--tempo-radius-lg);
  padding: 2rem;
}

.layout-entrance .entrance-card h1 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.layout-entrance .entrance-card button[type="submit"] {
  width: 100%;
  min-height: 48px;
  margin-top: 0.5rem;
  border: none;
  border-radius: 999px;
  background: var(--tempo-accent);
  color: var(--tempo-on-accent);
  font-family: var(--tempo-font-display);
  font-weight: 800;
  font-size: 1rem;
}

.layout-entrance .entrance-card button[type="submit"]:hover {
  background: var(--tempo-accent-hover);
}

.layout-entrance .entrance-card label {
  font-weight: 600;
  margin: 0.75rem 0 0.25rem;
}

/* --- Components ---------------------------------------------------------------- */
.page-title {
  font-size: 1.9rem;
  font-weight: 900;
  margin: 0;
}

.eyebrow {
  font-family: var(--tempo-font-display);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tempo-accent);
}

.card-tempo {
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
  border-radius: var(--tempo-radius);
  padding: 1.25rem 1.5rem;
}

.card-tempo > h2,
.card-tempo .card-title {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}

.coach-hero {
  background: var(--tempo-hero-bg);
  color: var(--tempo-hero-text);
  border-radius: var(--tempo-radius-lg);
  padding: 1.75rem 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

.coach-hero .date {
  color: var(--tempo-hero-muted);
  font-size: 0.95rem;
}

.coach-hero h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.25rem);
  font-weight: 900;
  line-height: 1.15;
  margin: 0.25rem 0 0.5rem;
}

.coach-hero p {
  color: var(--tempo-hero-muted);
  font-size: 1.05rem;
  margin: 0;
  max-width: 40rem;
}

.coach-hero .hero-figure {
  text-align: right;
}

@media (max-width: 767.98px) {
  .coach-hero .hero-figure {
    text-align: left;
  }
}

.coach-hero .hero-figure .value {
  font-family: var(--tempo-font-display);
  font-weight: 900;
  font-size: clamp(2.5rem, 7vw, 4rem);
  line-height: 1;
  color: var(--tempo-hero-accent);
}

.coach-hero .hero-figure .label {
  color: var(--tempo-hero-muted);
  font-size: 0.95rem;
}

.stat-tile {
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
  border-radius: var(--tempo-radius);
  padding: 1.1rem 1.25rem;
  height: 100%;
}

.stat-tile .label,
.stat-tile .detail {
  color: var(--tempo-text-2);
  font-size: 0.9rem;
}

.stat-tile .value {
  overflow-wrap: anywhere;
  font-family: var(--tempo-font-display);
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1.2;
}

.stat-grid dt {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tempo-text-2);
}

.stat-grid dd {
  font-family: var(--tempo-font-display);
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0;
}

.stat-grid .hero-stat dd {
  font-size: 2.75rem;
  font-weight: 900;
  line-height: 1;
}

.workout-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  background: var(--tempo-bg);
  color: var(--tempo-text);
  text-decoration: none;
}

.workout-row + .workout-row {
  margin-top: 0.5rem;
}

.workout-row:hover {
  color: var(--tempo-text);
  background: var(--tempo-fill);
}

.workout-row .title {
  font-weight: 700;
}

.workout-row .meta {
  color: var(--tempo-text-2);
  font-size: 0.85rem;
}

.activity-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tempo-fill);
  color: var(--tempo-text-2);
}

.activity-icon.activity-running {
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-row .form-select-sm {
  width: auto;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* --- Charts & zone graphics -------------------------------------------------------- */
.chart-box {
  position: relative;
  height: 280px;
}

.zone-swatch,
.legend-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  vertical-align: -0.05rem;
  margin-right: 0.35rem;
}

.zone-1 { background: var(--zone-1); }
.zone-2 { background: var(--zone-2); }
.zone-3 { background: var(--zone-3); }
.zone-4 { background: var(--zone-4); }
.zone-5 { background: var(--zone-5); }
.zone-none { background: var(--no-data); }

.zone-bar {
  display: flex;
  gap: 2px;
  height: 0.75rem;
  border-radius: 6px;
  overflow: hidden;
}

.pace-cell {
  min-width: 11rem;
}

.pace-value {
  display: inline-block;
  width: 3.5rem;
}

.pace-bar {
  display: inline-block;
  width: 6rem;
  height: 0.5rem;
  vertical-align: middle;
  background: var(--tempo-fill);
  border-radius: 4px;
  overflow: hidden;
}

.pace-bar > span {
  display: block;
  height: 100%;
  background: var(--zone-1);
  border-radius: 0 4px 4px 0;
}

.fastest .pace-bar > span {
  background: var(--tempo-accent);
}

/* --- Responsive details ------------------------------------------------------- */
select.form-select,
main form select {
  padding-right: 2.25rem;
}

.table.tabular td,
.table.tabular th {
  white-space: nowrap;
}

.layout-entrance .site-header .brand {
  visibility: hidden;
}

@media (max-width: 575.98px) {
  .pace-bar {
    display: none;
  }

  .pace-cell {
    min-width: 0;
  }

  .coach-hero {
    padding: 1.4rem 1.25rem;
  }
}

@media (min-width: 768px) {
  .coach-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
}

/* --- Exercise progression ---------------------------------------------------------- */
.exercise-link {
  color: var(--tempo-text);
  text-decoration: none;
}

.exercise-link:hover {
  color: var(--tempo-accent);
  text-decoration: underline;
}

.exercise-session {
  padding: 0.85rem 0;
  border-top: 1px solid var(--tempo-border);
}

.exercise-session:first-of-type {
  border-top: none;
  padding-top: 0;
}

.set-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.set-chip {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--tempo-fill);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.set-chip.is-warmup {
  background: transparent;
  border: 1px dashed var(--tempo-border);
}

.record-chip {
  margin-left: 0.35rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
  font-weight: 700;
  font-size: 0.75rem;
}

/* --- AI coach ------------------------------------------------------------------------ */
.onboarding {
  max-width: 720px;
}

.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.choice-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0 0.9rem;
  border: 1px solid var(--tempo-border);
  border-radius: 999px;
  background: var(--tempo-surface);
  cursor: pointer;
  font-weight: 600;
}

.choice-chip:has(input:checked) {
  border-color: var(--tempo-accent);
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
}

.choice-chip input {
  accent-color: var(--tempo-accent);
}

.coach-hero .coach-text {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tempo-hero-muted);
  font-size: 1.05rem;
  text-align: left;
  max-width: 40rem;
  cursor: pointer;
}

/* Two lines until tapped (data-expand-toggle in coach.js). */
.coach-hero .coach-text.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* Today's session on the dashboard: one row that opens to show the details. */
.today-row {
  padding-block: 0.85rem;
}

.today-row summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  list-style: none;
  cursor: pointer;
}

.today-row summary::-webkit-details-marker {
  display: none;
}

.today-row summary .planned-session {
  flex: 1;
  min-width: 0;
}

.today-label {
  display: block;
  color: var(--tempo-text-2);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.today-row summary .today-label {
  flex-basis: 100%;
}

.today-chevron {
  color: var(--tempo-text-2);
  transition: transform 0.2s;
}

.today-row details[open] .today-chevron {
  transform: rotate(90deg);
}

.today-details {
  padding: 0.5rem 0 0 calc(44px + 1rem);
}

.planned-session + .planned-session {
  margin-top: 0.75rem;
}

.session-steps {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
}

.activity-icon.activity-rest,
.activity-icon.activity-mobility {
  background: var(--tempo-fill);
  color: var(--tempo-text-2);
}

.phase-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.phase-list li {
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: var(--tempo-fill);
}

.plan-day {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--tempo-border);
}

.plan-day:first-of-type {
  border-top: none;
}

.plan-day.is-today {
  margin: 0 -0.75rem;
  padding: 0.85rem 0.75rem;
  border-radius: 16px;
  background: var(--tempo-accent-soft);
  border-top-color: transparent;
}

.plan-day.is-past {
  opacity: 0.6;
}

.plan-day-date {
  flex: 0 0 3.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.plan-day-date .weekday {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--tempo-text-2);
}

.plan-day-date .daynum {
  font-family: var(--tempo-font-display);
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
}

.comment-form textarea {
  width: 100%;
}

.chat-message {
  margin-top: 0.75rem;
}

/* --- Coach chat: floating button and panel (templates/coach/_chat.html) ------------- */
.chat-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  z-index: 1031;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--tempo-accent);
  color: var(--tempo-on-accent);
  box-shadow: 0 8px 24px rgb(31 27 25 / 28%);
  text-decoration: none;
}

.chat-fab:hover {
  background: var(--tempo-accent-hover);
  color: var(--tempo-on-accent);
}

@media (max-width: 767.98px) {
  .chat-fab {
    right: 1rem;
    bottom: calc(64px + env(safe-area-inset-bottom) + 1rem);
  }
}

.chat-fab-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--tempo-text);
  border: 2px solid var(--tempo-bg);
}

/* The coach is working: a ring turns around the button. */
.chat-fab.is-working::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--tempo-coral);
  animation: chat-spin 1s linear infinite;
}

@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}

.chat-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--tempo-border);
  background: var(--tempo-bg);
  color: var(--tempo-text);
  flex-direction: column;
}

.chat-panel[open] {
  display: flex;
}

.chat-panel::backdrop {
  background: rgb(31 27 25 / 42%);
}

.chat-grabber,
.chat-expand {
  display: none;
}

@media (max-width: 767.98px) {
  /* On phones: a sheet from the bottom, half or almost full height. */
  .chat-panel {
    inset: auto 0 0 0;
    width: 100%;
    height: 60dvh;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    transition: height 0.25s ease;
  }

  .chat-panel[data-size="large"] {
    height: calc(100dvh - 3rem);
  }

  .chat-grabber {
    display: block;
    width: 100%;
    padding: 8px 0 2px;
    border: 0;
    background: none;
    touch-action: none;
    cursor: grab;
  }

  .chat-grabber::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    margin: 0 auto;
    border-radius: 3px;
    background: var(--tempo-border);
  }

  .chat-expand {
    display: inline-block;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel,
  .today-chevron {
    transition: none;
  }

  .chat-fab.is-working::after {
    animation: none;
    border-color: var(--tempo-coral);
  }
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tempo-border);
}

.chat-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.chat-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tempo-hero-bg);
  color: var(--tempo-hero-accent);
}

.chat-subtitle {
  margin: 0;
  color: var(--tempo-text-2);
  font-size: 0.85rem;
}

.chat-subtitle [data-when-working] {
  color: var(--tempo-accent);
  font-weight: 700;
}

.chat-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--tempo-fill);
  color: var(--tempo-text-2);
}

/* A column so a short conversation sits at the bottom, next to the message box. */
.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 1rem;
}

.chat-older {
  align-self: center;
  margin-bottom: 0.5rem;
}

.chat-list {
  margin: auto 0 0;
  padding: 0;
  list-style: none;
}

.chat-day {
  margin-top: 0.75rem;
  color: var(--tempo-text-2);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.chat-panel .chat-bubble {
  max-width: 85%;
  white-space: pre-line;
  border-radius: 18px 18px 18px 6px;
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
}

.chat-panel .chat-message.from-user .chat-bubble {
  border-radius: 18px 18px 6px 18px;
  border-color: var(--tempo-accent);
  background: var(--tempo-accent);
  color: var(--tempo-on-accent);
}

.chat-panel .chat-meta {
  display: block;
  margin-top: 0.2rem;
}

.chat-typing {
  margin-top: 0.75rem;
}

.chat-typing .chat-bubble {
  display: inline-flex;
  gap: 6px;
  padding: 0.9rem 1rem;
}

.chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tempo-text-2);
  animation: chat-dot 1.2s infinite;
}

.chat-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }

  40% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-dot {
    animation: none;
    opacity: 0.6;
  }
}

.chat-note,
.chat-empty {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.75rem;
  border-radius: 14px;
  background: var(--tempo-fill);
  color: var(--tempo-text-2);
  font-size: 0.85rem;
}

.chat-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 1rem;
  scrollbar-width: none;
}

.chat-chip {
  flex: none;
  min-height: 40px;
  padding: 0 0.9rem;
  border: 1px solid var(--tempo-border);
  border-radius: 999px;
  background: var(--tempo-surface);
  color: var(--tempo-text);
  font-size: 0.9rem;
  font-weight: 600;
}

.chat-chip:hover {
  border-color: var(--tempo-accent);
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--tempo-border);
  background: var(--tempo-surface);
}

.chat-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 22px;
  background: var(--tempo-fill);
  color: var(--tempo-text);
  resize: none;
}

.chat-send {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--tempo-accent);
  color: var(--tempo-on-accent);
}

.chat-send:disabled {
  opacity: 0.5;
}

.chat-error {
  margin: 0;
  padding: 0 1rem 0.75rem;
  color: var(--bs-danger-text-emphasis);
  font-size: 0.85rem;
}

.chat-meta {
  color: var(--tempo-text-2);
  margin-bottom: 0.2rem;
}

.chat-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 16px;
  background: var(--tempo-fill);
}

.chat-message.from-user {
  text-align: right;
}

.chat-message.from-user .chat-bubble {
  text-align: left;
  background: var(--tempo-accent-soft);
}

.phase-list li.is-current {
  background: var(--tempo-accent-soft);
}

/* The coach is not a doctor: before the AI consent and under every message box. */
.medical-notice {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: var(--tempo-fill);
  color: var(--tempo-text-2);
  font-size: 0.9rem;
}

.chat-disclaimer {
  margin: 0.35rem 0 0;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  color: var(--tempo-text-2);
  text-align: center;
}

/* Morning check-in proposal on the dashboard. */
.check-in {
  border-color: var(--tempo-coral);
  background: var(--tempo-accent-soft);
}

/* --- Landing page (templates/core/landing.html) ----------------------------------- */
.landing-main {
  padding: 0;
}

.landing-inner {
  max-width: 1180px;
}

.landing-hero {
  padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(2.5rem, 6vw, 4.5rem);
  background:
    radial-gradient(60rem 30rem at 85% -10%, var(--tempo-accent-soft), transparent 70%),
    var(--tempo-bg);
}

.landing-hero-grid {
  display: grid;
  gap: 3rem;
  align-items: center;
}

@media (min-width: 992px) {
  .landing-hero-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }
}

.landing-title {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 1rem;
  text-wrap: balance;
}

.landing-lead {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--tempo-text-2);
  max-width: 36rem;
}

.landing-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.btn-lg {
  min-height: 52px;
  --bs-btn-padding-x: 1.6rem;
  --bs-btn-font-size: 1.05rem;
}

.landing-note {
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--tempo-text-2);
}

/* The "phone" with sample content. */
.landing-phone {
  justify-self: center;
  width: min(100%, 340px);
  padding: 12px;
  border-radius: 44px;
  background: var(--tempo-hero-bg);
  box-shadow: 0 30px 60px -25px rgba(31, 27, 25, 0.45);
}

.landing-phone-screen {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 34px;
  background: var(--tempo-bg);
}

.landing-phone .small-label {
  font-family: var(--tempo-font-display);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tempo-text-2);
}

.landing-phone-hero {
  padding: 1rem 1.1rem;
  border-radius: 22px;
  background: var(--tempo-hero-bg);
  color: var(--tempo-hero-text);
}

.landing-phone-hero .small-label {
  color: var(--tempo-hero-muted);
}

.landing-phone-hero .session {
  font-family: var(--tempo-font-display);
  font-weight: 900;
  font-size: 1.35rem;
  color: var(--tempo-hero-accent);
  margin: 0.15rem 0 0.35rem;
}

.landing-phone-hero p,
.landing-phone-card p {
  margin: 0;
  font-size: 0.9rem;
}

.landing-phone-hero p {
  color: var(--tempo-hero-muted);
}

.landing-phone-card {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
}

.landing-phone .coach-bubble {
  background: var(--tempo-accent-soft);
  border-color: transparent;
}

.landing-section {
  padding: clamp(2.75rem, 7vw, 5rem) 0;
}

.landing-alt {
  background: var(--tempo-fill);
}

.landing-section-head {
  max-width: 40rem;
  margin-bottom: 2rem;
}

.landing-section h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  font-weight: 900;
  margin: 0.35rem 0 0.75rem;
}

.landing-features {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.landing-feature h3 {
  font-size: 1.2rem;
  margin: 0.9rem 0 0.4rem;
}

.landing-feature p {
  margin: 0;
  color: var(--tempo-text-2);
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
}

.landing-steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 0;
  margin: 0;
}

.landing-steps li {
  counter-increment: step;
}

.landing-steps li::before {
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--tempo-accent);
  color: var(--tempo-on-accent);
  font-family: var(--tempo-font-display);
  font-weight: 900;
}

.landing-steps h3 {
  font-size: 1.2rem;
  margin: 0.9rem 0 0.4rem;
}

.landing-steps p,
.landing-trust p {
  color: var(--tempo-text-2);
  margin: 0;
}

.landing-trust {
  display: grid;
  gap: 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.landing-faq > * {
  max-width: 760px;
}

.landing-faq details {
  border-bottom: 1px solid var(--tempo-border);
  padding: 1rem 0;
}

.landing-faq summary {
  font-family: var(--tempo-font-display);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.landing-faq details p {
  margin: 0.25rem 0 0;
  color: var(--tempo-text-2);
}

.landing-final h2 {
  color: var(--tempo-hero-text);
  margin-top: 0;
}

.landing-final .landing-ctas {
  margin-top: 0;
}

/* What Tempo does, in three short points under the hero's lead. */
.landing-points {
  list-style: none;
  display: grid;
  gap: 0.5rem;
  padding: 0;
  margin: 1.25rem 0 0;
}

.landing-points li {
  position: relative;
  padding-left: 2rem;
  font-family: var(--tempo-font-display);
  font-weight: 800;
  font-size: 1.05rem;
}

/* A white check on a coral dot. */
.landing-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E")
      center / 0.8rem no-repeat,
    var(--tempo-coral);
}

/* Early-access form (waitlist/_form.html): email and button side by side, stacked on a phone. */
.waitlist-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
  max-width: 34rem;
}

.waitlist-form .form-control {
  flex: 1 1 15rem;
  min-height: 52px;
}

.waitlist-form .btn {
  flex: 0 0 auto;
}

@media (max-width: 575.98px) {
  .waitlist-form .btn {
    flex: 1 1 100%;
  }
}

/* Honeypot: off-screen for people, still filled in by naive bots. */
.waitlist-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.waitlist-form .waitlist-error {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.95rem;
  color: var(--tempo-accent);
}

.landing-final .waitlist-form {
  margin-top: 0;
  flex: 1 1 22rem;
}

.landing-final .waitlist-form .waitlist-error {
  color: var(--tempo-hero-accent);
}

.waitlist-thanks {
  max-width: 34rem;
  margin: clamp(2rem, 8vw, 5rem) auto;
  text-align: center;
}

.waitlist-thanks h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 900;
  margin: 1rem 0 0.5rem;
}

.waitlist-thanks p {
  color: var(--tempo-text-2);
  margin-bottom: 1.5rem;
}

/* Last night's numbers at the top of the sample phone. */
.landing-phone-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.landing-phone-metrics > div {
  padding: 0.6rem 0.7rem;
  border-radius: 16px;
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
}

.landing-phone-metrics .small-label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.landing-phone-metrics strong {
  font-family: var(--tempo-font-display);
  font-weight: 900;
  font-size: 1.05rem;
}

.landing-phone-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.landing-phone-actions span {
  flex: 1;
  padding: 0.45rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--tempo-accent);
  color: var(--tempo-accent);
  font-family: var(--tempo-font-display);
  font-weight: 800;
  font-size: 0.8rem;
  text-align: center;
}

.landing-phone-actions .is-primary {
  background: var(--tempo-accent);
  color: var(--tempo-on-accent);
}

/* "Everything your watch measures": metric and what the coach does with it. */
.landing-metrics {
  list-style: none;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  padding: 0;
  margin: 0;
}

.landing-metrics li {
  padding: 1.1rem 1.25rem;
  border-radius: var(--tempo-radius);
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
  border-top: 4px solid var(--tempo-coral);
}

.landing-metrics h3 {
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
}

.landing-metrics p,
.landing-section-head p {
  margin: 0;
  color: var(--tempo-text-2);
}

.landing-section-head.landing-problem {
  margin-bottom: 0;
}

.landing-problem h2 {
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
}

.landing-problem p {
  font-size: clamp(1.05rem, 2vw, 1.2rem);
}

/* Comparison table; scrolls sideways inside its box on narrow phones. */
.landing-compare-wrap {
  overflow-x: auto;
}

.landing-compare {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
}

.landing-compare th,
.landing-compare td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--tempo-border);
  text-align: center;
}

.landing-compare thead th {
  font-family: var(--tempo-font-display);
  font-weight: 800;
}

.landing-compare tbody th {
  text-align: left;
  font-weight: 700;
}

.landing-compare td {
  color: var(--tempo-text-2);
}

.landing-compare .is-tempo {
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
  font-family: var(--tempo-font-display);
  font-weight: 800;
}

.landing-compare thead .is-tempo {
  border-radius: 16px 16px 0 0;
}

.landing-compare tbody tr:last-child .is-tempo {
  border-radius: 0 0 16px 16px;
}

.landing-footer {
  border-top: 1px solid var(--tempo-border);
  padding: 1.75rem 0 2.5rem;
}

.landing-footer .landing-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.landing-footer nav {
  display: flex;
  gap: 1.25rem;
}

/* Sets editor (workouts/sets.html): one compact row per set, also on a phone. */
.set-row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) 1.75rem;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.set-row .form-control {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.set-row .form-control::-webkit-outer-spin-button,
.set-row .form-control::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.set-row .btn {
  padding-left: 0;
  padding-right: 0;
}

/* The set number is a native <select> in disguise: tapping it opens the type picker. */
.set-badge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  margin: 0;
  border-radius: 12px;
  background: var(--tempo-fill);
  font-family: var(--tempo-font-display);
  font-weight: 800;
  cursor: pointer;
}

.set-badge:focus-within {
  outline: 2px solid var(--tempo-accent);
  outline-offset: 1px;
}

.set-badge[data-type="warmup"],
.set-badge[data-type="drop"],
.set-badge[data-type="failure"] {
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
}

main form .set-badge select {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.set-head {
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.sets-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Exercise name box: the athlete's own exercise names as suggestions. */
.exercise-name {
  position: relative;
  min-width: 0;
}

.exercise-name input {
  scroll-margin-top: 84px;
}

.exercise-suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 16rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--tempo-surface);
  border: 1px solid var(--tempo-border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 15%);
}

/* On a phone the list pushes the page down instead of floating, so it can scroll above the keyboard. */
@media (max-width: 767.98px) {
  .exercise-suggestions {
    position: static;
    margin-top: 4px;
    box-shadow: none;
  }
}

.exercise-suggestions [role="option"] {
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}

.exercise-suggestions [role="option"]:hover,
.exercise-suggestions [role="option"][aria-selected="true"] {
  background: var(--tempo-accent-soft);
  color: var(--tempo-accent);
}

/* Privacy policy (core/privacy.html): a readable column of legal text. */
.legal {
  max-width: 46rem;
}

.legal h2 {
  margin-top: 2rem;
}

.legal h3 {
  font-size: 1.05rem;
  margin-top: 1.25rem;
}

.legal p,
.legal li {
  color: var(--tempo-text-2);
}

.legal strong {
  color: var(--bs-body-color);
}

/* Link under the sign-in / sign-up card. */
.entrance-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
}
