/* Tal / Train.
   One stylesheet for one phone. Portrait, 393 x 852, installed to the home screen.
   Section order follows DESIGN.md: tokens, shell, components, screens, overlays. */

/* ---------------------------------------------------------------- 1. Tokens */

:root {
  color-scheme: dark;

  /* Base. Darkest at the back, lightest at the front. */
  --bg:            #0a0c0f;
  --surface-1:     #111419;
  --surface-2:     #171b21;
  --surface-3:     #1e242b;
  --line:          #232a32;
  --line-strong:   #333c46;

  /* Ink */
  --text:          #f5f7f4;
  --text-2:        #a4ada6;
  --text-3:        #6f7a73;

  /* One accent. Lime on near black. */
  --accent:        #c9f24b;
  --accent-press:  #b5dc3c;
  --accent-ink:    #0e1304;
  --accent-wash:   rgba(201, 242, 75, 0.12);
  --accent-line:   rgba(201, 242, 75, 0.32);

  /* Semantic. Only three. */
  --good:          #c9f24b;
  --warn:          #f4c76b;
  --bad:           #ff8a7a;
  --bad-wash:      rgba(255, 138, 122, 0.12);

  /* Photographic scrim. Only on the Logs and Progress stat headers, never the hero. */
  --scrim-up:      linear-gradient(to top, rgba(10, 12, 15, 0.96), rgba(10, 12, 15, 0));

  /* Type. The root follows iOS Dynamic Type, every size is a capped rem. */
  --font-ui:       -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-display:  -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --font-num:      ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;

  --t-hero:        clamp(26px, 1.65rem, 34px);
  --t-title:       clamp(21px, 1.3rem,  27px);
  --t-section:     clamp(16px, 1rem,    20px);
  --t-body:        clamp(15px, 0.94rem, 19px);
  --t-small:       clamp(13px, 0.82rem, 17px);
  --t-micro:       clamp(11px, 0.68rem, 14px);
  --t-num-xl:      clamp(34px, 2.2rem,  44px);
  --t-num-lg:      clamp(24px, 1.5rem,  31px);
  --t-num-md:      clamp(19px, 1.2rem,  25px);

  --lh-tight:      1.05;
  --lh-snug:       1.25;
  --lh-body:       1.45;
  --track-tight:   -0.03em;
  --track-eyebrow:  0.12em;

  /* Spacing. 4pt grid. */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;

  --page-x: 16px;
  --row-min: 48px;
  --tap-min: 44px;

  /* Radii */
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-pill: 999px;

  /* Elevation */
  --e-0: none;
  --e-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --e-2: 0 8px 24px rgba(0, 0, 0, 0.35);
  --e-3: 0 -16px 48px rgba(0, 0, 0, 0.45);

  /* Motion */
  --ease:      cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in:   cubic-bezier(0.4, 0, 1, 1);
  --d-tap:     110ms;
  --d-fast:    180ms;
  --d-screen:  240ms;
  --d-sheet:   300ms;

  /* Safe areas */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  --tabbar-h: 54px;
}

@media (prefers-reduced-motion: reduce) {
  :root { --d-tap: 1ms; --d-fast: 1ms; --d-screen: 1ms; --d-sheet: 1ms; }
}

/* ------------------------------------------------------------ 2. Base rules */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 17px;            /* the iOS body size, so the scale matches the spec */
  font: -apple-system-body;   /* on iOS this wins and follows Dynamic Type */
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

svg {
  display: block;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:disabled {
  opacity: 0.45;
}

a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.noscript {
  padding: var(--s-6);
  color: var(--text-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  z-index: 100;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--t-small);
  font-weight: 700;
}

.skip-link:focus {
  top: var(--s-4);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------- 3. The shell */

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background: var(--bg);
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 0 calc(var(--s-6) + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: clip;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: none;
}

.app-main::-webkit-scrollbar {
  display: none;
}

/* The gutter, applied per block, never to the scroller. */
.gutter {
  padding-inline: calc(var(--page-x) + var(--safe-left)) calc(var(--page-x) + var(--safe-right));
}

.app[data-view="workout"] .app-main {
  padding: 0;
  overflow: hidden;
}

/* Today owns the whole screen: no trailing pad, so nothing scrolls by a hair. */
.app[data-view="home"] .app-main {
  padding-bottom: 0;
}

.app[data-view="workout"] .tabbar {
  display: none;
}

.screen {
  animation: screen-in var(--d-screen) var(--ease) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ 4. Type roles */

.eyebrow {
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: calc(56px + var(--safe-top));
  padding: var(--safe-top) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.screen-title {
  font-family: var(--font-display);
  font-size: var(--t-title);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-tight);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin: var(--s-4) 0 var(--s-2);
}

.section-label h2,
.section-label .eyebrow {
  margin: 0;
}

.empty-state {
  padding: var(--s-5) var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--text-2);
  font-size: var(--t-small);
  text-align: center;
}

/* ----------------------------------------------------------- 5. Components */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap-min);
  padding: 0 var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  transition: transform var(--d-tap) var(--ease), background-color var(--d-tap) var(--ease);
}

