/* ===========================================================================
   View-specific layout. Everything generic lives in components.css; what is
   here exists because one screen has a genuinely bespoke geometry.
   =========================================================================== */

/* ==========================================================================
   AUTH — login, register
   ========================================================================== */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background:
    radial-gradient(90% 60% at 12% -10%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 62%),
    radial-gradient(70% 55% at 100% 0%, color-mix(in srgb, var(--s-1) 16%, transparent), transparent 60%),
    var(--canvas);
}
.auth__panel {
  display: grid;
  align-content: center;
  justify-items: stretch;
  gap: var(--sp-5);
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 3rem) var(--gutter);
  padding-top: max(2rem, env(safe-area-inset-top));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}
.auth__brand { display: flex; align-items: center; gap: 0.65rem; }
.auth__brand svg { width: 38px; height: 38px; color: var(--brand); }
.auth__brand b { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.025em; }
.auth__lede { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.55; }
.auth__aside { display: none; }

@media (min-width: 960px) {
  .auth { grid-template-columns: minmax(24rem, 34rem) 1fr; }
  .auth__panel { max-width: 30rem; padding-inline: clamp(2rem, 5vw, 4rem); }
  .auth__aside {
    display: grid;
    align-content: center;
    gap: var(--sp-5);
    padding: var(--sp-7);
    border-left: 1px solid var(--line);
  }
  .auth__claim {
    font-size: clamp(1.6rem, 2.4vw, 2.4rem);
    font-weight: 660;
    line-height: 1.16;
    letter-spacing: -0.03em;
    max-width: 18ch;
  }
  .auth__claim em { color: var(--brand-ink); font-style: normal; }
  .auth__points { display: grid; gap: var(--sp-3); max-width: 38ch; }
  .auth__point { display: flex; gap: 0.7rem; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.5; }
  .auth__point svg { flex: none; width: 18px; height: 18px; color: var(--brand-ink); margin-top: 2px; }
}
.auth__legal { font-size: var(--fs-micro); color: var(--ink-3); text-align: center; }
.auth__legal a { text-decoration: underline; text-underline-offset: 2px; }

/* ==========================================================================
   PLAN — the calendar is the page
   ========================================================================== */
.plan { display: grid; gap: var(--sp-3); }

.calbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}
.calbar__month {
  font-size: var(--fs-h2);
  font-weight: 660;
  letter-spacing: -0.02em;
  min-width: 9rem;
  white-space: nowrap;
  flex: 0 0 auto;
}
@media (max-width: 1099px) {
  /* flex-basis pushes it onto its own line; max-content stops it stretching
     into a full-width banner once it gets there. */
  .calbar__phase { flex-basis: 100%; max-width: max-content; order: 10; }
}
@media (max-width: 767px) {
  .calbar { gap: var(--sp-2); }
  .calbar > .row { flex-wrap: wrap; min-width: 0; }
  .calbar__month { font-size: 1.05rem; min-width: 0; flex: 1 1 auto; }
  .calbar .segmented { flex: 1; }
  .calbar .segmented__btn { flex: 1; justify-content: center; }
}

.calbar__phase {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--c-macro) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c-macro) 38%, transparent);
  color: var(--ink);
  font-size: var(--fs-micro);
  font-weight: 640;
}

/* --- Desktop / tablet month matrix ----------------------------------------
   The grid sizes itself against its OWN width, not the viewport: the same
   calendar sits behind a 264px sidebar, a 68px rail or nothing at all, so a
   viewport breakpoint would have it guess. Container queries let it measure.

   The container is the WRAPPER, not .cal. A container query can never style
   the element that declares the container, so putting it on .cal would have
   made every step below silently dead code.                                   */
.calwrap {
  container-type: inline-size;
  container-name: cal;
}
.cal {
  display: none;
  --day-h: 124px;
  --wsum-w: 96px;
  --cal-gap: 7px;
  --day-pad: 9px;
}
.cal__head,
.cal__row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) var(--wsum-w);
  gap: var(--cal-gap);
}
.cal__head { margin-bottom: 9px; }
.cal__dow {
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-3);
  padding-left: calc(var(--day-pad) + 2px);
}
.cal__dow.is-weekend { color: color-mix(in srgb, var(--ink-3) 82%, var(--ink)); }
.cal__dow--wk { padding-left: 0; text-align: center; }
.cal__rows { display: grid; gap: var(--cal-gap); }

/* --- A day ---------------------------------------------------------------- */
.day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: var(--day-h);
  padding: var(--day-pad) var(--day-pad) calc(var(--day-pad) + 6px);
  border-radius: var(--r-md);
  /* A hairline of light across the top edge, the way every other raised
     surface in the app reads depth. */
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--s2) 60%, transparent) 0, transparent 44%),
    var(--s1);
  border: 1px solid var(--line-faint);
  text-align: left;
  min-width: 0;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.day.is-weekend {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--s2) 40%, transparent) 0, transparent 44%),
    color-mix(in srgb, var(--s1) 88%, var(--canvas));
}
.day.is-outside { background: none; border-color: transparent; opacity: 0.42; }
.day.is-today {
  border-color: color-mix(in srgb, var(--brand) 42%, transparent);
  background:
    linear-gradient(180deg, var(--brand-wash) 0, transparent 46%),
    var(--s1);
}
.day.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), var(--e-2);
}
.day.is-blocked {
  background:
    repeating-linear-gradient(135deg,
      transparent 0 8px,
      color-mix(in srgb, var(--c-blocked) 9%, transparent) 8px 16px),
    var(--s1);
}
@media (hover: hover) and (pointer: fine) {
  .day:hover {
    border-color: var(--line-strong);
    box-shadow: var(--e-2);
    transform: translateY(-1px);
  }
  .day.is-empty:hover .day__add { opacity: 1; }
}
.day:focus-visible { outline: none; box-shadow: var(--e-focus); }

