* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
}

body {
  font-family: var(--font-heading);
  color: var(--color-text);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
/* :not(.btn) -- a button-styled anchor (.btn-primary, .btn-outline, etc.) sets its own
   text color; this generic link-hover rule would otherwise beat it on specificity
   (a:hover is 0,1,1 vs .btn-primary's 0,1,0) and silently swap the text to
   --color-accent-hover -- which is also .btn-primary:hover's new background color,
   making the label invisible. See Greencard rsl -- reported via hovering "Try again"/
   "Back to Today"/"Connect with Strava". :not(.google-connect-btn) is the same fix --
   Google's brand color (#3c4043) must never swap to the site's green accent on hover. */
a:hover:not(.btn):not(.google-connect-btn) {
  color: var(--color-accent-hover);
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.page {
  min-height: 100vh;
  /* 100vh assumes browser chrome is fully hidden — mobile Safari's floating
     bottom toolbar sits on top of that, cutting off page-bottom content
     (e.g. the landing CTA button). 100dvh tracks the actually-visible
     viewport as the toolbar shows/hides. Kept vh above as a fallback for
     browsers predating dvh support (Safari <15.4) — this second
     declaration simply overrides it wherever dvh is understood. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-gradient);
}

.page-content {
  flex: 1;
  /* 24px baseline, growing only for a real device notch/status bar
     (env() is 0 in a normal browser tab) — the old flat 64px was
     padding for a notch that usually isn't there. Bottom padding
     keeps a page's last element clear of the tab bar below it — most
     pages already get that from .page-footer's own bottom padding,
     but a page that ends on a plain element (Settings) had nothing. */
  padding: max(24px, env(safe-area-inset-top)) var(--space-page-x) 24px;
  overflow: auto;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 8px 0 0;
}

.subtitle {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-top: 6px;
  line-height: 1.45;
}

.flash-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning-text);
  font-size: 13px;
  line-height: 1.4;
}

.flash-banner-success {
  background: var(--color-accent-bg-strong);
  border-color: rgba(204, 255, 51, 0.25);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  padding: 40px 20px;
}

.empty-icon-box {
  border-radius: 20px;
  border: 1.5px dashed var(--color-border-strong);
}

.status-bar {
  width: 6px;
  height: 38px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--color-border-strong);
}

.status-bar.is-done {
  background: var(--color-accent);
}

/* Cards */

.card {
  border: 1.5px solid var(--color-border);
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-dim {
  background: var(--color-card-dim);
  opacity: 0.72;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Buttons */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 54px;
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  width: 100%;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-border-strong);
  color: var(--color-text);
  font-weight: 600;
}

/* Wraps Strava's official "Connect with Strava" button asset (an SVG with its own
   pill background/padding baked in) -- must not get .btn/.btn-primary's own
   background, height or full-width sizing, or the brand asset would be distorted. */
.strava-connect-btn {
  display: inline-flex;
  line-height: 0;
}
.strava-connect-btn img {
  height: 48px;
  width: auto;
}

/* Google's brand guidelines require their own button style/colors -- white background,
   unmodified "G" mark -- so this can't reuse .btn/.btn-outline's dark-theme colors the
   way the Strava button (a self-contained SVG asset) doesn't need to either. Height
   matches strava-connect-btn's 48px so both sit flush in the same cta-footer row. */
.google-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px 0 14px;
  background: #ffffff;
  border: 1.5px solid #8a8f98;
  border-radius: var(--radius-md);
  color: #3c4043;
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
}
.google-connect-btn:hover {
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.btn-sm {
  height: auto;
  width: auto;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  gap: 6px;
}

.btn-danger-outline {
  background: transparent;
  border: 1.5px solid rgba(255, 107, 94, 0.3);
  color: var(--color-danger-text);
  font-weight: 600;
}

.page-footer {
  /* No horizontal padding — .page-content already applies var(--space-page-x), and
     every usage of this class was overriding it to 0 anyway. */
  padding: 14px 0 40px;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0) 0%, var(--color-surface) 30%);
  margin-top: auto;
}

/* Full-height hero layout (Landing, permission-required) */

.hero-page {
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px); /* see .page's comment on 100vh vs 100dvh */
  display: flex;
  flex-direction: column;
}

.cta-footer {
  padding: 48px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 340px;
}

.cta-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--color-text-dim);
  text-align: center;
  line-height: 1.6;
}

/* Onboarding flow-form layout (goal picker, equipment checklist) */

.onboarding-page {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 240px);
  min-height: calc(100dvh - 240px); /* see .page's comment on 100vh vs 100dvh */
}

/* Avatar — circular photo-or-icon container (Today header, Settings) */

.avatar {
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Settings row — linked card with an eyebrow label + value + chevron */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
}

.settings-row-value {
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

/* Selectable option rows (goal picker, equipment checklist) — native
   radio/checkbox inputs, visually hidden, styled via the sibling label so
   selection needs zero JS. */

.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.option-list.is-compact {
  gap: 8px;
}

.option-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-row {
  display: block;
  border: 1.5px solid var(--color-border);
  background: var(--color-card);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
}

.option-input:checked + .option-row {
  border-color: var(--color-accent);
  background: var(--color-accent-bg);
}

.option-input:disabled + .option-row {
  opacity: 0.4;
  cursor: not-allowed;
}

.option-row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 600;
}