.button:active:not(:disabled) {
  transform: scale(0.97);
}

.button-primary {
  min-height: 54px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.button-primary:active:not(:disabled) {
  background: var(--accent-press);
}

.button-secondary {
  min-height: 48px;
  border-color: var(--line-strong);
  background: transparent;
}

.button-secondary:active:not(:disabled) {
  background: var(--surface-2);
}

.button-ghost {
  min-height: var(--tap-min);
  background: transparent;
  color: var(--text-2);
}

.button-destructive {
  min-height: 48px;
  background: var(--bad-wash);
  color: var(--bad);
}

.button-full {
  width: 100%;
}

.button-small {
  min-height: var(--tap-min);
  padding: 0 var(--s-3);
  font-size: var(--t-small);
}

.button-large {
  min-height: 54px;
}

.button-row {
  display: flex;
  gap: var(--s-2);
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.button-stack .button {
  width: 100%;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.icon-button:active {
  background: var(--surface-3);
  color: var(--text);
}

.icon-button svg,
.log-icons svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--s-1);
  color: var(--accent);
  font-size: var(--t-small);
  font-weight: 600;
}

.card {
  position: relative;
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--e-1);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-accent {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.badge-soft {
  border-color: transparent;
  background: var(--accent-wash);
  color: var(--accent);
}

.badge-warning {
  border-color: transparent;
  background: rgba(244, 199, 107, 0.14);
  color: var(--warn);
}

.exercise-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.field-label {
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 500;
}

.field-input,
.field-select {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
}

.field-textarea {
  width: 100%;
  min-height: 84px;
  padding: var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
  line-height: var(--lh-body);
  resize: none;
}

.field-textarea:focus,
.field-input:focus,
.field-select:focus {
  border-color: var(--accent-line);
  outline: none;
}

.field-hint {
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-body);
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
}

/* Steppers */

.stepper {
  display: grid;
  grid-template-columns: var(--tap-min) minmax(0, 1fr) var(--tap-min);
  align-items: center;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.stepper-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: 100%;
  color: var(--text-2);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.stepper-button:active {
  background: var(--surface-3);
  color: var(--text);
}

.stepper-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--s-1);
  min-width: 0;
}

.stepper-input {
  width: 4.2ch;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--t-num-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-unit {
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  white-space: nowrap;
}

/* Segmented control */

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  height: 36px;
  padding: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.segmented-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.segmented-option::after {
  position: absolute;
  inset: -6px 0;
  content: "";
}

.segmented-option[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
}

/* Inset grouped rows, the Settings backbone. */

.group {
  margin-bottom: var(--s-5);
}

.group-label {
  margin: 0 0 var(--s-2) var(--s-4);
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.group-rows {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  overflow: hidden;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: var(--row-min);
  padding: var(--s-1) var(--s-4);
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 500;
  line-height: var(--lh-snug);
  text-align: left;
}

.row + .row,
.row + .row-details,
.row-details + .row,
.row + .push-action {
  border-top: 1px solid var(--line);
}

button.row:active,
label.row:active {
  background: var(--surface-2);
}

.row-label {
  flex: 1 1 auto;
  min-width: 0;
}

.row-value {
  flex: 0 0 auto;
  color: var(--text-2);
  font-size: var(--t-body);
  font-variant-numeric: tabular-nums;
}

.row-chevron {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row-inline-field {
  flex: 0 0 auto;
  width: 7ch;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.row-inline-field:focus {
  outline: none;
  color: var(--text);
}

.row-tall {
  min-height: 56px;
}

.row-segmented {
  flex: 0 0 132px;
}

/* A select laid transparently over a row, so iOS shows its own picker. */
.row-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 17px;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 51px;
  height: 31px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-3);
  transition: background-color var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
}

.switch-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
  transition: transform var(--d-fast) var(--ease);
}

.switch input:checked + .switch-track {
  border-color: var(--accent);
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Disclosure rows */

.row-details > summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--row-min);
  padding: var(--s-2) var(--s-4);
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 500;
  list-style: none;
}

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