.day__top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.day__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  height: 23px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  font-size: 0.83rem;
  font-weight: 680;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.day.is-outside .day__num { color: var(--ink-3); font-weight: 600; }
.day.is-today .day__num {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.day__mon {
  font-size: 9.5px; font-weight: 750;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3);
}
.day__load {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: var(--r-pill);
  background: var(--sunken);
  border: 1px solid var(--line-faint);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-2);
}
.day__loaddot {
  width: 5px; height: 5px; flex: none;
  border-radius: var(--r-pill);
  background: var(--s-2);
}
.day__items { display: grid; gap: 5px; min-width: 0; align-content: start; }

/* The day's load as a share of the busiest day on screen. Seven of these in a
   row are what make a month legible as a shape rather than a table. */
.day__pulse {
  position: absolute;
  left: var(--day-pad); right: var(--day-pad); bottom: 7px;
  height: 3px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ink-3) 18%, transparent);
  overflow: hidden;
}
.day__pulse i {
  display: block; height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--s-2) 62%, transparent), var(--s-2));
}
.day.is-today .day__pulse i { background: linear-gradient(90deg, var(--brand-dim), var(--brand)); }

.day__add {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  color: var(--ink-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease);
}

/* --- Entry chips ----------------------------------------------------------
   One grammar, two states. A dashed spine and a hollow glyph mean "planned";
   a solid spine and a filled glyph mean "this happened". Colour says which
   discipline, the glyph repeats it for anyone who cannot use the colour.      */
.ev,
.act {
  --entry: var(--c-other);
  position: relative;
  display: grid;
  gap: 4px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--r-sm);
  min-width: 0;
}
.ev::before,
.act::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: var(--r-pill);
  background: var(--entry);
}
.ev {
  background: color-mix(in srgb, var(--entry) 8%, var(--sunken));
}
.ev::before {
  /* Dashed: this is a plan, not something that happened. */
  background: repeating-linear-gradient(180deg, var(--entry) 0 4px, transparent 4px 7.5px);
}
.act {
  background: color-mix(in srgb, var(--entry) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--entry) 17%, transparent);
}
.act.is-ignored { opacity: 0.42; }

/* The glyph rides INSIDE the title box, as inline content on the first line.
   Sitting beside it in a flex row it stole 19px from every line, which at a
   laptop column width is the difference between "Endurance spin" and
   "Endura…". Here the second line gets the chip's full width back. */
.ev__glyph,
.act__glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  margin-right: 4px;
  vertical-align: -3px;
  border-radius: 5px;
  color: var(--entry);
}
.ev__glyph { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--entry) 36%, transparent); }
.act__glyph { background: color-mix(in srgb, var(--entry) 22%, transparent); }
.ev__glyph svg,
.act__glyph svg { width: 10.5px; height: 10.5px; stroke-width: 2; }

/* Two lines, then an ellipsis. A calendar chip that truncates "Threshold 2×20"
   to "Thresh…" has told the athlete nothing; the extra line costs 14px and
   buys back the whole session name. */
.ev__title,
.act__title {
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.32;
  color: var(--ink);
  overflow-wrap: break-word;
  hyphens: auto;
}
.ev__title { font-weight: 640; }
.act__title { font-weight: 600; }

.ev__meta,
.act__meta {
  display: block;
  font-size: 9.5px;
  line-height: 1.3;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev__wkoflag {
  display: inline-block;
  margin-right: 2px;
  font-size: 10px;
  vertical-align: -1px;
  color: color-mix(in srgb, var(--brand) 78%, var(--ink-3));
}

.ev--goal    { --entry: var(--c-goal);    background: color-mix(in srgb, var(--c-goal) 15%, transparent); }
.ev--blocked { --entry: var(--c-blocked); background: color-mix(in srgb, var(--c-blocked) 12%, transparent); }
.ev--goal::before,
.ev--blocked::before { background: var(--entry); }

.ev--macro {
  --entry: var(--c-macro);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 12px;
  background: color-mix(in srgb, var(--c-macro) 15%, transparent);
}
.ev--macro::before { background: var(--c-macro); }
.ev--macro .ev__glyph { box-shadow: none; }
.ev--macro .ev__title { -webkit-line-clamp: 1; line-clamp: 1; }

/* Multi-day entries: stated once, then carried as a band. */
.ev--cont { padding: 5px 8px 6px; gap: 3px; }
.ev--cont::before { display: none; }
.ev__ribbon {
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--entry);
  opacity: 0.7;
}
.ev--spanstart .ev__ribbon { margin-bottom: 1px; opacity: 0.85; }
.ev__ribbon.is-end { background: linear-gradient(90deg, var(--entry), color-mix(in srgb, var(--entry) 25%, transparent)); }
.ev__conttitle { font-size: 9.5px; font-weight: 600; color: var(--ink-3); }

/* --- The week rail --------------------------------------------------------
   Seven bars, then the totals. The bars are the reason this column exists: a
   single load figure cannot say whether a week was one huge day or six even
   ones, and that difference is the whole of a training week.                  */
