/* ==========================================================================
   JORIE DAILY — today-timeline.css · Living Today timeline (after Phase 36.1)
   Today page only. Every colour, radius, font and duration comes from the
   existing tokens (style.css · design-system.css), so light, dark and the
   Winter Arc season restyle it automatically. One spacing system:
     --tl-time   time column       --tl-rail  rail column (node centred on it)
     --tl-col    column gap        --tl-row   space between entries
     --tl-node   node size         --tl-top   node offset from the entry top
   ========================================================================== */

/* ---------- layout around it ------------------------------------------- */
.today-main { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
@media (min-width: 1024px) {
  .today-main { grid-column: span 7; align-self: start; }
}
.today-main > .workout-card { grid-column: auto; }
.tl-absorbed, .tl-card[hidden] { display: none !important; }

/* ---------- card --------------------------------------------------------- */
.tl-card {
  --tl-time: 60px;
  --tl-rail: 28px;
  --tl-col: 12px;
  --tl-row: 8px;
  --tl-node: 28px;
  --tl-top: 12px;
  --tl-surface: color-mix(in srgb, var(--surface-sunk) 55%, var(--surface));
  --tl-line: var(--line-2);
  --tl-line-strong: rgb(var(--burgundy-rgb) / 0.62);
  padding: var(--pad-card);
  display: grid;
  gap: var(--space-5);
  min-width: 0;
}
:root[data-theme="dark"] .tl-card { --tl-line-strong: rgb(var(--pink-rgb) / 0.7); --tl-surface: color-mix(in srgb, var(--surface-sunk) 40%, var(--surface)); }

.tl-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; min-width: 0; }
.tl-head__text { min-width: 0; flex: 1 1 170px; }
.tl-head__title { font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.75rem); }
.tl-head__summary { margin-top: 6px; font-size: var(--fs-sm); color: var(--ink-2); }
.tl-head__summary:empty { display: none; }
.tl-head__add { flex-shrink: 0; }
.tl-head__add .icon { width: 16px; height: 16px; }

/* ---------- list & rail ------------------------------------------------- */
.tl-list, .tl-sublist { list-style: none; margin: 0; padding: 0; min-width: 0; }
.tl-item {
  position: relative;
  display: grid;
  grid-template-columns: var(--tl-time) var(--tl-rail) minmax(0, 1fr);
  column-gap: var(--tl-col);
  padding-bottom: var(--tl-row);
  min-width: 0;
}
.tl-list > .tl-item:last-child { padding-bottom: 0; }

.tl-time {
  padding-top: calc(var(--tl-top) + 3px);
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.tl-time__main { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-md); line-height: 1.2; color: var(--ink); letter-spacing: -0.01em; }
.tl-time__main--period { font-size: var(--fs-sm); line-height: 1.25; }
.tl-time__sub { margin-top: 2px; font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); line-height: 1.3; }

.tl-rail { position: relative; display: flex; justify-content: center; align-items: flex-start; }
/* One continuous line: each segment runs through its row and the gap below it. */
.tl-rail::before {
  content: "";
  position: absolute; left: 50%; top: 0; bottom: calc(-1 * var(--tl-row));
  width: 2px; margin-left: -1px; border-radius: 2px;
  background: var(--tl-line);
  transition: background-color var(--dur-3) var(--ease-out);
}
.tl-list > .tl-item:first-child > .tl-rail::before { top: calc(var(--tl-top) + var(--tl-node) / 2); }
.tl-list > .tl-item:last-child > .tl-rail::before { bottom: auto; height: calc(var(--tl-top) + var(--tl-node) / 2); }
.tl-list > .tl-item:only-child > .tl-rail::before { display: none; }
.tl-list > .tl-item.is-before-now > .tl-rail::before { background: var(--tl-line-strong); }