.row-details > summary:active {
  background: var(--surface-2);
}

.details-plus {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text-3);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  transition: transform var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}

details[open] > summary .details-plus {
  color: var(--accent);
  transform: rotate(45deg);
}

.row-details-body {
  padding: 0 var(--s-4) var(--s-4);
  border-top: 1px solid var(--line);
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding-top: var(--s-3);
}

.secret-code {
  display: block;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
  overflow-wrap: anywhere;
  -webkit-user-select: all;
  user-select: all;
}

.setup-steps {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-top: var(--s-3);
  padding-left: var(--s-4);
  list-style: decimal;
}

.setup-steps li {
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
}

.setup-steps code,
.push-body code {
  overflow-wrap: anywhere;
}

.setup-steps code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text);
  font-size: var(--t-micro);
}

/* Sparkline */

.sparkline {
  display: block;
  width: 100%;
  height: 96px;
}

.sparkline-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.sparkline-area {
  fill: var(--accent-wash);
  stroke: none;
}

.sparkline-dot {
  fill: var(--accent);
}

.sparkline-empty {
  color: var(--text-3);
  font-size: var(--t-small);
  line-height: var(--lh-body);
}

/* ------------------------------------------------------------- 6. Tab bar */

.tabbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  flex: 0 0 auto;
  min-height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 6px 4px calc(var(--safe-bottom) + 4px);
  border-top: 1px solid var(--line);
  background: rgba(10, 12, 15, 0.82);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.tabbar-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tap-min);
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  transition: color var(--d-fast) var(--ease);
}

.tabbar-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar-button[aria-current="page"] {
  color: var(--accent);
}

.tabbar-button[aria-current="page"] svg {
  stroke-width: 2.1;
}

.tabbar-button:active {
  transform: scale(0.94);
}

.tabbar-label {
  line-height: 1.2;
}

/* --------------------------------------------------------------- 7. Today */

.home-hero {
  position: relative;
  width: 100%;
  height: auto;
  /* 378 keeps the worst case (two-line greeting plus a day-load line) on one
     screen once the iPhone safe-bottom is added to the tab bar. */
  aspect-ratio: 393 / 378;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
}

.home-hero-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 25%;
}

.home-body {
  padding: var(--s-2) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.home-head {
  margin-bottom: var(--s-2);
}

.home-head .eyebrow {
  margin-bottom: var(--s-1);
}

.home-greeting-title {
  max-width: 17ch;
  font-family: var(--font-display);
  font-size: var(--t-hero);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--track-tight);
}

.home-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.stat-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  height: 64px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  text-align: left;
  overflow: hidden;
}

button.stat-tile:active {
  background: var(--surface-2);
  transform: scale(0.97);
}

.stat-tile-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--t-num-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
}

.stat-tile-value.is-empty {
  color: var(--text-3);
}

.stat-tile-unit {
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.stat-tile-caption {
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-tile-caption.is-down {
  color: var(--good);
}

.stat-tile-caption.is-up {
  color: var(--warn);
}

.session-card {
  position: relative;
  padding: var(--s-4);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xl);
  background:
    radial-gradient(circle at 100% 0%, var(--accent-wash), transparent 55%),
    var(--surface-1);
  box-shadow: var(--e-1);
  overflow: hidden;
}

.session-card::after {
  position: absolute;
  top: 0;
  right: var(--r-xl);
  width: 48px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
  content: "";
}

.session-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 26px;
}

.session-card-title {
  margin-top: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--t-title);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-tight);
}

.session-card-meta {
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-card-note {
  margin-top: var(--s-1);
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-snug);
}

.session-card .button {
  margin-top: var(--s-4);
}

/* A session in progress adds the progress block. Reclaim its height from the
   card padding and button gap so Today still fits on the target phone. */
.session-card:has(.session-progress) {
  padding-block: var(--s-3);
}

.session-card:has(.session-progress) .button {
  margin-top: var(--s-3);
}