.wsum {
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 10px 11px 12px;
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--s2) 55%, transparent) 0, transparent 58%),
    var(--sunken);
  border: 1px solid var(--line-faint);
  min-width: 0;
}
.wsum__top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.wsum__wk {
  font-size: 9.5px; font-weight: 750;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3);
}
.wsum__tag {
  margin-left: auto;
  font-size: 8.5px; font-weight: 750;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  white-space: nowrap;
}
.wsum__figure { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.wsum__big {
  font-size: 1.32rem; font-weight: 700; line-height: 1;
  letter-spacing: -0.028em;
  font-variant-numeric: tabular-nums;
}
.wsum__unit {
  font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}

.wsum__bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  height: 30px;
  align-items: end;
}
.wsum__bar {
  display: flex;
  align-items: flex-end;
  height: 100%;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink-3) 8%, transparent);
  overflow: hidden;
}
.wsum__bar i {
  display: block; width: 100%;
  border-radius: 2px;
  background: color-mix(in srgb, var(--s-2) 78%, transparent);
}
.wsum__bar.is-today i { background: var(--brand); }
/* Planned but not yet ridden: the slot is claimed, the load is not in yet. */
.wsum__bar.is-planned {
  background: repeating-linear-gradient(135deg,
    transparent 0 2px, color-mix(in srgb, var(--ink-3) 26%, transparent) 2px 4px);
}

.wsum__foot {
  font-size: 9.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wsum__meter { height: 4px; }

/* --- Legend --------------------------------------------------------------- */
.callegend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line-faint);
}
.callegend__keys { display: flex; flex-wrap: wrap; gap: 0.4rem 0.85rem; }
.callegend .legend__item { --entry: var(--c-other); font-weight: 620; }
.legend__glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px; height: 17px;
  flex: none;
  border-radius: 6px;
  color: var(--entry);
  background: color-mix(in srgb, var(--entry) 18%, transparent);
}
.legend__glyph svg { width: 11px; height: 11px; stroke-width: 2; }
.callegend__note {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--fs-micro); color: var(--ink-3);
}
.callegend__swatch { width: 13px; height: 3px; border-radius: 2px; flex: none; }
.callegend__swatch--plan { background: repeating-linear-gradient(90deg, var(--ink-3) 0 3.5px, transparent 3.5px 6px); }
.callegend__swatch--done { background: var(--ink-3); margin-left: 0.4rem; }

/* --- Responsive steps, measured against the calendar's own width ----------- */
/* Narrow columns drop what the glyph already says. A chip reading
   "1h 35m · Bike" next to a bicycle is spending its only line on a repeat. */
@container cal (max-width: 979px) {
  .ev, .act { padding: 5px 6px 5px 10px; }
  .ev::before, .act::before { left: 4px; }
  .ev__glyph, .act__glyph { width: 13px; height: 13px; margin-right: 3px; border-radius: 4px; vertical-align: -2px; }
  .ev__glyph svg, .act__glyph svg { width: 9.5px; height: 9.5px; }
  .ev__title, .act__title { font-size: 11px; -webkit-line-clamp: 3; line-clamp: 3; }
  .ev__opt { display: none; }
}
@container cal (max-width: 779px) {
  .cal { --day-pad: 7px; }
  .ev, .act { padding: 5px 5px 5px 9px; }
  .ev__title, .act__title { font-size: 10.5px; }
  .wsum { padding: 8px 8px 10px; }
  .wsum__big { font-size: 1.15rem; }
}
@container cal (min-width: 620px) {
  .cal { --day-h: 132px; --wsum-w: 104px; }
}
@container cal (min-width: 780px) {
  .cal { --day-h: 148px; --wsum-w: 118px; --cal-gap: 8px; --day-pad: 10px; }
}

@container cal (min-width: 980px) {
  .cal { --day-h: 168px; --wsum-w: 138px; --cal-gap: 9px; --day-pad: 11px; }
  .ev, .act { padding: 7px 9px 7px 13px; gap: 5px; }
  .ev__title, .act__title { font-size: 12px; }
  .ev__meta, .act__meta { font-size: 10px; }
  .wsum { gap: 8px; padding: 12px 13px 14px; }
  .wsum__bars { height: 34px; }
}
@container cal (min-width: 1180px) {
  .cal { --day-h: 182px; --wsum-w: 152px; --cal-gap: 10px; }
  .ev__title, .act__title { font-size: 12.5px; }
  .wsum__big { font-size: 1.45rem; }
  .wsum__bars { height: 38px; }
}

/* Week view: one row, so it may take more height — but not so much that a
   quiet week becomes a screen of empty boxes. */
.cal--week .day { min-height: clamp(220px, 32vh, 340px); }
.cal--week .ev__title,
.cal--week .act__title { font-size: 13px; }

@media (min-width: 768px) {
  .cal { display: block; }
  .calmob { display: none; }
}

/* --- Mobile tap matrix ---------------------------------------------------- */
.calmob { display: grid; gap: var(--sp-3); }
.calmob__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calmob__dow {
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); text-align: center;
  padding-bottom: 2px;
}
.mday {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 3px;
  padding: 6px 2px 5px;
  min-height: 52px;
  border-radius: var(--r-sm);
  background: var(--s1);
  border: 1px solid var(--line-faint);
  touch-action: manipulation;
}
.mday.is-outside { background: transparent; border-color: transparent; opacity: 0.4; }
.mday.is-today { border-color: color-mix(in srgb, var(--brand) 55%, transparent); background: var(--brand-wash); }
.mday.is-selected { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.mday.is-blocked { background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c-blocked) 13%, transparent) 6px 12px), var(--s1); }
.mday { min-width: 0; }
.mday__num { font-size: 12px; font-weight: 660; font-variant-numeric: tabular-nums; line-height: 1; }
.mday__dots { display: flex; gap: 2px; min-height: 6px; align-items: center; }
.mday__dot { width: 5px; height: 5px; border-radius: var(--r-pill); background: var(--c-other); }
.mday__bar { width: 100%; height: 3px; border-radius: 2px; background: var(--s-1); opacity: 0.85; }