.tl-node {
  position: relative; z-index: 1;
  margin-top: var(--tl-top);
  width: var(--tl-node); height: var(--tl-node);
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  color: var(--ink-2);
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.tl-node .icon { width: 15px; height: 15px; }
.tl-item[data-state="past"] > .tl-rail .tl-node,
.tl-item[data-state="started"] > .tl-rail .tl-node { border-color: var(--tl-line-strong); color: var(--ink); }
.tl-item[data-done="yes"] > .tl-rail .tl-node { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tl-item[data-state="current"] > .tl-rail .tl-node {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
  box-shadow: 0 0 0 4px rgb(var(--pink-rgb) / 0.55);
}
.tl-item[data-state="inactive"] > .tl-rail .tl-node { border-style: dashed; opacity: 0.7; }

/* ---------- Phase 44.7 · same start time, one timestamp ------------------
   Display only. The first entry of a same-minute run keeps its time; a thin
   thread runs down the time column and ends, with a small tick, beside the
   last entry's node. Every entry keeps its own card, dropdown and actions. */
.tl-time__thread {
  display: block; flex: 1 1 auto; align-self: flex-end;
  width: 1px; min-height: 8px; margin: 7px var(--tl-thread-inset, 3px) calc(-1 * var(--tl-row)) 0;
  background: var(--tl-line); border-radius: 1px;
  transition: background-color var(--dur-3) var(--ease-out);
}
.tl-item.is-tg-mid > .tl-time > .tl-time__thread,
.tl-item.is-tg-last > .tl-time > .tl-time__thread { margin-top: calc(-1 * (var(--tl-top) + 3px)); }
.tl-item.is-tg-last > .tl-time > .tl-time__thread {
  position: relative; flex: none; height: calc(var(--tl-top) + var(--tl-node) / 2); min-height: 0; margin-bottom: 0;
}
.tl-item.is-tg-last > .tl-time > .tl-time__thread::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 6px; height: 1px; background: inherit; border-radius: 1px;
}
.tl-item.is-before-now > .tl-time > .tl-time__thread { background: color-mix(in srgb, var(--tl-line-strong) 70%, var(--tl-line)); }
/* The time is said once: later entries keep it for screen readers only. */
.tl-item.is-tg-mid .tl-meta__part--time,
.tl-item.is-tg-last .tl-meta__part--time {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- entry (collapsed header + panel) -------------------------- */
.tl-item:not(.tl-group):not(.tl-now):not(.tl-gap) > .tl-body {
  min-width: 0;
  border-radius: var(--radius-sm);
  background: var(--tl-surface);
  border: 1px solid var(--line);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.tl-item:not(.tl-group):not(.tl-now):not(.tl-gap) > .tl-body:hover { border-color: var(--line-2); }
.tl-item.is-open > .tl-body { border-color: var(--line-2); box-shadow: var(--shadow-sm, 0 1px 2px rgb(0 0 0 / 0.05)); }
.tl-item[data-state="current"] > .tl-body { border-color: var(--ink) !important; }

.tl-toggle {
  appearance: none; -webkit-appearance: none;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px;
  width: 100%; min-height: var(--tap);
  margin: 0; padding: 11px 10px 12px 16px;
  border: 0; border-radius: inherit; background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.tl-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tl-toggle__main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.tl-kicker { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); line-height: 1.4; overflow-wrap: anywhere; }
.tl-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); line-height: 1.3; color: var(--ink); overflow-wrap: anywhere; }
/* Separators never start a wrapped line: each part carries its dot on the left,
   and the dot of a part that begins a line falls outside the clipped wrapper. */
.tl-meta-wrap { display: block; overflow: hidden; }
.tl-meta { display: flex; flex-wrap: wrap; row-gap: 2px; margin-left: -16px; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; }
/* Phase 38: a part that wraps onto a second line is indented, never clipped (200% text). */
.tl-meta__part { position: relative; padding-left: 16px; overflow-wrap: anywhere; min-width: 0; }
.tl-meta__part--time { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.tl-meta__part::before { content: "·"; position: absolute; left: 0; top: 0; width: 16px; text-align: center; color: var(--ink-3); }
.tl-meta__part--warn { font-style: italic; }
.tl-toggle__side { display: flex; align-items: flex-start; gap: 6px; flex: none; max-width: 50%; }
.tl-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; padding-top: 2px; }
.tl-tags:empty { display: none; }
.tl-chev { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; color: var(--ink-2); transition: transform var(--dur-2) var(--ease-out), background-color var(--dur-1); }
.tl-chev .icon { width: 16px; height: 16px; }
.tl-toggle:hover .tl-chev { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tl-item.is-open > .tl-body > .tl-toggle .tl-chev { transform: rotate(180deg); }
.tl-item[data-state="past"] .tl-title,
.tl-item[data-state="inactive"] .tl-title { color: var(--ink-2); }
.tl-item[data-state="inactive"] .tl-title { text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: var(--ink-3); }

.tl-chip {
  display: inline-flex; align-items: center; min-height: 22px; padding: 1px 9px;
  border-radius: var(--radius-pill); border: 1px solid var(--line-2);
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.01em; line-height: 1.25; color: var(--ink-2);
  text-align: center; overflow-wrap: anywhere;
}
.tl-chip--cloud { border-style: dashed; color: var(--ink-2); font-weight: 600; }
/* A TIME, not a status: plain text with a dot — never a filled pill. */
.tl-when {
  display: inline-flex; align-items: center; gap: 6px; min-height: 22px;
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; line-height: 1.2;
  color: var(--ink-2); white-space: nowrap;
}
.tl-when::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: currentColor; }
.tl-when--live { color: var(--ink); }
.tl-when--live::before { box-shadow: 0 0 0 3px rgb(var(--pink-rgb) / 0.75); animation: tl-pulse 2.4s var(--ease-in-out) infinite; }
.tl-when--next::before { background: transparent; border: 1.5px solid currentColor; width: 6px; height: 6px; }
.tl-when--past { color: var(--ink-3); }
.tl-when--past::before { background: transparent; border: 1.5px solid currentColor; width: 6px; height: 6px; opacity: 0.8; }
@keyframes tl-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgb(var(--pink-rgb) / 0.75); } 50% { box-shadow: 0 0 0 5px rgb(var(--pink-rgb) / 0.35); } }
.tl-chip--done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tl-chip--live { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tl-chip--pending { border-style: dashed; border-color: var(--ink); color: var(--ink); }
.tl-chip--skipped { font-style: italic; }
.tl-chip--muted { border-style: dashed; color: var(--ink-3); }
.tl-chip--info { background: var(--ds-attn-bg, var(--accent-soft)); border-color: transparent; color: var(--ink); }
.tl-chip--window { border-style: dashed; color: var(--ink); }

/* Smooth height without measuring: 0fr → 1fr. Overflow becomes visible once open. */
.tl-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-2) var(--ease-out); }
.tl-item.is-open > .tl-body > .tl-panel { grid-template-rows: 1fr; }
.tl-panel__inner { min-height: 0; overflow: hidden; }
.tl-panel.is-settled > .tl-panel__inner { overflow: visible; }
.tl-panel__pad { display: grid; gap: 14px; padding: 12px 16px 16px; border-top: 1px solid var(--line); min-width: 0; }
.tl-details:empty, .tl-links:empty, .tl-host:empty { display: none; }