.session-progress {
  margin-top: var(--s-3);
}

.session-progress-caption {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.session-progress-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.session-progress-fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--accent);
}

/* ------------------------------------------------------------- 8. Workout */

.screen-workout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.workout-top {
  display: grid;
  grid-template-columns: var(--tap-min) minmax(0, 1fr) var(--tap-min);
  align-items: center;
  gap: var(--s-2);
  flex: 0 0 auto;
  min-height: calc(56px + var(--safe-top));
  padding: calc(var(--safe-top) + 6px) calc(var(--page-x) + var(--safe-right)) 6px
    calc(var(--page-x) + var(--safe-left));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.workout-back,
.workout-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
}

.workout-back svg,
.workout-menu svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workout-back:active,
.workout-menu:active {
  background: var(--surface-3);
  color: var(--text);
}

.workout-progress {
  min-width: 0;
  text-align: center;
}

.workout-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 14px;
}

.workout-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.workout-dot[data-state="done"] {
  background: var(--accent);
}

.workout-dot[data-state="current"] {
  width: 11px;
  height: 11px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-line);
}

.workout-progress-label {
  margin-top: 4px;
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workout-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--s-3) calc(var(--page-x) + var(--safe-right)) var(--s-6)
    calc(var(--page-x) + var(--safe-left));
  overflow-y: auto;
  overflow-x: clip;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: none;
}

.workout-body::-webkit-scrollbar {
  display: none;
}

.day-load-note {
  margin-bottom: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
}

.exercise-strip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
}

.exercise-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  background: var(--accent-wash);
  color: var(--accent);
}

.exercise-tile svg {
  width: 24px;
  height: 24px;
}

.exercise-strip-copy {
  min-width: 0;
}

.exercise-strip-copy .eyebrow {
  margin-bottom: 2px;
}

.exercise-title {
  font-family: var(--font-display);
  font-size: var(--t-title);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-tight);
}

.prescription {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 72px;
  margin-top: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  overflow: hidden;
}

.prescription-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 0 var(--s-4);
  min-width: 0;
}

.prescription-cell + .prescription-cell {
  border-left: 1px solid var(--line);
}

.prescription-value {
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--t-num-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
}