.mweek {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--r-md);
  background: var(--sunken);
  border: 1px solid var(--line-faint);
}
.mweek__cell { display: grid; gap: 1px; }
.mweek__k { font-size: 9px; font-weight: 680; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.mweek__v { font-size: 0.95rem; font-weight: 660; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* Declared last on purpose — see the note above. */
@media (min-width: 768px) {
  .calmob { display: none; }
}

/* --- Day inspector -------------------------------------------------------- */
.inspect { display: grid; gap: var(--sp-3); }
.inspect__date { font-size: var(--fs-h3); font-weight: 650; }
.inspect__entry {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line-faint);
}
.inspect__entryhead { display: flex; align-items: flex-start; gap: var(--sp-2); }

/* The build strip: the calendar reporting on work the calendar itself started. */
.buildstrip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  background: var(--s2);
  border: 1px solid var(--line-faint);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.buildstrip .meter { flex: 1; max-width: 12rem; }

/* ==========================================================================
   COACH — the home screen
   Check-ins (one per activity) and open conversations. The activity a
   check-in is about sits at the top of its stream as a hero card, tinted with
   that sport's calendar colour, so the athlete never wonders which ride the
   coach is asking about.
   ========================================================================== */
.coach {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 1200px) {
  .coach { grid-template-columns: 272px minmax(0, 1fr) 296px; }
  .coach__threads { position: sticky; top: calc(var(--header-h) + var(--sp-4));
                    max-height: calc(100dvh - var(--header-h) - 2 * var(--sp-4)); overflow: auto; }
  .coach__aside { position: sticky; top: calc(var(--header-h) + var(--sp-4)); display: grid; gap: var(--grid-gap); }
  .switcher, .waiting { display: none !important; }
}
@media (max-width: 1199px) {
  .coach__threads, .coach__aside { display: none; }
}

.coach__main { display: flex; flex-direction: column; min-width: 0; }

.coach__stream {
  display: grid;
  gap: var(--sp-4);
  align-content: start;
  min-width: 0;
}
/* Scrolling to the newest message must stop above the sticky composer, not under it. */
.coach__stream > * { scroll-margin-bottom: 13rem; }

/* Without a thread list and side panel to fill the height, the composer would
   sit directly under a two-line conversation in the middle of the screen. It
   belongs in the thumb zone, so the stream takes the slack. */
@media (max-width: 1199px) {
  .coach__main {
    min-height: calc(100dvh - var(--header-h) - var(--tabbar-h) - 2 * var(--gutter));
  }
  .coach__stream { flex: 1; }
}

/* --- Thread list ---------------------------------------------------------- */
.threads { display: grid; gap: 2px; padding: var(--sp-3); }
.threads__head { display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-1) var(--sp-2); }
.threads__label {
  display: flex; align-items: center; gap: var(--sp-2);
  margin: var(--sp-3) var(--sp-2) var(--sp-1);
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--ink-3);
}
.threads__count {
  padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--brand-wash); color: var(--brand-ink);
  letter-spacing: 0; text-transform: none; font-weight: 680;
}
.threads__empty { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.5; padding: 0 var(--sp-2) var(--sp-2); }
.threads__foot {
  display: flex; gap: var(--sp-1); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-top: 1px solid var(--line-faint);
}
.threads--sheet { padding: 0; }

.threadlist { display: grid; gap: 2px; }
.threadrow {
  --sport: var(--brand);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--r-md);
  text-align: left;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  position: relative;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.threadrow[aria-current="true"] {
  background: color-mix(in srgb, var(--sport) 13%, var(--s2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sport) 30%, transparent);
}
.threadrow:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { .threadrow:hover { background: var(--s2); } }
.threadrow__glyph {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--sport);
  background: color-mix(in srgb, var(--sport) 16%, transparent);
}
.threadrow__glyph svg { width: 17px; height: 17px; }
.threadrow__glyph--chat { color: var(--brand-ink); background: var(--brand-wash); }
.threadrow__body { display: grid; gap: 1px; min-width: 0; }
.threadrow__title { font-size: var(--fs-xs); font-weight: 640; line-height: 1.3; }
.threadrow__meta { font-size: 11px; color: var(--ink-3); }
.threadrow__dot {
  width: 9px; height: 9px; border-radius: var(--r-pill);
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-wash);
  animation: pulse 1.8s var(--ease) infinite;
}
.threadrow__state { display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; }
.threadrow__state svg { width: 15px; height: 15px; }
.threadrow__state--ok { color: var(--ok); }
.threadrow__state--wait {
  padding: 2px 8px; border-radius: var(--r-pill);
  color: var(--on-brand); background: var(--brand);
}

/* --- Phone / tablet thread switcher ---------------------------------------- */
.switcher { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.switcher__pick {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-lg);
  background: var(--s1);
  border: 1px solid var(--line);
  text-align: left;
  min-height: 52px;
}
.switcher__pick > svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.switcher__icon {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-wash); color: var(--brand-ink);
}
.switcher__icon svg { width: 17px; height: 17px; }
.switcher__text { display: grid; min-width: 0; flex: 1; }
.switcher__kind { font-size: 10px; font-weight: 700; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--ink-3); }
.switcher__title { font-size: var(--fs-sm); font-weight: 640; }
.switcher__badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 760;
}

.waiting {
  display: flex; gap: var(--sp-2);
  overflow-x: auto; scrollbar-width: none;
  margin: calc(-1 * var(--sp-1)) 0 var(--sp-3);
  padding-bottom: 2px;
}
.waiting::-webkit-scrollbar { display: none; }
.waiting__chip {
  --sport: var(--brand);
  flex: none; max-width: 15rem;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 640;
  background: color-mix(in srgb, var(--sport) 14%, var(--s1));
  border: 1px solid color-mix(in srgb, var(--sport) 34%, transparent);
  min-height: 40px;
}
.waiting__chip svg { width: 15px; height: 15px; color: var(--sport); flex: none; }
.waiting__dot { width: 7px; height: 7px; border-radius: var(--r-pill); background: var(--brand); flex: none; }