/* Phase 38: details as one compact row of facts (label above value), not a tall list. */
.tl-dl { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; min-width: 0; }
.tl-detail { display: grid; gap: 1px; align-content: start; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.tl-detail--parts { flex-basis: 100%; }
.tl-detail dt { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); line-height: 1.4; }
.tl-detail dd { margin: 0; font-size: var(--fs-sm); color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
.tl-parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tl-parts li::before { content: "♡"; margin-right: 6px; color: var(--ink-3); font-size: 0.85em; }
.tl-link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); text-underline-offset: 3px; }
.tl-link .icon { width: 14px; height: 14px; }

/* ---------- hosted original rows (same nodes; the entry header already carries title & time) */
.tl-host { min-width: 0; }
.tl-host__list { list-style: none; margin: 0; padding: 0; display: block; }
.tl-host .act, .tl-host .plan, .tl-host .tt-act {
  display: block; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; overflow: visible;
}
.tl-host .act::before,
.tl-host .act__art, .tl-host .act__kicker, .tl-host .act__title, .tl-host .act__meta,
.tl-host .plan__icon, .tl-host .plan__kicker, .tl-host .plan__title, .tl-host .plan__meta,
.tl-host .tp-act__title, .tl-host .tp-act__meta { display: none; }
.tl-host .act__sub { margin-top: 0; }
.tl-host .act__foot, .tl-host .plan__actions { margin-top: 10px; }
.tl-host .plan__side { margin-top: 2px; }
.tl-host .plan__side:has(+ .plan__actions) { display: none; }   /* the header chip already says it */
.tl-host .tt-act { display: grid; gap: 10px; }
/* Phase 38: the hosted workout sits directly on the entry — ONE surface, no
   card in a card. The open workout entry carries a light wash of the workout
   tint instead, so it stays recognisably "the workout". */