.prescription-label {
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rest-line {
  margin-top: var(--s-3);
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rest-line .rest-live {
  color: var(--accent);
  font-weight: 700;
}

.set-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.set-card {
  padding: var(--s-3);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  animation: set-in var(--d-fast) var(--ease) both;
}

@keyframes set-in {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

.set-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
}

.set-fields-single {
  grid-template-columns: 1fr;
}

.set-fields-cardio {
  grid-template-columns: repeat(3, 1fr);
}

.set-fields-cardio .field-label {
  color: var(--text-3);
  font-size: var(--t-micro);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.set-fields-cardio .field-input {
  min-height: 48px;
  padding: 0 var(--s-2);
  text-align: center;
}

.set-log {
  width: 100%;
  min-height: var(--tap-min);
  margin-top: var(--s-2);
}

.set-row-logged {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--tap-min);
  padding-left: var(--s-3);
  border-radius: var(--r-md);
  background: var(--accent-wash);
}

.set-tick {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.set-name {
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.set-value {
  margin-left: auto;
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--t-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.set-undo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--tap-min);
  height: var(--tap-min);
  color: var(--text-3);
}

.set-undo svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.set-undo:active {
  color: var(--accent);
}

.set-row-pending {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: var(--t-small);
  font-weight: 600;
  text-align: left;
}

.set-row-pending:active {
  background: var(--surface-1);
  color: var(--text-2);
}

.set-details {
  margin-top: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  overflow: hidden;
}

.set-details > summary {
  display: flex;
  align-items: center;
  min-height: var(--row-min);
  padding: 0 var(--s-4);
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 500;
  list-style: none;
}

.set-details > summary::-webkit-details-marker {
  display: none;
}

.set-details > summary:active {
  background: var(--surface-2);
}

.details-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: 0 var(--s-4) var(--s-4);
}

.details-reason {
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
}

.effort-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
}

.effort-option {
  min-height: var(--row-min);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.effort-option[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent);
}

.workout-footer {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--s-2);
  flex: 0 0 auto;
  padding: 0 calc(var(--page-x) + var(--safe-right)) var(--safe-bottom)
    calc(var(--page-x) + var(--safe-left));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.workout-footer .button {
  min-height: 54px;
}

/* ------------------------------------------------------------- 9. Summary */

.summary-hero {
  padding: calc(var(--safe-top) + var(--s-4)) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.summary-hero .eyebrow {
  margin-bottom: var(--s-2);
}

.summary-title {
  font-family: var(--font-display);
  font-size: var(--t-hero);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--track-tight);
}

.summary-date {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 72px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.stat-value {
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--t-num-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  line-height: 1.2;
  text-transform: uppercase;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.next-list {
  margin-top: var(--s-2);
}

.next-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: var(--tap-min);
  border-top: 1px solid var(--line);
}

.next-item:first-child {
  border-top: 0;
}

.next-name {
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 500;
}

.next-change {
  color: var(--accent);
  font-family: var(--font-num);
  font-size: var(--t-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-flat {
  box-shadow: none;
}

.llm-card .card-row .badge {
  margin-left: auto;
}

.llm-line {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--t-body);
  line-height: var(--lh-body);
}

.llm-empty {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--t-small);
  line-height: var(--lh-body);
}

.coach-pick {
  margin-top: var(--s-2);
}

.coach-change {
  color: var(--accent);
  font-family: var(--font-num);
  font-size: var(--t-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ai-note {
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-body);
}

.meta-row {
  margin-top: var(--s-2);
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-body);
}

/* ---------------------------------------------------------------- 10. Logs */

.log-tabs {
  padding: 0 calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.log-body {
  padding: var(--s-3) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.log-row {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  text-align: left;
}

.log-row:active {
  background: var(--surface-2);
}

.log-row-active {
  border-color: var(--accent-line);
}

.log-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}

.log-date {
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 650;
}

.log-volume {
  color: var(--accent);
  font-family: var(--font-num);
  font-size: var(--t-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-1);
}

.log-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
}

.log-icons svg {
  width: 16px;
  height: 16px;
}

.log-count {
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  white-space: nowrap;
}

.weight-head {
  padding: var(--s-2) 0 var(--s-3);
}

.weight-value {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-top: var(--s-2);
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--t-num-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.weight-unit {
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.weight-delta {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--t-small);
}

.weight-delta-down {
  color: var(--good);
}

.weight-delta-up {
  color: var(--warn);
}

.weight-spark {
  margin: var(--s-3) 0;
}

.history-list {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  overflow: hidden;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: var(--tap-min);
  padding: 0 var(--s-4);
  font-size: var(--t-body);
}

.history-row + .history-row {
  border-top: 1px solid var(--line);
}

.history-date {
  color: var(--text-2);
}

.history-weight {
  color: var(--text);
  font-family: var(--font-num);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.log-exercise {
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}

.log-exercise:first-of-type {
  border-top: 0;
}

.log-exercise-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.exercise-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
}

.exercise-icon-wrap svg {
  width: 24px;
  height: 24px;
}

.log-exercise-head > div {
  flex: 1 1 auto;
  min-width: 0;
}

.log-exercise-title {
  font-family: var(--font-display);
  font-size: var(--t-section);
  font-weight: 650;
  line-height: var(--lh-snug);
}

.log-meta {
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-body);
}

.log-exercise-note {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--t-small);
  font-style: italic;
}

.set-table {
  margin-top: var(--s-2);
}

.set-table-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  align-items: center;
  min-height: 36px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--t-small);
}