/* --- The activity hero on a check-in -------------------------------------- */
.ridecard {
  --sport: var(--brand);
  position: relative;
  overflow: hidden;
  display: grid;
  gap: var(--sp-3);
  padding: clamp(1rem, 2.6vw, 1.4rem);
  border-radius: var(--r-xl);
  background:
    radial-gradient(130% 120% at 100% 0%, color-mix(in srgb, var(--sport) 26%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--sport) 7%, var(--s1)), var(--s1));
  border: 1px solid color-mix(in srgb, var(--sport) 32%, var(--line));
  box-shadow: var(--e-2);
  animation: rise var(--t-slow) var(--ease-out) both;
}
.ridecard::after {
  /* a slow light sweep across the card as it arrives */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.07) 50%, transparent 62%);
  transform: translateX(-100%);
  animation: sweep 1.6s 0.25s var(--ease-out) both;
}
.ridecard--gone { background: var(--s1); border-color: var(--line); box-shadow: none; }
.ridecard--gone::after { display: none; }
.ridecard__head { display: flex; align-items: center; gap: var(--sp-3); }
.ridecard__glyph {
  width: 48px; height: 48px; border-radius: 15px; flex: none;
  display: grid; place-items: center;
  color: var(--on-brand);
  background: var(--sport);
  box-shadow: 0 10px 24px -10px var(--sport);
}
.ridecard__glyph svg { width: 24px; height: 24px; }
.ridecard__titles { flex: 1; min-width: 0; }
.ridecard__name { font-size: var(--fs-h2); font-weight: 720; letter-spacing: -0.025em; line-height: 1.15; overflow-wrap: anywhere; }
.ridecard__when { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 2px; }
.ridecard__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr));
  gap: var(--sp-2);
}
.ridecard__stat {
  display: grid; gap: 2px;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--canvas) 45%, transparent);
  border: 1px solid var(--line-faint);
  animation: rise var(--t-slow) var(--ease-out) both;
  animation-delay: calc(120ms + var(--i, 0) * 55ms);
}
.ridecard__k { font-size: 10px; font-weight: 700; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--ink-3); }
.ridecard__v { font-size: 1.12rem; font-weight: 720; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ridecard__status {
  display: flex; align-items: flex-start; gap: 0.45rem;
  font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-2);
}
.ridecard__status svg { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--brand-ink); }
.ridecard__status.is-saved svg { color: var(--ok); }
.ridecard__warn { display: flex; gap: 0.4rem; font-size: var(--fs-micro); color: var(--warn); }
.ridecard__warn svg { width: 14px; height: 14px; flex: none; }

/* --- Empty main conversation --------------------------------------------- */
.coachhero {
  position: relative;
  display: grid; justify-items: start; gap: var(--sp-2);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  border-radius: var(--r-xl);
  overflow: hidden;
  background:
    radial-gradient(90% 120% at 0% 0%, var(--brand-wash), transparent 60%),
    radial-gradient(80% 90% at 100% 100%, color-mix(in srgb, var(--s-1) 16%, transparent), transparent 60%),
    var(--s1);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  animation: rise var(--t-slow) var(--ease-out) both;
}
.coachhero__title { font-size: var(--fs-h1); font-weight: 740; letter-spacing: -0.035em; line-height: 1.05; max-width: 18ch; }
.coachhero__lede { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.6; max-width: 56ch; }
.coachhero__lede b { color: var(--brand-ink); font-weight: 680; }
.coachhero__orb { position: absolute; right: clamp(-2rem, -2vw, 0rem); top: 50%; width: 180px; height: 180px; transform: translateY(-50%); opacity: 0.8; pointer-events: none; }
.coachhero__orb span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--brand) 40%, transparent);
  animation: orb 5.5s var(--ease) infinite;
}
.coachhero__orb span:nth-child(2) { animation-delay: 1.8s; }
.coachhero__orb span:nth-child(3) { animation-delay: 3.6s; }
@media (max-width: 640px) { .coachhero__orb { opacity: 0.35; } }

/* --- Messages ------------------------------------------------------------ */
.msg {
  display: grid; gap: var(--sp-2); max-width: 100%;
  animation: rise var(--t-slow) var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}
.msg__meta {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  font-size: var(--fs-micro); color: var(--ink-3); font-weight: 620;
}
.msg__bubble {
  padding: 0.85rem 1rem;
  border-radius: var(--r-lg);
  background: var(--s1);
  border: 1px solid var(--line);
  min-width: 0;
}
.msg__text { white-space: pre-wrap; line-height: 1.55; overflow-wrap: anywhere; }
.msg--athlete { justify-items: end; }
.msg--athlete .msg__bubble {
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 20%, var(--s1)), var(--brand-wash));
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  border-bottom-right-radius: var(--r-xs);
  max-width: min(46rem, 88%);
}
.msg--coach .msg__bubble { border-bottom-left-radius: var(--r-xs); max-width: min(52rem, 100%); }
.msg--quick .msg__bubble { max-width: min(36rem, 100%); font-size: 1rem; }
.msg--coach.is-new .msg__bubble { box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent), 0 12px 32px -18px var(--brand-glow); }
.msg--failed .msg__bubble { border-color: color-mix(in srgb, var(--critical) 40%, transparent); background: var(--critical-wash); }
.msg__saved { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--ok); font-weight: 680; }
.msg__saved svg { width: 13px; height: 13px; }