.option-row-desc {
  font-size: 13.5px;
  color: var(--color-text-muted);
  margin-top: 6px;
  line-height: 1.45;
}

.option-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-strong);
  flex-shrink: 0;
}

.option-input:checked + .option-row .option-check {
  background: var(--color-accent);
  border-color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Compact row variant (equipment checklist) */

.option-row.is-compact {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
}

.option-row.is-compact .option-row-title {
  flex: 1;
  font-size: 16px;
}

.option-check.is-square {
  border-radius: var(--radius-xs);
}

/* Coach-decide card + focus-area grid (Today page body-part picker) */

.coach-decide-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px solid var(--color-border);
  background: var(--color-card);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
}

.option-input:checked + .coach-decide-card {
  border-color: var(--color-accent);
  background: var(--color-accent-bg);
}

.coach-decide-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent-bg-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.best-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #0a0a0b;
  background: var(--color-accent);
  border-radius: 999px;
  padding: 4px 10px;
  flex-shrink: 0;
}

.option-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.option-divider::before,
.option-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option-row.is-grid-tile {
  padding: 16px 14px;
}

.option-row.is-grid-tile .option-row-title {
  font-size: 15px;
}

.check-icon {
  display: none;
  flex-shrink: 0;
}

.option-input:checked + .option-row.is-grid-tile .option-row-title {
  color: var(--color-text);
  font-weight: 700;
}

.option-input:checked + .option-row.is-grid-tile .check-icon {
  display: inline-flex;
}

/* Pill button groups (reaction / difficulty) */

.pill-group {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.pill-label {
  flex: 1;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.option-input:checked + .pill-label {
  border: 1.5px solid var(--color-accent);
  background: var(--color-accent-bg-strong);
  color: var(--color-accent);
  font-weight: 600;
}

.option-input:checked + .pill-label.is-danger {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: var(--radius-xs);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-accent {
  background: var(--color-accent-bg-strong);
  border: 1px solid rgba(204, 255, 51, 0.25);
  color: var(--color-accent);
}
.badge-accent .badge-dot {
  background: var(--color-accent);
}

.badge-warning {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning-text);
}
.badge-warning .badge-dot {
  background: var(--color-warning-text);
}

.badge-neutral {
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
}

.feedback-row {
  margin: -4px 0 10px;
}

.feedback-status {
  font-weight: 600;
  color: var(--color-text-muted);
}

.feedback-status.is-hated {
  color: var(--color-danger-text);
}

.feedback-status.is-liked {
  color: var(--color-accent);
}

/* Stats */

.stat-row {
  display: flex;
  gap: 22px;
  margin-top: 12px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.stat-divider {
  width: 1px;
  background: var(--color-border);
}

/* Tab bar */

.tab-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 12px 24px 34px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--color-text-faint);
  transition: color 0.15s ease, background 0.15s ease;
}

.tab-item:hover {
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.tab-item.is-active {
  color: var(--color-accent);
  background: var(--color-accent-bg);
}

.tab-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
}

.nav-logo {
  /* Solid fill, not the dim tinted pill used for the active tab-item
     below — otherwise the logo reads as a second "active" nav item. */
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--color-accent);
  flex-shrink: 0;
}

/* ==========================================================================
   Utilities — small, composable, reused across pages instead of inline
   styles. Values here are drawn directly from what the templates actually
   use, not a speculative scale. Genuinely dynamic values (computed per
   request from data, or macro parameters like avatar()'s size/bg) are the
   one deliberate exception that still needs a real inline style — a static
   utility class can't express a value that isn't known until render time.
   ========================================================================== */

