/* LiftRun — dark-mode-first, gym-glanceable, one-handed */
*, *::before, *::after { box-sizing: border-box; }
/* Dynamic Type: root font-size drives all rem-based text. Settings can bump it. */
html { font-size: 16px; }
html[data-textsize="large"]  { font-size: 18px; }
html[data-textsize="larger"] { font-size: 20px; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 1rem; line-height: 1.5;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}
/* Ambient depth: a soft warm glow at the top + a cool floor, fixed behind all content. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(125% 70% at 50% -12%, var(--glow-accent), transparent 58%),
    radial-gradient(100% 50% at 50% 112%, var(--glow-floor), transparent 60%);
}
:root {
  --bg: #090b0e;
  --bg-2: #15191f;       /* primary card surface */
  --bg-3: #1d222b;       /* raised: inputs, steppers, chips */
  --line: #2a313a;
  --line-2: #39424d;
  --text: #eef1f4;
  --text-dim: #9aa3ad;
  --text-faint: #868f9b;
  --accent: #ff6438;
  --accent-2: #ffb38a;
  --accent-grad: linear-gradient(180deg, #ff7d52 0%, #ff5a28 100%);
  --on-accent: #1a0d07;          /* text/glyphs on top of the accent */
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #ef4444;
  --tab-h: calc(60px + env(safe-area-inset-bottom));
  --top: env(safe-area-inset-top);
  /* Surfaces & elevation */
  --fill-subtle: rgba(255,255,255,.035);   /* grouped/flat sections */
  --card-hi: inset 0 1px 0 rgba(255,255,255,.05);   /* lit-from-above edge */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 4px 16px rgba(0,0,0,.30), 0 1px 3px rgba(0,0,0,.22);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.50), 0 4px 12px rgba(0,0,0,.32);
  --glow-accent: rgba(255,100,56,.07);
  --glow-floor: rgba(40,70,120,.06);
  --bg-blur: rgba(9,11,14,.72);
  /* Spacing scale (8pt-based) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 11px;
}
/* Light theme — opt-in via data-theme attribute on <html> */
html[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-2: #ffffff;
  --bg-3: #eceff3;
  --line: #e0e4ea;
  --line-2: #c4cad3;
  --text: #11161c;
  --text-dim: #5a6470;
  --text-faint: #6b7480;
  --accent: #e85529;
  --accent-2: #ff7a4a;
  --accent-grad: linear-gradient(180deg, #ff7141 0%, #e8501f 100%);
  --on-accent: #1a0d07;
  --fill-subtle: rgba(16,22,30,.035);
  --card-hi: inset 0 1px 0 rgba(255,255,255,.7);
  --shadow-sm: 0 1px 2px rgba(20,30,50,.06);
  --shadow: 0 4px 16px rgba(20,30,50,.07), 0 1px 3px rgba(20,30,50,.05);
  --shadow-lg: 0 18px 44px rgba(20,30,50,.14), 0 4px 12px rgba(20,30,50,.08);
  --glow-accent: rgba(255,100,56,.05);
  --glow-floor: rgba(40,70,120,.03);
  --bg-blur: rgba(244,246,249,.78);
}

/* Pink theme — light, blush surfaces with a magenta-pink accent. Opt-in per profile. */
html[data-theme="pink"] {
  --bg: #fff5f9;
  --bg-2: #ffffff;
  --bg-3: #ffe7f1;
  --line: #ffd3e4;
  --line-2: #f6abc9;
  --text: #2a1620;
  --text-dim: #8a6076;
  --text-faint: #92637a;
  --accent: #ec4899;             /* pink-500 */
  --accent-2: #f9a8d4;
  --accent-grad: linear-gradient(180deg, #f472b6 0%, #ec4899 100%);
  --on-accent: #ffffff;          /* white reads best on pink */
  --good: #16a34a; --warn: #d97706; --bad: #dc2626;
  --fill-subtle: rgba(236,72,153,.05);
  --card-hi: inset 0 1px 0 rgba(255,255,255,.85);
  --shadow-sm: 0 1px 2px rgba(190,40,110,.08);
  --shadow: 0 4px 16px rgba(190,40,110,.12), 0 1px 3px rgba(190,40,110,.07);
  --shadow-lg: 0 18px 44px rgba(190,40,110,.20), 0 4px 12px rgba(190,40,110,.12);
  --glow-accent: rgba(236,72,153,.09);
  --glow-floor: rgba(244,114,182,.06);
  --bg-blur: rgba(255,245,249,.82);
}
html[data-theme="system"] {
  /* respects OS — vars stay as dark defaults but flip in light system mode */
}
@media (prefers-color-scheme: light) {
  html[data-theme="system"] {
    --bg: #f4f6f9; --bg-2: #fff; --bg-3: #eceff3;
    --line: #e0e4ea; --line-2: #c4cad3;
    --text: #11161c; --text-dim: #5a6470; --text-faint: #6b7480;
    --accent: #e85529; --accent-2: #ff7a4a;
    --accent-grad: linear-gradient(180deg, #ff7141 0%, #e8501f 100%);
    --on-accent: #1a0d07;
    --fill-subtle: rgba(16,22,30,.035);
    --card-hi: inset 0 1px 0 rgba(255,255,255,.7);
    --shadow-sm: 0 1px 2px rgba(20,30,50,.06);
    --shadow: 0 4px 16px rgba(20,30,50,.07), 0 1px 3px rgba(20,30,50,.05);
    --shadow-lg: 0 18px 44px rgba(20,30,50,.14), 0 4px 12px rgba(20,30,50,.08);
    --glow-accent: rgba(255,100,56,.05);
    --glow-floor: rgba(40,70,120,.03);
    --bg-blur: rgba(244,246,249,.78);
  }
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea {
  font: inherit; color: inherit;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,100,56,.18);
}
::selection { background: rgba(255,100,56,.3); }

/* Keyboard / switch-control focus ring — visible for everyone navigating without touch. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible, .tab:focus-visible, .switch:focus-visible, .rpe-chip:focus-visible,
.log-btn:focus-visible, .run-type-chip:focus-visible, .run-start-btn:focus-visible,
summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:focus-visible { outline-offset: 3px; }

.app {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
.view {
  flex: 1; padding: calc(var(--top) + 14px) 16px calc(var(--tab-h) + 20px);
  max-width: 720px; margin: 0 auto; width: 100%;
  scroll-behavior: smooth;
}
/* Subtle, unobtrusive scrollbars (desktop/iPad). */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--tab-h);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--bg-blur);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--line);
  z-index: 50;
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-faint); padding: 4px 2px;
  font-size: 10px; font-weight: 600; letter-spacing: .01em;
  transition: color .2s;
}
.tab svg { width: 23px; height: 23px; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg { transform: translateY(-1px) scale(1.06); }
/* Active indicator: a soft glow above the icon. */
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 5px; width: 26px; height: 26px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,100,56,.28), transparent 70%);
  pointer-events: none;
}
.tab:active { transform: scale(.92); transition: transform .08s; }