.msg__avatar {
  width: 22px; height: 22px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: conic-gradient(from 210deg, var(--brand), var(--brand-dim), var(--brand));
  color: var(--on-brand);
}
.msg__avatar svg { width: 13px; height: 13px; }

.thinking { display: flex; align-items: center; gap: 0.55rem; color: var(--ink-2); font-size: var(--fs-sm); }
.thinking__dots { display: inline-flex; gap: 3px; }
.thinking__dots i {
  width: 6px; height: 6px; border-radius: var(--r-pill);
  background: var(--brand);
  animation: think 1.1s var(--ease) infinite;
}
.thinking__dots i:nth-child(2) { animation-delay: 0.14s; }
.thinking__dots i:nth-child(3) { animation-delay: 0.28s; }

/* --- Composer ------------------------------------------------------------ */
.composer {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
  margin-top: var(--sp-4);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--s1) 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--e-2);
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); box-shadow: var(--e-2), 0 0 0 4px var(--brand-wash); }
.composer--answer { border-color: color-mix(in srgb, var(--brand) 38%, var(--line-strong)); }
@media (min-width: 768px) { .composer { bottom: var(--sp-4); } }
.composer__row { display: flex; align-items: flex-end; gap: var(--sp-2); }
.composer__input {
  flex: 1;
  min-height: 44px;
  max-height: 40dvh;
  padding: 0.65rem 0.8rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--s2);
  resize: none;
  font-size: max(16px, 0.92rem);
  line-height: 1.45;
}
.composer__input:focus { border-color: var(--brand); outline: none; }
.composer__send { transition: transform var(--t-fast) var(--ease); }
.composer__send:active { transform: scale(0.92); }
.composer__chips { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.composer__chips::-webkit-scrollbar { display: none; }
.chip--quick { background: var(--brand-wash); border-color: color-mix(in srgb, var(--brand) 28%, transparent); }
.composer__context {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 0.4rem 0.6rem; border-radius: var(--r-sm);
  background: var(--s2); font-size: var(--fs-xs); color: var(--ink-2);
}
.composer__context span { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; }
.composer__context svg { width: 14px; height: 14px; flex: none; }
/* A phone swipes the chips; a desktop has the room to show them all, and a
   half-cut chip with no scrollbar reads as a bug rather than an affordance. */
@media (min-width: 768px) {
  .composer__chips { flex-wrap: wrap; overflow-x: visible; }
}

/* --- Aside cards ---------------------------------------------------------- */
.openq { display: grid; gap: var(--sp-2); padding: var(--sp-2) 0; }
.openq + .openq { border-top: 1px solid var(--line-faint); }
.openq__text { font-size: var(--fs-sm); line-height: 1.5; font-weight: 560; }

.biostate { display: grid; gap: 0.45rem; }
.biostate__row {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2);
  font-size: var(--fs-xs);
  padding: 0.3rem 0;
}
.biostate__row + .biostate__row { border-top: 1px solid var(--line-faint); }
.biostate__k { color: var(--ink-3); }
.biostate__v { font-weight: 640; font-variant-numeric: tabular-nums; text-align: right; }

@keyframes think { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes sweep { to { transform: translateX(100%); } }
@keyframes orb {
  0% { transform: scale(0.35); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* ==========================================================================
   RIDER DNA
   ========================================================================== */
.dna-metrics {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}
.dna-metric {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line-faint);
  text-align: left;
}
.dna-metric__evidence { font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.45; }
.dna-archetype {
  display: grid; gap: 0.2rem;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-wash), transparent 70%), var(--s2);
  border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line));
}
.dna-archetype__name {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700; letter-spacing: -0.03em; line-height: 1.05;
  text-transform: capitalize;
}

.ceiling {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line-faint);
}

.cp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}
@media (max-width: 540px) {
  .cp-grid {
    grid-template-columns: 1fr;
  }
}
.cp-battery {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line-faint);
  display: grid;
  gap: var(--sp-2);
}
.cp-battery__bar {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--sunken);
  overflow: hidden;
  position: relative;
}
.cp-battery__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ok), var(--brand));
  transition: width var(--t-slow) var(--ease-out);
}

/* ==========================================================================
   MEMORY — the bio-rule hub
   ========================================================================== */
.rule {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line-faint);
  border-left: 3px solid var(--ink-3);
}
.rule[data-status="active"]    { border-left-color: var(--ok); }
.rule[data-status="candidate"] { border-left-color: var(--warn); }
.rule[data-status="evolving"]  { border-left-color: var(--s-1); }
.rule[data-status="resolved"]  { border-left-color: var(--ink-3); opacity: 0.8; }
.rule__head { display: flex; align-items: flex-start; gap: var(--sp-2); }
.rule__key { font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3); }
.rule__directive { font-size: var(--fs-sm); line-height: 1.5; }
.rule__evidence { font-size: var(--fs-micro); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rule__actions { display: flex; gap: var(--sp-1); margin-left: auto; }

/* ==========================================================================
   AERO LAB — segments, route direction, CdA
   ========================================================================== */
.seg {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--s1);
  border: 1px solid var(--line);
}
.seg__head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.seg__name { font-size: var(--fs-body); font-weight: 640; line-height: 1.25; }
.seg__grid { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@container (min-width: 520px) { .seg__grid { grid-template-columns: 132px 1fr; align-items: center; } }
.seg__score {
  display: grid; justify-items: center; gap: 2px;
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--sunken);
}
.seg__scoreval { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }

.cda-result {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--s-1) 12%, transparent), transparent 65%), var(--s2);
  border: 1px solid var(--line);
}
.cda-result__value { font-size: clamp(2.2rem, 7vw, 3rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1; }

.dropzone {
  display: grid;
  place-items: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4);
  border-radius: var(--r-lg);
  border: 2px dashed var(--line-strong);
  background: var(--sunken);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.dropzone.is-over { border-color: var(--brand); background: var(--brand-wash); }
.dropzone svg { width: 30px; height: 30px; color: var(--ink-3); }

/* ==========================================================================
   SYNC
   ========================================================================== */
.syncstate {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--s2);
  border: 1px solid var(--line);
}
.syncstate__dot {
  width: 9px; height: 9px; border-radius: var(--r-pill);
  background: var(--ink-3); flex: none;
}
.syncstate__dot--live { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-wash); }
.syncstate__dot--busy { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-wash); animation: pulse 1.4s var(--ease) infinite; }
.syncstate__dot--off  { background: var(--critical); box-shadow: 0 0 0 4px var(--critical-wash); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ==========================================================================
   ONBOARDING
   ========================================================================== */
.onb {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: var(--gutter);
  padding-top: max(var(--gutter), env(safe-area-inset-top));
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  background:
    radial-gradient(80% 50% at 50% 0%, color-mix(in srgb, var(--brand) 11%, transparent), transparent 60%),
    var(--canvas);
}
.onb__card { width: min(38rem, 100%); }
.onb__steps { display: flex; gap: 4px; margin-bottom: var(--sp-4); }
.onb__step { flex: 1; height: 3px; border-radius: var(--r-pill); background: var(--sunken); }
.onb__step.is-done { background: var(--brand); }
.onb__step.is-now { background: var(--brand-dim); }

/* ==========================================================================
   LEGAL / CONSTRUCTION
   ========================================================================== */
.doc { max-width: 68ch; margin-inline: auto; }
.doc h2 { margin-top: var(--sp-5); }
.doc p, .doc li { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.65; }
.doc ul { list-style: disc; padding-left: 1.2rem; display: grid; gap: 0.3rem; }

.construction {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: var(--sp-4);
  padding: var(--gutter);
  background:
    radial-gradient(75% 50% at 50% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 62%),
    var(--canvas);
}
.construction__mark { width: 62px; height: 62px; color: var(--brand); display: block; }
.construction__mark svg { width: 100%; height: 100%; }
.construction h1 { font-size: var(--fs-display); letter-spacing: -0.035em; }
.construction p { color: var(--ink-2); max-width: 44ch; }

/* ==========================================================================
   PROMPT LAB
   ========================================================================== */
.prompt-lab {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.prompt-lab-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.prompt-lab-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--grid-gap);
}

@media (min-width: 992px) {
  .prompt-lab-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Dropdowns & Selects in Prompt Lab */
.prompt-lab select.select,
.prompt-lab .select {
  background-color: var(--s2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line-strong) !important;
  min-height: 38px;
  height: 38px;
  padding: 0.35rem 2rem 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.prompt-lab select.select option,
.prompt-lab .select option {
  background-color: #161b22 !important;
  color: #f0f6fc !important;
  padding: 8px 12px;
}

/* Diffchecker-Style Diff Container & Components */
.dc-diff {
  background: var(--canvas-deep, #0c1017);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 21px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.dc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--s1);
  border-bottom: 1px solid var(--line-strong);
}

.dc-toolbar__group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dc-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--s2);
  color: var(--ink-2);
  transition: all 0.15s ease;
}

.dc-pill-btn:hover {
  background: var(--s3);
  color: var(--ink);
}

.dc-pill-btn.is-active {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
  font-weight: 600;
}

.dc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--r-pill);
}

.dc-badge--del {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.dc-badge--add {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.dc-nav-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sunken);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
}

.dc-nav-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-weight: bold;
}

.dc-nav-btn:hover:not(:disabled) {
  background: var(--s2);
  color: var(--brand);
}

.dc-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Pane Headers (Side-by-Side) */
.dc-pane-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--s2);
  border-bottom: 1px solid var(--line-strong);
  font-size: 12px;
}

.dc-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
}

.dc-pane-header:first-child {
  border-right: 1px solid var(--line-strong);
}

.dc-pane-title {
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Synchronized Scroll Container */
.dc-scroll {
  max-height: 660px;
  overflow-y: auto;
  overflow-x: auto;
  background: var(--canvas-deep, #0c1017);
}

/* Split Diff Grid & Rows */
.dc-split-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 860px;
}

.dc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  transition: background 0.15s ease;
}

.dc-row--active {
  background: rgba(200, 250, 85, 0.12) !important;
  box-shadow: inset 0 0 0 1px var(--brand);
  animation: dc-pulse 1.2s ease-out;
}

@keyframes dc-pulse {
  0% { background: rgba(200, 250, 85, 0.25); }
  100% { background: rgba(200, 250, 85, 0.08); }
}

.dc-cell {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  border-left: 3px solid transparent;
}

.dc-cell--left {
  border-right: 1px solid var(--line-strong);
}

.dc-ln {
  width: 48px;
  flex: 0 0 48px;
  padding: 1px 8px;
  text-align: right;
  user-select: none;
  font-size: 11.5px;
  color: var(--ink-3);
  background: rgba(0, 0, 0, 0.15);
  border-right: 1px solid var(--line-faint);
}

.dc-code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1px 10px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink-2);
}

/* Diffchecker Specific Highlight Colors */
.dc-cell--del {
  background-color: rgba(239, 68, 68, 0.15);
  border-left-color: #ef4444;
}

.dc-cell--del .dc-ln {
  color: #f87171;
  background-color: rgba(239, 68, 68, 0.18);
  font-weight: 600;
}

.dc-cell--del .dc-code {
  color: #ffe4e6;
}