/* Display / flex */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 2px; }
.mt-3 { margin-top: 3px; }
.mt-6 { margin-top: 6px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-40 { margin-top: 40px; }
.mt-auto { margin-top: auto; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.pb-12 { padding-bottom: 12px; }
.pb-24 { padding-bottom: 24px; }
.px-4 { padding-left: 4px; padding-right: 4px; }
.overflow-auto { overflow: auto; }
.gap-2 { gap: 2px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-9 { gap: 9px; }
.gap-12 { gap: 12px; }
.gap-14 { gap: 14px; }

/* Font size / weight */
.fs-10 { font-size: 10px; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; }
.fs-15 { font-size: 15px; }
.fs-16 { font-size: 16px; }
.fs-17 { font-size: 17px; }
.fs-19 { font-size: 19px; }
.fs-20 { font-size: 20px; }
.fs-52 { font-size: 52px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* Text color / typography */
.text-default { color: var(--color-text); }
.text-muted { color: var(--color-text-muted); }
.text-dim { color: var(--color-text-dim); }
.text-faint { color: var(--color-text-faint); }
.text-accent { color: var(--color-accent); }
.text-inherit { color: inherit; }
.text-center { text-align: center; }
.no-underline { text-decoration: none; }
.font-mono { font-family: var(--font-mono); }
.leading-tight { line-height: 0.95; }
.leading-snug { line-height: 1.4; }
.leading-normal { line-height: 1.5; }
.tracking-tight { letter-spacing: -1px; }
.tracking-wide { letter-spacing: 0.5px; }
.tracking-wider { letter-spacing: 1px; }

/* Sizing */
.w-32 { width: 32px; }
.h-32 { height: 32px; }
.w-64 { width: 64px; }
.h-64 { height: 64px; }
.bg-accent-strong { background: var(--color-accent-bg-strong); }
.min-w-0 { min-width: 0; }
.max-w-280 { max-width: 280px; }
.max-w-340 { max-width: 340px; }
.max-w-380 { max-width: 380px; }
.max-w-420 { max-width: 420px; }
.max-w-640 { max-width: 640px; }
.max-w-760 { max-width: 760px; }

/* ==========================================================================
   Hover states — mobile is a touch surface with none of these, but every
   pointer-driven surface (desktop, and mobile web with a mouse/trackpad)
   was missing feedback on anything clickable.
   ========================================================================== */

.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-outline:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-bg);
}

.btn-danger-outline:hover {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

a.card:hover,
.settings-row:hover {
  border-color: var(--color-border-strong);
  background: var(--color-card-dim);
}

.coach-decide-card:hover,
.option-row:hover {
  border-color: var(--color-border-strong);
}

/* ==========================================================================
   Desktop layout — the app was built mobile-first with no wide-viewport
   treatment at all: full-bleed content, a bottom tab bar sized for thumb
   reach, and full-width buttons. Below the breakpoint, none of this
   applies and the mobile PWA is pixel-identical to before.
   ========================================================================== */

.today-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.landing-copy {
  display: contents;
}

.landing-preview {
  display: none;
}

.landing-preview::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(204, 255, 51, 0.14) 0%, rgba(204, 255, 51, 0) 70%);
}

.landing-preview-card {
  position: relative;
  width: 340px;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.5);
}

@media (min-width: 900px) {
  /* No auto-centering: content should sit flush against the nav rail,
     not float centered in whatever space is left on a wide screen. */
  .page-content {
    max-width: 1160px;
  }

  /* The "flush against the rail" reasoning above only holds when there
     is a rail. Landing/Privacy/permission-required/auth-declined have
     no .tab-bar, so without this they inherit the same flush-left
     behavior and just stick to the left edge with dead space on the
     right on a wide screen. Center them instead. */
  .page:not(:has(.tab-bar)) .page-content {
    margin: 0 auto;
  }

  /* 64px of breathing room after the rail, not the 20px mobile edge
     padding — flush against the rail read as cluttered. Top padding
     matches the rail's own 28px top padding so the page title sits
     parallel to the logo instead of floating lower. */
  .page:has(.tab-bar) .page-content {
    padding-left: calc(84px + 64px);
    padding-top: 28px;
  }

  .tab-bar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84px;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 28px 0;
    border-top: none;
    border-right: 1px solid var(--color-border);
    z-index: 10;
  }

  .nav-logo {
    display: flex;
    margin-bottom: 20px;
  }

  /* Redundant with the rail's own Settings icon on desktop — mobile
     keeps it since the avatar is the only settings entry point there. */
  .today-avatar {
    display: none;
  }

  .btn {
    width: auto;
    padding: 0 28px;
  }

  /* Today — main workflow column + sticky running-load sidebar. DOM order
     is sidebar-then-main (matches the mobile stacking order); `order`
     only repositions them visually once there's a row to position within. */
  .today-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
  }

  .option-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .today-sidebar {
    width: 360px;
    flex-shrink: 0;
    order: 2;
    position: sticky;
    top: 32px;
  }

  .today-main {
    order: 1;
    flex: 1;
    min-width: 0;
  }

  .exercise-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .exercise-list .card {
    margin-bottom: 0;
  }

  /* The bottom-fade gradient exists to blend a fixed mobile footer over
     scrolling content underneath it — in normal desktop flow there's
     nothing to fade into, so it reads as a stray dark box. */
  .today-main .page-footer,
  .onboarding-page .page-footer {
    background: none;
    padding-bottom: 0;
  }

  /* min-height: calc(100vh - 240px) exists to pin the continue/generate
     button near the bottom of a phone screen for thumb reach — on
     desktop it just strands the button far below short content lists,
     so let the form size to its content instead. */
  .onboarding-page {
    min-height: 0;
  }

  /* Landing — two-column hero. `.landing-copy` is `display: contents`
     below this breakpoint so it doesn't affect the existing mobile
     single-column stacking at all. */
  .landing-hero {
    flex-direction: row;
    align-items: center;
    gap: 64px;
  }

  .landing-copy {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-height: 60vh;
  }

  .landing-preview {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
  }
}

/* "View on Strava" link-back. Strava's brand guidelines: when linking to original Strava
   data, the text must read exactly "View on Strava" and be identifiable as a link by bold
   weight, underline, or orange #FC5200. Used wherever the app links out to Strava. */
.strava-view-link {
  color: #FC5200;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