/* Headers */
.h-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 18px; min-width: 0; }
h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 0; }
.h-row h1 { min-width: 0; }
.workout-title {
  flex: 1; min-width: 0;
  font-size: 1.25rem !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
h2 { font-size: 1.3rem; font-weight: 750; letter-spacing: -.02em; margin: 26px 0 12px; }
h3 { font-size: 1rem; font-weight: 650; letter-spacing: -.01em; margin: 0 0 6px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 0.8125rem; }
.eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }

/* Card — elevated primary surface */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--card-hi), var(--shadow);
}
.card.tight { padding: 12px; }
/* Flat — a quiet grouped section, not another outlined box. */
.card.flat {
  background: var(--fill-subtle);
  border: 0;
  box-shadow: none;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 12px 18px; border-radius: 13px;
  background: var(--bg-3); color: var(--text);
  font-weight: 650; font-size: 15px; letter-spacing: -.01em;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent-grad); color: var(--on-accent); border-color: transparent;
  box-shadow: 0 4px 14px rgba(255,100,56,.32), var(--card-hi);
  font-weight: 700;
}
.btn.primary:active { filter: brightness(.94); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text); }
.btn.ghost:active { background: var(--fill-subtle); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.lg { min-height: 56px; font-size: 16px; border-radius: 15px; }
.btn.sm { min-height: 36px; padding: 8px 13px; font-size: 13px; border-radius: 9px; box-shadow: none; }
.btn.icon { width: 44px; height: 44px; padding: 0; border-radius: 13px; min-height: 44px; }
.btn.icon svg { width: 22px; height: 22px; }
.btn:disabled { opacity: .45; pointer-events: none; box-shadow: none; }

/* Pills / chips */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line);
  font-size: 12px; font-weight: 650; letter-spacing: -.01em;
  line-height: 1;
}
.pill.accent { background: rgba(255,100,56,.12); color: var(--accent); border-color: rgba(255,100,56,.3); }
.pill.good { background: rgba(74,222,128,.12); color: var(--good); border-color: rgba(74,222,128,.3); }
.pill.warn { background: rgba(251,191,36,.12); color: var(--warn); border-color: rgba(251,191,36,.3); }