.dc-word--del {
  background-color: rgba(239, 68, 68, 0.42);
  color: #ffffff;
  border-radius: 2px;
  padding: 0 3px;
  font-weight: 600;
}

.dc-cell--add {
  background-color: rgba(16, 185, 129, 0.15);
  border-left-color: #10b981;
}

.dc-cell--add .dc-ln {
  color: #34d399;
  background-color: rgba(16, 185, 129, 0.18);
  font-weight: 600;
}

.dc-cell--add .dc-code {
  color: #ecfdf5;
}

.dc-word--add {
  background-color: rgba(16, 185, 129, 0.42);
  color: #ffffff;
  border-radius: 2px;
  padding: 0 3px;
  font-weight: 600;
}

.dc-cell--empty {
  background-color: rgba(0, 0, 0, 0.3);
  background-image: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255, 255, 255, 0.015) 8px, rgba(255, 255, 255, 0.015) 16px);
  border-left-color: transparent;
}

.dc-cell--empty .dc-ln {
  background: transparent;
  border-right-color: transparent;
}

/* Collapsed Hunk / Unchanged Banner */
.dc-hunk-banner {
  background: var(--s2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px 16px;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dc-hunk-banner:hover {
  background: var(--s3);
  color: var(--brand);
}

/* Unified Diff View */
.dc-uni-body {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.dc-uni-row {
  display: flex;
  align-items: flex-start;
  width: 100%;
  min-height: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  border-left: 3px solid transparent;
}

.dc-uni-row--del {
  background-color: rgba(239, 68, 68, 0.15);
  border-left-color: #ef4444;
}

.dc-uni-row--del .dc-ln {
  color: #f87171;
  background-color: rgba(239, 68, 68, 0.18);
  font-weight: 600;
}

.dc-uni-row--del .dc-code {
  color: #ffe4e6;
}

.dc-uni-row--add {
  background-color: rgba(16, 185, 129, 0.15);
  border-left-color: #10b981;
}

.dc-uni-row--add .dc-ln {
  color: #34d399;
  background-color: rgba(16, 185, 129, 0.18);
  font-weight: 600;
}

.dc-uni-row--add .dc-code {
  color: #ecfdf5;
}

.dc-uni-sign {
  width: 24px;
  flex: 0 0 24px;
  text-align: center;
  user-select: none;
  font-weight: bold;
}

.prompt-textarea {
  width: 100%;
  height: 200px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.82rem;
  line-height: 1.4;
  padding: var(--sp-3);
  background: var(--s2);
  color: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  resize: vertical;
}

.json-viewer {
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink-1);
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Feedback the athlete gave their coach about an activity, in the Plan day inspector. */
.feedbacknote {
  display: grid; gap: 0.3rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--r-md);
  background: var(--brand-wash);
  border: 1px solid color-mix(in srgb, var(--brand) 24%, transparent);
}
.feedbacknote__label {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: var(--fs-micro); font-weight: 700; color: var(--brand-ink);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
}
.feedbacknote__label svg { width: 13px; height: 13px; }
.feedbacknote__text { font-size: var(--fs-sm); line-height: 1.55; white-space: pre-line; }

/* --- Check-in lifecycle: close, skip, closed ------------------------------ */
.threads__closed > summary { cursor: pointer; list-style: none; }
.threads__closed > summary::-webkit-details-marker { display: none; }
.threads__closed > summary::after { content: "▾"; margin-left: auto; font-size: 10px; transition: transform var(--t-fast) var(--ease); }
.threads__closed:not([open]) > summary::after { transform: rotate(-90deg); }
.threads__count--dim { background: var(--s2); color: var(--ink-3); }
.threadrow.is-closed { opacity: 0.62; }
.threadrow.is-closed[aria-current="true"] { opacity: 1; }
.threadrow__state--close {
  padding: 2px 8px; border-radius: var(--r-pill);
  color: var(--ok); background: var(--ok-wash);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
}
.threadrow__state--dim { color: var(--ink-3); font-weight: 600; }

.ridecard__foot { display: flex; align-items: flex-start; gap: var(--sp-2); }
.ridecard__foot .ridecard__status { flex: 1; }
.ridecard__feedback {
  display: grid; gap: 3px;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ok) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 24%, transparent);
}
.ridecard__feedback p { font-size: var(--fs-sm); line-height: 1.5; white-space: pre-line; }
.ridecard.is-closed { box-shadow: none; }

.closecta {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 14%, var(--s1)), var(--s1) 70%);
  border: 1px solid color-mix(in srgb, var(--ok) 34%, var(--line));
  animation: rise var(--t-slow) var(--ease-out) both;
  animation-delay: 120ms;
}
.closecta__icon {
  width: 36px; height: 36px; border-radius: var(--r-pill); flex: none;
  display: grid; place-items: center;
  color: #fff; background: var(--ok);
  box-shadow: 0 0 0 6px var(--ok-wash);
}
.closecta__icon svg { width: 18px; height: 18px; }
.closecta__text { flex: 1; min-width: 12rem; }
.closecta__title { font-weight: 680; font-size: var(--fs-sm); }
.closecta__sub { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 1px; }


.composer--closed { grid-template-columns: 1fr auto; align-items: center; display: grid; }
.composer__closed { display: flex; align-items: center; gap: 0.45rem; font-size: var(--fs-sm); color: var(--ink-2); }
.composer__closed svg { width: 16px; height: 16px; color: var(--ok); }

.coach__main.is-closing { animation: fold-away 260ms var(--ease) forwards; }
@keyframes fold-away { to { opacity: 0; transform: translateY(-8px) scale(0.985); } }
.closecta__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
@media (max-width: 540px) { .closecta__actions { width: 100%; } .closecta__actions .btn { flex: 1; } }