.tl-item[data-source="workout"].is-open > .tl-body { background: color-mix(in srgb, var(--tint-bg) 45%, var(--surface)); }
.tl-host--workout { padding: 0; border-radius: 0; background: none; color: var(--ink); min-width: 0; }
.tl-host--workout .workday {
  margin: 0 0 12px; padding: 8px 12px; border-radius: var(--radius-xs);
  background: var(--tint-chip); font-size: var(--fs-xs); line-height: 1.5;
}
.tl-host--workout .workday .icon { width: 15px; height: 15px; margin-top: 1px; }
.tl-host--workout .workout__head { margin-top: 0; }
.tl-host--workout .workout__head:first-child { margin-top: 0; }
.tl-host--workout .workout__tag { min-height: 26px; padding: 0 10px 0 8px; gap: 6px; letter-spacing: 0.1em; }
.tl-host--workout .workout__tag .icon { width: 14px; height: 14px; }
.tl-host--workout .workout__body { margin-top: 10px; gap: 8px 16px; }
.tl-host--workout .workout__title { font-size: var(--fs-lg); line-height: 1.12; letter-spacing: -0.02em; }
.tl-host--workout .workout__big { display: none; }                 /* the same number is in the chips */
.tl-host--workout .workout__meta { margin-top: 10px; gap: 6px; }
.tl-host--workout .workout__meta .chip { min-height: 30px; padding: 0 11px; font-size: var(--fs-xs); }
.tl-host--workout .stars { margin-top: 10px; }
.tl-host--workout .workout__actions { margin-top: 14px; }
.tl-host--workout .workout__actions .btn--lg { --btn-h: 46px; padding: 0 22px; font-size: var(--fs-sm); }
.tl-host--workout .workout-items { margin-top: 12px; gap: 0; }
.tl-host--workout .workout-item { padding: 12px 0; border-radius: 0; background: none; border-top: 1px solid var(--line); }
.tl-host--workout .past-notes,
.tl-host--workout .exercise-list { margin-top: 12px; padding: 2px 0 2px 14px; border-radius: 0; background: none; border-left: 2px solid var(--line-2); }
.tl-host--workout .follow-up { margin-top: 12px; border-radius: var(--radius-sm); }
.tl-host--workout .reminder { margin-top: 12px; border-radius: var(--radius-sm); }
.tl-host--workout .alt-done { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-sm); }
.tl-host--workout .planned-ref__label { margin-bottom: 8px; }
/* The question sits right under the workout, with a hairline — not at the bottom of a padded box. */
.tl-host--workout .completion { margin-top: 16px; padding-top: 14px; border-top: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.tl-host--workout .completion__inner { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- period groups (flexible windows) -------------------------- */
.tl-group__card { border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; min-width: 0; }
.tl-group[data-state="window"] .tl-group__card { border-color: var(--tl-line-strong); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tl-group__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 0 4px; }
.tl-group__title { font-weight: 700; font-size: var(--fs-sm); color: var(--ink); }
.tl-group__sub { font-size: var(--fs-xs); color: var(--ink-3); }
.tl-group__head .tl-chip { margin-left: auto; }
.tl-group > .tl-rail .tl-node { border-style: dashed; }
.tl-sublist { display: grid; gap: 8px; }
.tl-item--nested { display: block; padding: 0; }
.tl-item--nested > .tl-time, .tl-item--nested > .tl-rail { display: none; }

/* ---------- now & free time --------------------------------------------- */
.tl-now > .tl-rail::before { background: linear-gradient(to bottom, var(--tl-line-strong) 0 calc(var(--tl-top) + var(--tl-node) / 2), var(--tl-line) 0); }
.tl-now > .tl-time { padding-top: calc(var(--tl-top) + 2px); }
.tl-now__time { font-weight: 700; font-size: var(--fs-sm); color: var(--ink); line-height: 1.2; }
.tl-now > .tl-rail .tl-node {
  width: 14px; height: 14px; margin-top: calc(var(--tl-top) + (var(--tl-node) - 14px) / 2);
  border: 0; background: var(--ink);
  box-shadow: 0 0 0 4px rgb(var(--pink-rgb) / 0.6);
}
.tl-now > .tl-body { position: relative; display: flex; align-items: center; min-height: calc(var(--tl-top) * 2 + var(--tl-node)); }
.tl-now > .tl-body::before { content: ""; position: absolute; left: calc(-1 * var(--tl-col)); right: 0; top: calc(var(--tl-top) + var(--tl-node) / 2); height: 0; border-top: 1.5px solid var(--ink); opacity: 0.55; }
.tl-now__text {
  position: relative; z-index: 1; margin-left: 4px; padding: 3px 12px;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--line-2);
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; max-width: 100%;
}
.tl-now.is-moved > .tl-body, .tl-now.is-moved > .tl-time { animation: tl-settle var(--dur-3) var(--ease-out) both; }
@keyframes tl-settle { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.tl-gap > .tl-rail::before { background: none; border-left: 2px dotted var(--tl-line); width: 0; margin-left: -1px; }
.tl-gap.is-before-now > .tl-rail::before { border-left-color: var(--tl-line-strong); }
.tl-gap > .tl-rail .tl-node { display: none; }
.tl-gap > .tl-body { display: flex; align-items: center; min-height: 28px; }
.tl-gap__text { font-size: var(--fs-xs); color: var(--ink-3); font-style: italic; padding-left: 4px; }

/* ---------- empty, notes ------------------------------------------------ */
.tl-empty { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-radius: var(--radius-sm); border: 1px dashed var(--line-2); }
.tl-empty__icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--ink); flex: none; }
.tl-empty__icon .icon { width: 16px; height: 16px; }
.tl-empty__title { font-weight: 700; color: var(--ink); }
.tl-empty__text { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-2); }
.tl-card[data-state="loading"] .tl-empty { border-style: solid; border-color: var(--line); }