/* Today hero */
.hero {
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255,100,56,.10), transparent 55%),
    linear-gradient(165deg, var(--bg-3) 0%, var(--bg-2) 72%);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg); padding: 20px;
  position: relative; overflow: hidden;
  box-shadow: var(--card-hi), var(--shadow);
}
.hero::after {
  content: ""; position: absolute; right: -50px; top: -50px;
  width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,100,56,.22), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; }
.hero h1 { font-size: 2rem; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 0; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item .meta { margin-left: auto; color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.list-item button.row-btn {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
}

/* Set logging */
.exercise-block {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
  box-shadow: var(--card-hi), var(--shadow);
}
.exercise-block .ex-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.exercise-block .ex-header h3 { flex: 1; }
.set-row {
  display: grid;
  /* minmax(0,1fr) lets the steppers shrink instead of clipping the number on narrow phones. */
  grid-template-columns: 18px minmax(0,1fr) minmax(0,1fr) 40px auto;
  gap: 5px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.set-row.head { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; border-top: 0; padding-top: 0; }
.set-row .idx { color: var(--text-faint); font-weight: 700; font-variant-numeric: tabular-nums; }
.set-row.done .idx { color: var(--good); }
.set-row .stepper {
  display: grid; grid-template-columns: 27px minmax(0,1fr) 27px;
  align-items: center;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden;
}
.set-row .stepper input {
  background: transparent; border: 0; text-align: center; min-width: 0;
  font-size: 14px; font-weight: 600; padding: 9px 0;
  font-variant-numeric: tabular-nums;
}
.set-row .stepper button {
  height: 38px; padding: 0; color: var(--text-dim); font-size: 18px; font-weight: 700;
}
.set-row .stepper button:active { background: var(--line); }
.set-row .rpe-chip {
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; height: 42px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.set-row .log-btn {
  height: 42px; min-width: 44px; padding: 0 7px;
  border-radius: 11px; background: var(--accent-grad); color: var(--on-accent);
  font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 8px rgba(255,100,56,.28);
  transition: transform .08s, filter .15s;
}
.set-row .log-btn:active { transform: scale(.95); filter: brightness(.94); }
.set-row.done .log-btn { background: var(--good); box-shadow: none; }
.set-row.done .stepper { opacity: .65; }

/* Rest timer */
.timer-fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + 12px);
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--accent-grad); color: var(--on-accent);
  font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 28px rgba(255,100,56,.40), var(--card-hi);
  z-index: 40;
  transition: transform .15s;
}
.timer-fab:active { transform: scale(.95); }
.timer-fab.hidden { display: none; }
.timer-fab .ring {
  position: absolute; inset: 0; transform: rotate(-90deg);
  pointer-events: none;
}

/* PR badge */
.pr-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-grad);
  color: var(--on-accent); font-size: 11px; font-weight: 800; letter-spacing: .04em;
}