.set-table-row-head {
  border-top: 0;
  color: var(--text-3);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.set-table-value {
  color: var(--text);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.set-table-empty {
  margin-top: var(--s-2);
  color: var(--text-3);
  font-size: var(--t-small);
}

/* ------------------------------------------------------------ 11. Progress */

.progress-body {
  padding: var(--s-2) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.progress-big {
  margin-top: var(--s-2);
  color: var(--accent);
  font-family: var(--font-num);
  font-size: var(--t-num-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.progress-sub {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--t-small);
}

.progress-spark {
  margin: var(--s-3) 0;
}

.ai-card {
  margin-top: var(--s-3);
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.ai-copy {
  margin-top: var(--s-3);
  color: var(--text);
  font-size: var(--t-body);
  line-height: var(--lh-body);
}

.ai-copy-rules {
  color: var(--text-2);
}

.ai-copy.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
}

.ai-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.ai-footer .ai-updated {
  color: var(--text-3);
  font-size: var(--t-micro);
}

/* ------------------------------------------------------------ 12. Settings */

.settings-body {
  padding: var(--s-2) calc(var(--page-x) + var(--safe-right)) 0
    calc(var(--page-x) + var(--safe-left));
}

.settings-save {
  margin-top: var(--s-2);
}

.settings-foot {
  margin: var(--s-5) 0 var(--s-2);
  color: var(--text-3);
  font-size: var(--t-micro);
  letter-spacing: var(--track-eyebrow);
  text-align: center;
  text-transform: uppercase;
}

.push-body {
  padding: 0 var(--s-4) var(--s-3);
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-body);
}

.push-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  min-height: var(--row-min);
  padding: var(--s-2) var(--s-4);
  color: var(--accent);
  font-size: var(--t-body);
  font-weight: 600;
  text-align: left;
}

.push-action:active {
  background: var(--surface-2);
}

/* --------------------------------------------------------- 13. Sheets, toast */

.sheet-root:empty {
  display: none;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.55);
  animation: fade-in var(--d-fast) var(--ease) both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.sheet {
  width: 100%;
  max-height: 88svh;
  padding: var(--s-2) calc(var(--s-4) + var(--safe-right)) calc(var(--s-6) + var(--safe-bottom))
    calc(var(--s-4) + var(--safe-left));
  border-top: 1px solid var(--line-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface-1);
  box-shadow: var(--e-3);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  animation: sheet-in var(--d-sheet) var(--ease) both;
}

.sheet::-webkit-scrollbar {
  display: none;
}

@keyframes sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.sheet-grabber {
  width: 36px;
  height: 5px;
  margin: 0 auto var(--s-3);
  border-radius: var(--r-pill);
  background: var(--line-strong);
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.sheet-title {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: var(--t-title);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-tight);
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.sheet-menu {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.sheet-menu .button {
  width: 100%;
}

.discard-zone {
  margin-top: var(--s-6);
}

.confirm-row {
  padding: var(--s-3);
  border: 1px solid rgba(255, 138, 122, 0.3);
  border-radius: var(--r-md);
  background: var(--bad-wash);
}

.confirm-text {
  margin-bottom: var(--s-3);
  color: var(--text);
  font-size: var(--t-body);
  line-height: var(--lh-body);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
}

.confirm-delete {
  min-height: var(--tap-min);
  border-radius: var(--r-md);
  background: var(--bad);
  color: #1a0a07;
  font-size: var(--t-body);
  font-weight: 700;
}

.goal-options {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.goal-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 64px;
  padding: var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: left;
}

.goal-option[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-wash);
}

.goal-name {
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 600;
}

.goal-detail {
  color: var(--text-3);
  font-size: var(--t-micro);
  line-height: var(--lh-body);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--tabbar-h) + 12px);
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text);
  font-size: var(--t-small);
  line-height: var(--lh-body);
  text-align: center;
  transform: translateX(-50%);
  box-shadow: var(--e-2);
}

.toast[data-tone="error"] {
  border-color: rgba(255, 138, 122, 0.4);
  background: #2a1714;
  color: var(--bad);
}

/* -------------------------------------------------------------- 14. Loading */

.screen-loading {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 70svh;
  overflow: hidden;
  text-align: center;
}

.loading-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.loading-veil {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 15, 0.72);
}

.loading-copy {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-6);
}

.loading-copy h1 {
  font-family: var(--font-display);
  font-size: var(--t-section);
  font-weight: 650;
  line-height: var(--lh-snug);
}

.loading-mark {
  display: flex;
  gap: 6px;
}

.loading-mark span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: loading-pulse 1.1s var(--ease) infinite;
}

.loading-mark span:nth-child(2) {
  animation-delay: 0.16s;
}

.loading-mark span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1); }
}

/* ----------------------------------------------------- 15. Short viewports */

/* 393 x 852 is the target. On a shorter phone the photo gives up height first,
   so Today still lands on one screen. */
@media (max-height: 700px) {
  .home-hero {
    height: clamp(180px, 32svh, 250px);
  }

  .home-body {
    padding-top: var(--s-2);
  }

  .home-head {
    margin-bottom: var(--s-2);
  }

  .home-numbers {
    margin-bottom: var(--s-2);
  }

  .session-card {
    padding: var(--s-3) var(--s-4);
  }

  .session-card .button {
    margin-top: var(--s-2);
  }
}