.tl-notes { display: grid; gap: 8px; min-width: 0; }
.tl-notes:empty { display: none; }
.tl-note { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px 8px; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.5; }
.tl-note .icon { width: 13px; height: 13px; flex: none; margin-top: 2px; }
.tl-note > span:first-child:has(> svg) { flex: none; display: inline-flex; }
.tl-note > span:first-child:has(> svg) + span { flex: 1 1 0; min-width: 0; }
.tl-note--done { color: var(--ink); }
.tl-note--quiet { color: var(--ink-3); }
.tl-note--error { color: var(--ds-attn, var(--ink)); }
.tl-notes .act-skips { margin: 0; }
.tl-notes .acts-empty { margin: 0; }

/* ---------- check-in answers: ONE family of controls (Phase 38) ---------
   Workout: "Yes, I did!" · "Not today" · "I Did Something Different".
   Learning & creative sessions: "Mark as completed" · "Not today".
   Same height, width, radius, icon well, padding and label alignment
   everywhere on Today (timeline entry or stand-alone card). Narrow: full-width
   stacked rows; wider: equal columns. Colours come from the context tokens. */
.choice-group {
  --ch-ink: var(--ink); --ch-bg: var(--surface); --ch-line: var(--line-2);
  --ch-on-bg: var(--btn-bg); --ch-on-ink: var(--btn-ink);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; gap: 8px; min-width: 0;
}
.workout-card:not(.tl-absorbed) .choice-group { --ch-ink: var(--tint-ink); --ch-bg: var(--tint-chip); --ch-line: color-mix(in srgb, var(--tint-ink) 30%, transparent); }
.completion, .act__foot { container-type: inline-size; }
/* Medium: the two direct answers side by side, the alternative path full width
   beneath. Wide: three equal columns. Never ad-hoc widths. */