/* Bottom sheet */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sheet-back.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg-2);
  border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg);
  padding: 0 16px calc(env(safe-area-inset-bottom) + 20px);
  z-index: 61; max-height: 92dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  transform: translateY(100%); transition: transform .34s cubic-bezier(.32,.72,0,1);
  border-top: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  will-change: transform;
}
.sheet.open { transform: translateY(0); }
/* While the user is dragging, kill the transition so the sheet tracks the finger 1:1. */
.sheet.dragging { transition: none; }
/* Persistent sticky drag handle — always a target, even when content is scrolled. */
.sheet .grabber {
  position: sticky; top: 0; z-index: 4;
  width: calc(100% + 32px); margin: 0 -16px 6px;
  padding: 12px 0 10px; /* large hit area */
  display: flex; align-items: center; justify-content: center;
  cursor: grab; touch-action: none;
  background: linear-gradient(var(--bg-2) 62%, transparent);
  border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg);
}
.sheet .grabber:active { cursor: grabbing; }
.sheet .grabber::before {
  content: ""; display: block;
  width: 38px; height: 5px; border-radius: 3px;
  background: var(--line-2);
  transition: background .15s, width .15s;
}
.sheet.dragging .grabber::before { background: var(--accent); width: 52px; }
/* Always-visible close button in the top-right of every sheet. */
.sheet .sheet-close {
  position: sticky; top: 12px; float: right;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg-3);
  color: var(--text-dim); border: 1px solid var(--line);
  font-size: 18px; font-weight: 600;
  cursor: pointer; margin: 0 -4px -32px 0;
  z-index: 5;
}
.sheet .sheet-close:active { background: var(--line); transform: scale(.92); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.grid-2 > * { min-width: 0; }
.field { min-width: 0; }
.field input, .field select, .field textarea { width: 100%; max-width: 100%; box-sizing: border-box; }
/* Belt-and-braces: any input/select/textarea, anywhere, must not overflow its container. */
input, select, textarea { max-width: 100%; box-sizing: border-box; }
input[type="file"] { width: 100%; padding: 8px; font-size: 13px; color: var(--text-dim); }
input[type="file"]::-webkit-file-upload-button {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 500;
  margin-right: 10px; cursor: pointer;
}
.card { min-width: 0; overflow-wrap: break-word; overflow-x: hidden; }
.view { overflow-x: hidden; }
.app { overflow-x: hidden; max-width: 100vw; }

/* Toggles */
.toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.toggle:last-child { border-bottom: 0; }
.toggle .label { font-weight: 500; }
.switch { width: 50px; height: 30px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; position: relative; transition: background .2s; }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--text); transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }

/* Charts */
.chart {
  width: 100%; height: 160px; display: block;
}
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .gridline { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; opacity: .5; }
.chart .line { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart .area { fill: rgba(255,100,56,.16); }
.chart .bar { fill: var(--accent); }
.chart .dot { fill: var(--accent); }
.chart text { fill: var(--text-faint); font-size: 10px; }

/* Calendar adherence */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .cell { aspect-ratio: 1; border-radius: 6px; background: var(--bg-3); position: relative; }
.cal .cell.done { background: var(--accent); }
.cal .cell.rest { background: var(--line); }
.cal .cell.partial { background: rgba(255,100,56,.4); }
.cal .cell .d { position: absolute; top: 2px; left: 4px; font-size: 9px; color: var(--text-faint); }
.cal .cell.done .d { color: var(--on-accent); }

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--tab-h) + 100px); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 100; box-shadow: var(--shadow);
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(74,222,128,.4); }
.toast.error { border-color: rgba(239,68,68,.4); color: #fecaca; }

/* Run map */
#runmap { width: 100%; height: 220px; background: var(--bg-3); border-radius: var(--radius); margin-bottom: 12px; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 80px; }
.bubble { padding: 10px 14px; border-radius: 16px; max-width: 86%; font-size: 15px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.bubble.user { background: var(--accent-grad); color: var(--on-accent); align-self: flex-end; border-bottom-right-radius: 4px; box-shadow: 0 2px 10px rgba(255,100,56,.22); }
.bubble.assistant { background: var(--bg-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm); }
.composer {
  position: fixed; bottom: var(--tab-h); left: 0; right: 0;
  display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg-blur); border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 44px; padding: 10px 12px;
}

/* PR celebration */
@keyframes prpop { 0% { transform: scale(.6); opacity: 0 } 60% { transform: scale(1.15); opacity: 1 } 100% { transform: scale(1); } }
.pr-celebration {
  position: fixed; top: 30%; left: 50%; transform: translateX(-50%);
  padding: 16px 24px; border-radius: 16px;
  background: var(--accent-grad); color: var(--on-accent);
  font-weight: 800; font-size: 22px; letter-spacing: -.01em;
  box-shadow: var(--shadow); z-index: 200;
  animation: prpop .6s cubic-bezier(.2,.8,.2,1);
}

/* Skeleton shimmer */
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

/* Full-screen rest timer */
.rest-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: radial-gradient(circle at 50% 40%, var(--bg-3), var(--bg) 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  padding: env(safe-area-inset-top) 24px calc(env(safe-area-inset-bottom) + 24px);
}
.rest-breathe { position: relative; display: flex; align-items: center; justify-content: center; animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(.94); } 50% { transform: scale(1.04); } }
.rest-count { position: absolute; font-size: 3.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.rest-sub { position: absolute; bottom: 64px; color: var(--text-faint); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.rest-actions { display: flex; gap: 12px; }
.rest-actions .btn { min-width: 120px; }
.rest-close { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--line); color: var(--text-dim); width: 44px; height: 28px; border-radius: 14px; font-size: 18px; }
@media (prefers-reduced-motion: reduce) { .rest-breathe { animation: none; } }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Animated exercise demonstration (looping start/end frames) */
.ex-demo {
  position: relative; width: 100%;
  background: radial-gradient(circle at 50% 35%, var(--bg-3), var(--bg-2));
  border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center; min-height: 160px;
}
.ex-demo.compact { min-height: 120px; }
.ex-demo-img { width: 100%; display: block; object-fit: contain; }
.ex-demo.empty { min-height: 110px; }
.ex-demo-fallback { font-size: 44px; opacity: .35; }
.ex-demo-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.5); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 999px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}

/* Account gate (pre-app profile create / picker / PIN) */
.account-gate {
  position: fixed; inset: 0; z-index: 1000;
  background: radial-gradient(125% 70% at 50% -12%, var(--glow-accent), transparent 58%), var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 24px);
  overflow-y: auto;
}
.account-inner { width: 100%; max-width: 420px; }
.account-logo {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 16px;
  background: var(--bg-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--accent);
  box-shadow: var(--card-hi), var(--shadow);
}

/* Util */
.spacer { height: 16px; }
.center { text-align: center; }
.hide { display: none !important; }
.row-action { display: flex; gap: 8px; align-items: center; }
.kbd-like { font-variant-numeric: tabular-nums; }

/* Onboarding */
.welcome {
  min-height: 80vh; display: flex; flex-direction: column; gap: 16px;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
}
.welcome h1 { font-size: 36px; }
.welcome .logo {
  width: 84px; height: 84px; border-radius: 22px;
  background: linear-gradient(160deg, #1c2128, #0b0d10);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.welcome .logo svg { width: 50px; height: 50px; }

/* ============================================================
   Running tab — bold, full-bleed running UI (original design).
   Scoped under .run-screen so the volt accent never leaks into
   the rest of the app's orange brand.
   ============================================================ */
.run-screen { --volt: #d8ff3e; --volt-ink: #11160a; }
.run-screen .run-eyebrow {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 800;
}
.run-screen .run-headline {
  font-size: 40px; line-height: .96; font-weight: 900; letter-spacing: -.03em;
  margin: 2px 0 0; text-transform: uppercase;
}

/* Run-type picker chips */
.run-types { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
.run-types::-webkit-scrollbar { display: none; }
.run-type-chip {
  flex: 0 0 auto; padding: 9px 16px; border-radius: 999px; cursor: pointer;
  background: var(--bg-3); border: 1.5px solid var(--line); color: var(--text-dim);
  font-weight: 800; font-size: 13px; letter-spacing: .01em; transition: all .15s;
}
.run-type-chip[aria-pressed="true"] {
  background: var(--volt); color: var(--volt-ink); border-color: var(--volt);
}

/* Big circular START button */
.run-start-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px 0 6px; }
.run-start-btn {
  width: 188px; height: 188px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--volt); color: var(--volt-ink);
  font-size: 30px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 0 0 0 10px rgba(216,255,62,.10), 0 16px 44px rgba(216,255,62,.22);
  display: flex; align-items: center; justify-content: center; flex-direction: column; line-height: 1;
  transition: transform .12s ease;
}
.run-start-btn:active { transform: scale(.95); }
.run-start-btn small { font-size: 12px; font-weight: 800; opacity: .7; margin-top: 6px; letter-spacing: .12em; }

/* Quick stat strip */
.run-strip { display: flex; gap: 10px; }
.run-strip .stat {
  flex: 1; background: var(--fill-subtle); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.run-strip .stat .v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.run-strip .stat .k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; margin-top: 2px; }

/* Live in-run screen */
.run-live {
  background: radial-gradient(120% 80% at 50% -10%, rgba(216,255,62,.10), transparent 60%), var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
}
.run-live .run-live-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.run-live .run-gps { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.run-live .run-gps .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--volt); box-shadow: 0 0 8px var(--volt); animation: runpulse 1.6s infinite; }
.run-live.paused .run-gps .dot { background: var(--warn); box-shadow: none; animation: none; }
@keyframes runpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.run-live .run-distance {
  font-size: clamp(72px, 26vw, 116px); font-weight: 900; line-height: .9;
  font-variant-numeric: tabular-nums; letter-spacing: -.04em; text-align: center;
  color: var(--volt); margin: 6px 0 0;
}
.run-live .run-distance .unit { display: block; font-size: 14px; letter-spacing: .22em; text-transform: uppercase; color: var(--text-faint); margin-top: 8px; font-weight: 800; }
.run-metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin: 18px 0 4px; }
.run-metrics .m { text-align: center; padding: 8px 4px; }
.run-metrics .m .mv { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }
.run-metrics .m .mk { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; margin-top: 2px; }
.run-splits { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.run-splits .sp-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; font-variant-numeric: tabular-nums; }
.run-splits .sp-row .sp-km { font-weight: 800; color: var(--text-dim); }
.run-splits .sp-bar { height: 6px; border-radius: 3px; background: var(--volt); opacity: .8; }
.run-controls { display: flex; gap: 10px; margin-top: 18px; }
.run-controls button { flex: 1; border: 0; border-radius: 14px; padding: 16px; font-weight: 900; font-size: 15px; cursor: pointer; letter-spacing: .02em; }
.run-controls .pause { background: var(--bg-3); color: var(--text); }
.run-controls .stop { background: var(--volt); color: var(--volt-ink); }
.run-controls .discard { background: transparent; color: var(--bad); border: 1.5px solid var(--line); }