@container (min-width: 380px) {
  .completion .choice-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .completion .choice-group .choice--diff { grid-column: 1 / -1; }
}
@container (min-width: 640px) {
  .completion .choice-group { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .completion .choice-group .choice--diff { grid-column: auto; }
}
@container (min-width: 300px) { .choice-group--act { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice-group .choice {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; column-gap: 12px;
  width: 100%; min-width: 0; min-height: 56px; margin: 0;
  padding: 10px 16px 10px 14px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--ch-line);
  background: var(--ch-bg); color: var(--ch-ink);
  font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; letter-spacing: 0.005em;
  text-align: left; white-space: normal; cursor: pointer;
}
.choice-group .choice:hover:not(:disabled) { transform: none; border-color: var(--ch-ink); box-shadow: none; }
.choice-group .choice:active:not(:disabled) { transform: scale(0.985); }
.choice-group .choice:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.choice-group .choice__mark { width: 28px; height: 28px; border-width: 1.5px; }
.choice-group .choice__label { min-width: 0; overflow-wrap: anywhere; text-wrap: pretty; }
.choice-group .act__complete .icon { width: 14px; height: 14px; }
/* saved answer */
.choice-group .choice[aria-pressed="true"]:not(.is-pending) { background: var(--ch-on-bg); border-color: var(--ch-on-bg); color: var(--ch-on-ink); }
.choice-group .choice[aria-pressed="true"]:not(.is-pending) .choice__mark { background: var(--ch-on-ink); border-color: var(--ch-on-ink); color: var(--ch-on-bg); }
.choice-group .choice--no[aria-pressed="true"]:not(.is-pending) { background: transparent; color: var(--ch-ink); border-color: var(--ch-ink); box-shadow: inset 0 0 0 0.5px var(--ch-ink); }
.choice-group .choice--no[aria-pressed="true"]:not(.is-pending) .choice__mark { background: var(--ch-ink); border-color: var(--ch-ink); color: var(--ch-bg); }
/* selected, NOT saved yet: dashed, never filled */
.choice-group .choice.is-pending[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--ch-bg)); color: var(--ch-ink);
  border: 1.5px dashed var(--ch-ink); box-shadow: inset 0 0 0 0.5px var(--ch-ink);
}
.choice-group .choice.is-pending[aria-pressed="true"] .choice__mark { background: transparent; color: var(--ch-ink); border-color: var(--ch-ink); }
.choice-group.has-choice .choice[aria-pressed="false"] { opacity: 0.62; }
.choice-group.has-choice .choice[aria-pressed="false"]:hover { opacity: 1; }
.choice-group .choice:disabled { opacity: 0.45; cursor: not-allowed; }

/* the question + its answers read as one block */
.completion__q { text-wrap: balance; }
.tl-host--workout .completion__q { margin-bottom: 10px; font-size: var(--fs-md); line-height: 1.3; }
.completion .completion__feedback:empty { display: none; }
.completion .completion__feedback { min-height: 0; margin-top: 10px; }
.completion .time-slot:empty { display: none; }
.completion__saved:empty { display: none; }
.completion .completion__saved { margin-top: 10px; }

/* Save Changes / Cancel — the obvious next step after choosing */
.completion .save-confirm, .act__foot .save-confirm {
  display: grid; gap: 4px 10px; margin-top: 10px; padding: 12px;
  border-radius: var(--radius-sm); border: 1.5px dashed color-mix(in srgb, var(--ink) 34%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
  color: var(--ink);
}
.completion .save-confirm__label, .act__foot .save-confirm__label { font-size: var(--fs-sm); line-height: 1.35; }
.completion .save-confirm__hint, .act__foot .save-confirm__hint { margin: 0 0 0 23px; }
.completion .save-confirm__actions, .act__foot .save-confirm__actions {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px;
}
.completion .save-confirm__actions .btn, .completion .save-confirm__actions .plan-btn,
.act__foot .save-confirm__actions .btn, .act__foot .save-confirm__actions .plan-btn {
  min-height: 46px; justify-content: center; font-size: var(--fs-sm); padding: 0 18px;
}
.completion .save-confirm__actions .save-confirm__save:only-child,
.act__foot .save-confirm__actions .save-confirm__save:only-child { grid-column: 1 / -1; }
.completion .save-confirm__error, .act__foot .save-confirm__error { margin-top: 6px; }
@container (min-width: 430px) {
  .completion .save-confirm { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .completion .save-confirm__label, .completion .save-confirm__hint { grid-column: 1; }
  .completion .save-confirm__actions { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; grid-template-columns: auto auto; }
  .completion .save-confirm__actions .save-confirm__save { min-width: 9.5em; }
  .completion .save-confirm__error { grid-column: 1 / -1; }
}
.completion .save-fix, .act__foot .save-fix { border-radius: var(--radius-sm); }

/* hosted activity rows: answers on their own line, full width */
.act__foot .choice-group--act { flex-basis: 100%; width: 100%; }
.tl-host .act__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

/* ---------- extra workouts on a day without a scheduled one (Phase 38) -- */
.xw { display: grid; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.xw__title { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; font-size: var(--fs-sm); }
.xw__title .icon { width: 16px; height: 16px; flex: none; }
.xw__sub { margin: 2px 0 0; font-size: var(--fs-xs); opacity: 0.8; max-width: 52ch; }
.xw__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.xw-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: start; gap: 4px 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--tint-chip); }
.xw-item__mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--btn-bg); color: var(--btn-ink); }
.xw-item__mark .icon { width: 13px; height: 13px; stroke-width: 2.5; }
.xw-item__body { min-width: 0; }
.xw-item__title { margin: 2px 0 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.xw-item__desc { margin: 4px 0 0; font-size: var(--fs-xs); white-space: pre-wrap; overflow-wrap: anywhere; opacity: 0.85; }
.xw-item__note { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; font-size: var(--fs-xs); opacity: 0.75; }
.xw-item__note .icon { width: 13px; height: 13px; }
.xw-item__actions .plan-btn { min-height: 36px; }
.xw-item__actions .icon { width: 13px; height: 13px; }
.xw__add { justify-self: start; }
.xw__add .icon { width: 15px; height: 15px; }
@media (max-width: 420px) {
  .xw-item { grid-template-columns: 26px minmax(0, 1fr); }
  .xw-item__actions { grid-column: 2; }
}
#xw-video-field[hidden] { display: none; }

/* ---------- narrow screens ------------------------------------------------ */
/* Phones: the time moves into each entry (it is already in the meta line),
   so the entry and its controls get the full width beside the rail. */
.tl-now__clock { display: none; }
@media (max-width: 560px) {
  .tl-card { --tl-time: 0px; --tl-rail: 24px; --tl-col: 10px; --tl-node: 24px; --tl-top: 12px; gap: var(--space-4); }
  .tl-item { grid-template-columns: var(--tl-rail) minmax(0, 1fr); }
  .tl-item > .tl-time { display: none; }
  .tl-now__clock { display: inline; font-weight: 700; }
  .tl-node .icon { width: 12px; height: 12px; }
  .tl-toggle { position: relative; flex-wrap: wrap; padding: 10px 42px 11px 13px; }
  .tl-toggle__side { max-width: 100%; flex: 1 1 100%; }
  .tl-toggle__side:not(:has(.tl-tags > *)) { display: none; }
  .tl-tags { justify-content: flex-start; padding-top: 0; }
  .tl-chev { position: absolute; top: 8px; right: 6px; }
  .tl-panel__pad { padding: 12px 13px 14px; gap: 12px; }
  .tl-host .workout__body { grid-template-columns: minmax(0, 1fr); }
  .tl-group__card { padding: 10px; }
  .tl-dl { gap: 8px 20px; }
  .tl-now__text { padding: 4px 11px; }
  /* Phase 44.7: phones have no time column — the first entry's own line keeps
     the time and a hairline beside the cards ties the group together. */
  .tl-item--tg > .tl-body { position: relative; }
  .tl-item--tg > .tl-body::before {
    content: ""; position: absolute; left: calc(-1 * var(--tl-col) / 2 - 0.5px); width: 1px;
    top: 0; bottom: calc(-1 * var(--tl-row) - 1px); background: var(--tl-line); border-radius: 1px; pointer-events: none;
  }
  .tl-item.is-tg-first > .tl-body::before { top: calc(var(--tl-top) + var(--tl-node) / 2); }
  .tl-item.is-tg-last > .tl-body::before { bottom: auto; height: calc(var(--tl-top) + var(--tl-node) / 2); }
}
@media (max-width: 360px) {
  .tl-card { --tl-col: 8px; }
  .tl-toggle { padding-left: 12px; }
  .tl-panel__pad { padding-inline: 12px; }
  .choice-group .choice { padding-inline: 12px 12px; column-gap: 10px; }
}

/* ---------- motion ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .tl-panel, .tl-chev, .tl-node, .tl-rail::before, .tl-time__thread { transition: none !important; }
  .tl-now.is-moved > .tl-body, .tl-now.is-moved > .tl-time { animation: none !important; }
  .tl-when--live::before { animation: none !important; }
  .choice-group .choice { transition: none !important; }
}

/* Scotty sees the workout but no check-in controls (style.css hides them): no empty divider. */
:root[data-viewer] .tl-host--workout .completion { border-top: 0; padding-top: 0; margin-top: 8px; }