/* Post-run summary banner */
.run-summary { background: linear-gradient(160deg, rgba(216,255,62,.10), transparent), var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.run-summary .big { font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
@media (prefers-reduced-motion: reduce) { .run-live .run-gps .dot { animation: none; } .run-start-btn:active { transform: none; } }

/* ============================================================
   Onboarding — guided multi-step first run
   ============================================================ */
.welcome.ob { justify-content: flex-start; min-height: auto; padding: calc(var(--top) + 20px) 20px 40px; gap: 0; text-align: left; }
.ob-top { width: 100%; margin-bottom: 22px; }
.ob-bar { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.ob-bar > i { display: block; height: 100%; background: var(--accent-grad); border-radius: 3px; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.ob-step-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); font-weight: 800; margin-top: 8px; }
.ob-step { width: 100%; animation: obIn .28s cubic-bezier(.2,.8,.2,1); }
@keyframes obIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ob-title { font-size: 26px; line-height: 1.15; font-weight: 900; letter-spacing: -.02em; margin: 0 0 6px; }
.ob-sub { color: var(--text-dim); margin: 0 0 18px; font-size: 15px; line-height: 1.45; }
.ob-grid { display: flex; flex-direction: column; gap: 10px; }
.ob-option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px; border-radius: var(--radius); background: var(--bg-2);
  border: 1.5px solid var(--line); box-shadow: var(--card-hi); cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
}
.ob-option:active { transform: scale(.99); }
.ob-option[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(180deg, rgba(255,100,56,.10), transparent); }
.ob-icon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; background: var(--bg-3); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.ob-opt-label { font-weight: 700; font-size: 16px; }
.ob-opt-desc { color: var(--text-faint); font-size: 13px; margin-top: 2px; }
.ob-check { width: 24px; flex: 0 0 24px; text-align: center; color: var(--accent); font-weight: 900; }
.ob-chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-chip { padding: 9px 15px; border-radius: 999px; background: var(--bg-3); border: 1.5px solid var(--line); color: var(--text-dim); font-weight: 700; font-size: 13px; cursor: pointer; transition: all .15s; }
.ob-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ob-equip, .ob-subq { width: 100%; }
.ob-nav { display: flex; justify-content: flex-start; margin-top: 20px; }
.ob-hero { display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: center; min-height: 78vh; gap: 6px; }
.ob-hero .logo { margin-bottom: 10px; }
.ob-h1 { font-size: 40px; font-weight: 900; letter-spacing: -.03em; margin: 4px 0; }
.ob-tagline { color: var(--text-dim); font-size: 16px; line-height: 1.5; max-width: 320px; margin: 0 0 22px; }
.ob-hero .btn { max-width: 360px; }
.ob-celebrate { font-size: 44px; text-align: center; }
.ob-sum-row { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ob-sum-row:last-child { border-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .ob-step { animation: none; } .ob-bar > i { transition: none; } }

/* Today — premium greeting band + hero focal point */
.today-greet-left { min-width: 0; }
.today-hello { font-size: 26px; font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.today-sub { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.today-date { color: var(--text-dim); font-size: 13px; }
.streak-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 800; color: var(--accent); background: var(--fill-subtle); border: 1px solid var(--line); padding: 2px 9px; border-radius: 999px; }
.today-hero { background: linear-gradient(165deg, rgba(255,100,56,.12), transparent 62%), var(--bg-2); }
.today-hero-title { font-size: 30px; font-weight: 900; letter-spacing: -.02em; margin: 0; line-height: 1.05; }

/* Session-complete celebration overlay */
.session-done { position: fixed; inset: 0; z-index: 400; background: rgba(9,11,14,.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 24px; animation: sdFade .2s ease; }
@keyframes sdFade { from { opacity: 0; } to { opacity: 1; } }
.sd-card { width: 100%; max-width: 420px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 28px 22px calc(22px + env(safe-area-inset-bottom)); text-align: center; animation: sdPop .32s cubic-bezier(.2,.8,.2,1); }
@keyframes sdPop { from { transform: scale(.92) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.sd-emoji { font-size: 52px; line-height: 1; }
.sd-title { font-size: 26px; font-weight: 900; letter-spacing: -.02em; margin: 10px 0 4px; }
.sd-sub { color: var(--text-dim); margin: 0 0 18px; }
.sd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.sd-stat { background: var(--fill-subtle); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; }
.sd-v { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.sd-k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; margin-top: 3px; }
.sd-streak { color: var(--accent); font-weight: 800; margin-bottom: 14px; }
@media (prefers-reduced-motion: reduce) { .session-done, .sd-card { animation: none; } }

/* Secondary header subtitle used across screens */
.screen-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
