/* ══════════════════════════════════════
   SOMAPSYCHE — Design System & All Styles
   Brand system (shared with theworks): warm cream background,
   coral primary + teal/amber/green secondary accents, JetBrains
   Mono structural + Atkinson Hyperlegible Next reading font.
   No purples.
   ══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible+Next:wght@400;700&family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

:root {
  /* Fonts — shared with theworks */
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  --font-sans: 'Atkinson Hyperlegible Next', system-ui, sans-serif;

  /* ══════════════════════════════════════
     SOMAPSYCHE PALETTE — contrast-checked
     Every foreground / background pair below meets WCAG AA (4.5:1 for
     body text, 3:1 for large text / UI chrome). Ratios verified vs
     --bg-base: #FAF8F4.
     ══════════════════════════════════════ */

  /* Surfaces — warm cream ladder */
  --bg-base: #FAF8F4;       /* warm cream — page background */
  --bg-surface: #F2EFE8;    /* one step warmer — card chrome */
  --bg-overlay: #E8E4DC;    /* two steps — hover state */
  --bg-inset: #FFFFFF;      /* pure white — form inputs, sheet */
  --border: #D1CCBF;        /* low-contrast grid line (was #DDD9D0) */
  --border-muted: #B8B2A3;  /* darker border for focus states */

  /* Text — AA/AAA ladder on --bg-base */
  --text-primary:   #1A1917; /* ~17:1 — near-black, body text */
  --text-secondary: #4A4640; /* ~8.1:1 — subdued body, was #5C5850 */
  --text-tertiary:  #6E6A62; /* ~4.8:1 — hints, dates (was #9A958C at 2.7:1 — FAILED) */

  /* Primary accent — coral, warm earth tone */
  --accent:          #C86840;           /* 3.9:1 on cream — large text / UI chrome only */
  --accent-muted:    rgba(200, 104, 64, 0.10);
  --accent-dark:     #8E3A1F;           /* 6.5:1 on cream — body text, links */
  --accent-light:    #F0997B;           /* decorative only; 2.3:1 on cream — NOT for text */
  --accent-on-accent: #FFFFFF;          /* 4.8:1 on accent — button label */

  /* Legacy --purple-* tokens kept for backwards compat with the existing
     layout CSS, now pointing entirely at the coral accent. */
  --purple:       var(--accent-dark);   /* text-safe coral */
  --purple-light: var(--accent);
  --purple-bg:    rgba(200, 104, 64, 0.08);

  /* Secondary status colors — all AA on cream, paired with tint backgrounds */
  --teal:     #1F7A5C;      /* 5.0:1 — training progress (was #30A880 at 3.1:1) */
  --teal-bg:  #E3F2EA;

  --amber:    #8B6A1A;      /* 5.3:1 — intensity / warnings (was #B08830 at 3.4:1) */
  --amber-bg: #F8F0DB;

  --red:      #9A2E2E;      /* 6.3:1 — cancel / danger (was #B84040 at 4.6:1 — OK but darker for stronger signal) */
  --red-muted: rgba(154, 46, 46, 0.10);

  --green:    #2E8050;      /* 5.1:1 — success / completed (was #58A038 at 3.1:1) */
  --green-bg: #E5F1E8;

  /* Legacy grayscale aliases (keep existing layout selectors working) */
  --gray-bg: var(--bg-surface);
  --gray-light: var(--bg-overlay);
  --gray-border: var(--border);
  --white: var(--bg-inset);

  /* Geometry */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-pill: 9999px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Let the SPA's window scroll work ──
   Kit's tokens.css sets `html, body { overflow: hidden; height:
   100dvh }` + `body { display: flex; flex-direction: column }`.
   That makes <main> the scroll container — which the SPA's JS cannot
   use: it listens on window scroll and calls window.scrollTo.
   Release the viewport-fixed rules so the window is the one and only
   scroll container, matching the standalone SPA before kit adoption.
   Unscoped html/body rules are safe — this stylesheet only loads on
   the somapsyche app. */
html {
    overflow: visible;
    height: auto;
}
body.somapsyche-app {
    overflow-x: hidden;  /* keep SPA's horizontal clip */
    overflow-y: visible; /* let the window scroll vertically */
    height: auto;
    min-height: 100dvh;
    display: block;      /* kit set this to flex-column; SPA wants block */
}

/* ── No horizontal scroll on phone, ever.
   Belt-and-suspenders: clip at every container so any content that
   pokes past the viewport edge (stray inline style, third-party
   widget, oversized image) is trimmed instead of scrolling sideways. */
@media (max-width: 1023px) {
    body.somapsyche-app #app,
    body.somapsyche-app .page,
    body.somapsyche-app .page-no-nav {
        overflow-x: hidden;
        max-width: 100%;
    }
    body.somapsyche-app img,
    body.somapsyche-app video {
        max-width: 100%;
        height: auto;
    }
}

/* ── Phone landscape — discourage rotation, keep users in portrait.
   iPad landscape (viewport ≥ 1024px) gets the desktop layout per
   the @media (min-width: 1024px) block elsewhere. Phone landscape
   (viewport < 900px) shows a full-screen "rotate to portrait" message
   so users don't get a broken squished layout. */
@media (orientation: landscape) and (max-width: 900px) {
    body.somapsyche-app::before {
        content: "↻  Rotate to portrait";
        position: fixed;
        inset: 0;
        background: var(--bg-base);
        color: var(--accent-dark);
        font-family: var(--font-mono);
        font-size: 18px;
        letter-spacing: 0.5px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        z-index: 9999;
        padding: 24px;
    }
}

/* ── Kit <main> passthrough for somapsyche SPA ──
   Even after releasing html/body, kit's @media rules set <main> to
   flex: 1; overflow-y: auto on both breakpoints, making main its
   own nested scroll container. Drain those on the SPA so there's
   one scroll container (window) and window.scrollTo / window
   scroll listeners work as the SPA expects. */
body.somapsyche-app main {
    padding: 0;
    max-width: none;
    margin: 0;
    display: block;
    flex: 0 0 auto;      /* opt out of kit's flex:1 stretch */
    min-height: auto;
    overflow: visible;   /* let window handle scroll, not main */
}
body.somapsyche-app main::after {
    display: none;  /* kit's bottom-nav clearance — SPA owns its own */
}

/* ── Map somapsyche palette onto kit tokens ──
   Kit components (header, buttons, inputs, login-form, modal, tooltip)
   read --bg, --bg-card, --ink, --accent etc. The kit's base-shell.html
   sets `data-theme="dark"` on <html> by default, and the kit's
   tokens.css overrides --accent inside `:root[data-theme="dark"]` (a
   HIGHER-specificity selector than the plain `:root` somapsyche's
   tokens live in above). So we have to write the somapsyche palette
   at the same high specificity here, with LITERAL color values — never
   `var(--accent)` self-referencing (that's circular and resolves to
   nothing → transparent button → invisible white text on white page,
   which was the "Sign in" bug). */
:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
    /* Surfaces */
    --bg:            #FAF8F4;
    --bg-raised:     #E8E4DC;
    --bg-card:       #F2EFE8;
    --bg-input:      #FFFFFF;
    /* Text */
    --ink:           #1A1917;
    --ink-soft:      #4A4640;
    --ink-faint:     #6E6A62;
    /* Borders */
    --border:        #D1CCBF;
    --border-light:  #B8B2A3;
    /* Accent — coral. Hex literals (not var refs) so they win the cascade. */
    --accent:        #C86840;
    --accent-light:  #F0997B;
    --accent-muted:  rgba(200, 104, 64, 0.10);
    --accent-text:   #8E3A1F;
    /* Semantic */
    --red:           #9A2E2E;
    --red-muted:     rgba(154, 46, 46, 0.10);
}

/* ── Brand mark (lockup): SomaPsyche_ cursor — used in login + header ── */

.brand-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: var(--accent);
  line-height: 1;
}
.brand-text {
  display: inline-block;
}
.brand-cursor {
  display: inline-block;
  width: 10px;
  height: 3px;
  background: currentColor;
  border-radius: 1px;
  animation: cursor-blink 1.2s ease-in-out infinite;
  margin-left: 2px;   /* small breath after the "e" */
  margin-bottom: 2px;
}
@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ── Auth / login page ── */

body.auth-page {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  margin: 0;
  padding: 24px;
}
.auth-container {
  width: 100%;
  max-width: 380px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}
.auth-form {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.auth-heading {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.auth-error {
  background: var(--red-muted);
  color: var(--red);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-family: var(--font-mono);
}
.auth-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 16px;
}
.auth-label:first-of-type { margin-top: 0; }
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
}
.auth-remember input { accent-color: var(--accent); }
.auth-button {
  width: 100%;
  background: var(--accent);
  color: var(--accent-on-accent);
  border: 0;
  padding: 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  margin-top: 22px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.auth-button:active { background: var(--accent-dark); }
.auth-button:hover  { background: var(--accent-dark); }

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  height: 100%;
  overflow-x: hidden;       /* belt: never allow horizontal scroll */
  overscroll-behavior: none; /* suppress iOS rubber-band chaining */
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);   /* warm cream — same as login */
  color: var(--text-primary);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ══════════════════════════════════════
   TABLET (500 – 1023px) — iPhone-style device frame preview
   The SPA is fundamentally phone-shaped, so at tablet widths we show
   it inside a device-frame mockup (bezel, notch, home indicator) so
   the phone design doesn't look cramped. On real desktops (≥1024px)
   we drop the frame entirely — see the block further down that uses
   the kit's desktop shell.
   ══════════════════════════════════════ */
@media (min-width: 500px) and (max-width: 1023px) {
  html {
    background: var(--bg-surface);
    min-height: 100dvh;
    overflow-x: hidden;
  }
  html::before {
    /* Brand watermark top-left */
    content: "SomaPsyche_";
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: -0.3px;
    position: fixed;
    top: 24px;
    left: 32px;
    z-index: 0;
    opacity: 0.9;
  }
  html::after {
    content: "desktop preview · install as a PWA on your phone for the real experience";
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.2px;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 0;
    opacity: 0.65;
    white-space: nowrap;
  }

  body {
    /* Body becomes the phone bezel */
    width: 414px;
    max-width: 414px;
    min-height: 840px;
    max-height: calc(100dvh - 64px);
    margin: 32px auto;
    padding: 14px 13px 13px 13px;
    background:
      linear-gradient(155deg, #2A2622 0%, #16140F 55%, #0A0908 100%);
    border-radius: 54px;
    border: none;
    overflow: visible;
    position: relative;
    box-shadow:
      0 60px 100px -30px rgba(26, 25, 23, 0.35),
      0 40px 80px -20px rgba(200, 104, 64, 0.15),
      0 0 0 1px rgba(255, 255, 255, 0.06) inset,
      0 1px 0 rgba(255, 255, 255, 0.08) inset;
    display: flex;
    flex-direction: column;
    z-index: 1;
  }

  /* Notch (iPhone-style Dynamic Island pill) */
  body::before {
    content: "";
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 118px;
    height: 32px;
    background: #05040A;
    border-radius: 20px;
    z-index: 20;
    box-shadow: inset 0 0 2px rgba(0,0,0,0.8);
  }

  /* Home indicator (iOS bar) */
  body::after {
    content: "";
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 130px;
    height: 4px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 3px;
    z-index: 20;
  }

  /* The #app div is the actual "screen" — the phone's display */
  #app {
    flex: 1;
    background: var(--bg-base);
    border-radius: 42px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    min-height: 0;
    padding-top: 42px;   /* breathing space below the notch */
    padding-bottom: 18px;
    -webkit-overflow-scrolling: touch;
  }
  #app::-webkit-scrollbar { display: none; }
  #app { scrollbar-width: none; }

  /* Bottom nav inside the screen, not the viewport */
  .bottom-nav {
    position: sticky;
    bottom: 0;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: none;
    margin-top: auto;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    padding-bottom: 14px;
  }
  .page { padding-bottom: 16px; }
}

/* Really wide tablet-range screens: breathing room around the mockup */
@media (min-width: 900px) and (max-width: 1023px) {
  body { margin: 48px auto; }
}

/* ══════════════════════════════════════
   DESKTOP (≥1024px) — kit shell, no phone frame
   The SPA drops the device-frame mockup and uses the denovo-kit
   layout instead: header at top with top-nav, content centered in a
   1000px-max column, mobile .bottom-nav hidden. Mobile markup + JS
   are unchanged — this is pure CSS.
   ══════════════════════════════════════ */
@media (min-width: 1024px) {
    /* Reset the phone-mockup background/frame. body becomes a normal
       flex column owning the viewport. Kit's own layout-desktop.css
       handles <header> visibility + <footer> hiding; we just need to
       undo the body cap + frame styling from the base 430px rule. */
    html {
        background: var(--bg-base);
        overflow: visible;
    }
    html::before,
    html::after {
        display: none;
    }
    body {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0;
        background: var(--bg-base);
        border: none;
        border-radius: 0;
        box-shadow: none;
        min-height: 100dvh;
        max-height: none;
        overflow: visible;
        display: flex;
        flex-direction: column;
    }
    body::before,
    body::after {
        display: none;
    }
    /* #app becomes the kit content column. The SPA's internal pages
       paint into here without any frame or rounded screen. */
    #app {
        background: var(--bg-base);
        border-radius: 0;
        max-width: 1000px;
        margin: 0 auto;
        width: 100%;
        padding: 16px 24px 24px;
        flex: 1;
        overflow: visible;
    }
    /* The SPA's internal bottom-nav is not used on desktop — the kit's
       desktop header already exposes Today / Training / You. */
    .bottom-nav { display: none !important; }
    /* Our desktop top-nav lives in the kit <header> (see index.html).
       Make sure it's visible on desktop — the mobile rule below hides
       it. */
    .sp-desktop-nav { display: flex; }
    /* The SPA's .page was padded 80px at bottom to clear the bottom-
       nav. On desktop the nav is gone, reclaim that space. */
    .page { padding-bottom: 24px; }
}

/* ── Desktop top-nav (rendered inside kit <header>) ── */
.sp-desktop-nav {
    /* Shown ≥1024px via the .sp-desktop-nav { display: flex } rule
       inside the desktop media query above. Hidden on mobile via
       the rule below (scoped to < 1024px so the mobile rule doesn't
       undo the desktop rule in the cascade). */
    gap: 4px;
    align-items: center;
    margin-left: auto;
}
@media (max-width: 1023px) {
    .sp-desktop-nav { display: none; }
}
.sp-desktop-nav a {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.sp-desktop-nav a:hover {
    background: var(--accent-muted);
    color: var(--accent-dark);
}
.sp-desktop-nav a.active {
    color: var(--accent-dark);
    background: var(--accent-muted);
}
.sp-desktop-logout {
    color: var(--text-tertiary) !important;
    margin-left: 12px;
    border-left: 1px solid var(--border);
    padding-left: 16px !important;
    border-radius: 0 !important;
}
.sp-desktop-logout:hover {
    color: var(--accent-dark) !important;
    background: transparent !important;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--purple); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--white);
  border-top: 1px solid var(--gray-border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 20;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg { color: var(--text-secondary); }
.nav-label { font-size: 10px; color: var(--text-secondary); }
.nav-item.active svg { color: var(--purple); }
.nav-item.active .nav-label { color: var(--purple); }

/* ── Page Container ── */
.page { padding-bottom: 80px; flex: 1; animation: page-in 140ms ease-out both; }
.page-no-nav { animation: page-in 140ms ease-out both; }
/* Opacity-only — animating `transform` on .page promotes its descendants
 * (including position:fixed .bottom-nav) into the same containing block,
 * which makes the fixed nav scroll with the page. Keep it as a simple
 * fade. */
@keyframes page-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Tap feedback — instant visual ACK on any tappable surface. Without
 * this, iOS Safari adds a ~300 ms delay before any :hover/:active style
 * fires and taps feel laggy. */
.exercise-row:active, .workout-card-hero:active, .start-btn:active,
.menu-row:active, .timeline-workout-card:active, .nav-item:active,
.history-month-header:active, .form-btn:active, .dialog-btn-primary:active,
.dialog-btn-danger:active, .dialog-link:active {
  opacity: 0.7;
  transform: scale(0.985);
  transition: opacity 60ms linear, transform 60ms linear;
}
.page-no-nav { flex: 1; display: flex; flex-direction: column; }

/* ══════════════════
   HOME PAGE
   ══════════════════ */
.header { padding: calc(16px + var(--safe-top)) 20px 0; }
.date-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--amber); letter-spacing: 0.5px;
}
.greeting {
  font-size: 28px; font-weight: 700; color: var(--text-primary); margin-top: 4px;
}
.motivation {
  font-size: 16px; font-weight: 600; color: var(--text-primary); padding: 12px 20px 0;
}

/* Workout Card */
.workout-card-hero {
  margin: 12px 20px 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--purple-light) 0%, var(--accent-dark) 100%);
  padding: 24px 20px 48px; position: relative; overflow: hidden;
}
.workout-card-hero::before {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 160px; height: 160px; background: rgba(255,255,255,0.08);
  transform: rotate(45deg); border-radius: 20px;
}
.card-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: rgba(255,255,255,0.7); letter-spacing: 1px;
}
.card-title {
  font-size: 22px; font-weight: 700; color: white; margin-top: 6px;
}

/* Rest Card */
.rest-card {
  margin: 16px 20px 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-dark) 0%, #5C2812 100%);
  padding: 24px 20px; position: relative; overflow: hidden;
}
.rest-card::before {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 140px; height: 140px; background: rgba(255,255,255,0.04);
  transform: rotate(45deg); border-radius: 16px;
}
.rest-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: rgba(255,255,255,0.6); letter-spacing: 1px;
}
.rest-title { font-size: 18px; font-weight: 700; color: white; margin-top: 6px; }
.rest-subtitle { font-size: 14px; color: rgba(255,255,255,0.7); margin-top: 6px; }

/* Start Button */
.start-btn-container {
  display: flex; justify-content: center; margin-top: -22px;
  position: relative; z-index: 2;
}
.start-btn {
  background: var(--white); color: var(--purple); border: none; border-radius: 25px;
  padding: 12px 32px; font-size: 16px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Tasks */
.tasks-section { padding: 24px 20px 0; }
.tasks-header { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.task-row {
  display: flex; align-items: center; padding: 14px 0;
  border-bottom: 1px solid var(--gray-border);
}
.task-icon {
  width: 40px; height: 40px; background: var(--gray-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--text-secondary);
}
.task-info { flex: 1; margin-left: 12px; min-width: 0; }
.task-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.task-workout-name {
  font-size: 13px; color: var(--text-secondary); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-date { font-size: 13px; color: var(--red); margin-top: 2px; }
.form-btn {
  background: none; border: 2px solid var(--purple); color: var(--purple);
  border-radius: 20px; padding: 6px 16px; font-size: 14px; font-weight: 600;
  white-space: nowrap;
}
.task-row.task-completed { opacity: 0.5; }
.task-row.task-completed .task-title { text-decoration: line-through; }
.task-row.task-missed .task-icon { background: #FDEAEA; color: var(--red); }
.missed-tag {
  display: inline-block; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  letter-spacing: 0.5px; vertical-align: middle;
}
.task-done-check { color: var(--green); flex-shrink: 0; }
.task-message-content {
  padding: 24px 20px; flex: 1;
}
.task-message-text {
  font-size: 16px; line-height: 1.6; color: var(--text-primary);
  white-space: pre-wrap;
}

/* ══════════════════
   TRAINING CALENDAR
   Single-scroll inner pattern: .page--calendar is a fixed-height flex
   column. .cal-top stays pinned at the top (flex-shrink: 0), .cal-body
   is the one scroll container for the weeks list. Works identically
   on mobile (window fills viewport) and desktop (sits inside kit's
   <main> column at the remaining viewport-height after the kit header).
   CSS vars below adjust the available height per breakpoint. */
:root {
    --cal-top-offset:    0px;  /* reserved space above .page--calendar */
    --cal-bottom-offset: 0px;  /* reserved space below */
}
@media (max-width: 1023px) {
    /* SPA .bottom-nav ≈ 40px + 16px padding + iOS safe-area inset. */
    :root { --cal-bottom-offset: calc(56px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 1024px) {
    /* Kit desktop <header> (~100px) + #app top padding (16px) +
       small breathing buffer. If the kit header ever changes height
       significantly this is the one number to retune. */
    :root { --cal-top-offset: 124px; }
}
.page--calendar {
    height: calc(100dvh - var(--cal-top-offset) - var(--cal-bottom-offset));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;           /* override base .page padding */
    flex: 0 0 auto;
}
.cal-top {
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    background: var(--bg-inset);
}
.cal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Legacy alias — old markup used .cal-sticky-top + .workout-list.
   Keep the selectors defined so any stale render path still has CSS,
   but the new markup uses .cal-top + .cal-body above. */
.cal-sticky-top {
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    background: var(--bg-inset);
}
.cal-header {
  background: var(--bg-inset); padding: calc(16px + var(--safe-top)) 20px 0;
}
.cal-header-top {
  display: flex; align-items: center; justify-content: space-between;
}
.back-arrow {
  font-size: 28px; color: var(--text-primary); cursor: pointer;
  line-height: 1; background: none; border: none; padding: 0;
}
/* Legacy variant — kept as an alias so existing markup still works,
   but rendered in the same dark color as the default so every deeper-
   page back button matches the /#history style (user request). */
.back-arrow-white { color: var(--text-primary); }
.page-title {
  font-size: 28px; font-weight: 700; color: var(--text-primary);
  margin-top: 8px; padding-bottom: 16px;
}

/* Week Navigation */
.week-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0 12px;
}
.week-arrow {
  font-size: 28px; color: var(--purple); cursor: pointer;
  background: none; border: none; padding: 0 8px;
  line-height: 1; font-weight: 600;
}
.week-label {
  font-size: 15px; font-weight: 600; color: var(--text-secondary);
  text-align: center;
}

.calendar-strip { background: var(--bg-overlay); padding: 12px 20px; }
.cal-days { display: flex; justify-content: space-between; text-align: center; }
.cal-day {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; width: 40px;
}
.cal-day-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-secondary);
}
.cal-day-num {
  font-size: 18px; font-weight: 700; color: var(--text-secondary);
  width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; border-radius: 50%;
}
.cal-day.today .cal-day-label,
.cal-day.today .cal-day-num { color: var(--purple); }
.cal-day.scheduled .cal-day-num { border: 2px solid var(--purple); color: var(--text-primary); }
.cal-day.completed .cal-day-num { background: var(--green); color: white; border: none; }
.cal-day.missed .cal-day-num { border: 2px solid var(--red); color: var(--text-primary); }

.workout-list { padding: 0; }
.day-row {
  display: flex; align-items: flex-start; padding: 20px;
  border-bottom: 1px solid var(--gray-border); background: var(--white);
  min-height: 80px; flex-wrap: wrap; gap: 8px 0;
}
.day-row .workout-card-cal { flex: 1; min-width: calc(100% - 68px); margin-left: 8px; cursor: pointer; }
.day-row .workout-card-cal + .workout-card-cal { margin-left: 68px; }
.day-info { width: 60px; flex-shrink: 0; }
.day-abbr {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-secondary);
}
.day-num-big { font-size: 22px; font-weight: 700; color: var(--text-secondary); }
.day-row.today .day-abbr,
.day-row.today .day-num-big { color: var(--purple); }
.day-row.has-workout { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.workout-card-cal {
  flex: 1; background: var(--bg-surface); border-radius: 10px;
  padding: 14px 16px; margin-left: 8px;
}
.workout-name-cal { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.workout-exercises-cal { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* Completed workout in calendar */
.workout-card-cal.completed {
  background: #E8F5E9; border-left: 3px solid var(--green);
}

/* Missed workout in calendar */
.workout-card-cal.missed {
  background: #FFF3F0; border-left: 3px solid #E53935;
}
.missed-label { color: #E53935; font-weight: 600; }
.cal-day.missed .cal-day-num { color: #E53935; }

/* ── Rearrange Page ── */
.rearrange-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 20px 16px;
  position: sticky; top: 0; z-index: 10; background: var(--white);
}
.rearrange-title { font-size: 20px; font-weight: 700; text-align: center; }
.rearrange-list { padding: 0 20px; }
.rearrange-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0; border-bottom: 1px solid #E8E8E8;
  min-height: 60px; transition: background 0.15s;
}
.rearrange-row.today .day-abbr,
.rearrange-row.today .day-num-big { color: var(--purple); }
.rearrange-row.drag-over {
  background: var(--purple-bg);
  border: 2px dashed var(--purple);
  border-radius: 10px;
  margin: -2px 0;
}
.rearrange-row.past { opacity: 0.45; }
.rearrange-cards {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
}
.rearrange-empty-slot {
  min-height: 20px;
}
.week-separator {
  padding: 18px 20px 8px;
  font-size: 13px; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-border);
}
.scroll-sentinel { height: 1px; }
#cal-weeks > * { overflow-anchor: none; }
.rearrange-card {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-surface); border-radius: 8px; padding: 14px 16px;
}
.rearrange-card.locked { opacity: 0.5; }
.rearrange-card-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.drag-handle { cursor: grab; padding: 8px 12px; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.drag-ghost {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--bg-surface); border-radius: 8px; padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); opacity: 0.9;
  display: flex; align-items: center; justify-content: space-between;
}
.drag-origin { opacity: 0.3; }

/* ── Bottom Sheet Dialogs ── */
.dialog-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s;
}
.dialog-sheet {
  background: white; border-radius: 16px 16px 0 0;
  padding: 16px 24px calc(24px + var(--safe-bottom));
  width: 100%; max-width: 430px; text-align: center;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dialog-chevron { text-align: left; font-size: 24px; color: var(--text-secondary); cursor: pointer; margin-bottom: 8px; }
.dialog-icon-warn { font-size: 40px; margin-bottom: 12px; }
.dialog-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.dialog-message { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; }
.dialog-btn-danger {
  width: 100%; padding: 14px; border: none; border-radius: 25px;
  background: var(--red); color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; margin-bottom: 12px;
}
.dialog-btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 25px;
  background: var(--purple); color: white; font-size: 16px; font-weight: 700;
  cursor: pointer; margin-bottom: 12px;
}
.dialog-link { font-size: 14px; font-weight: 600; color: var(--purple); cursor: pointer; padding: 8px; }

/* ── Done Button (active workout) ── */
.done-btn {
  background: var(--purple); color: white; border: none; border-radius: 25px;
  padding: 10px 32px; font-size: 16px; font-weight: 700; cursor: pointer;
}

/* ── Finish Page (last dot) ── */
.finish-page-content {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 40px 24px;
}
.finish-icon { margin-bottom: 24px; }
.finish-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.finish-stats { font-size: 16px; color: var(--text-secondary); margin-bottom: 12px; }
.finish-warning { font-size: 14px; color: var(--amber); margin-bottom: 24px; }
.finish-great { font-size: 14px; color: var(--green); margin-bottom: 24px; }
.finish-done-btn { padding: 14px 48px; font-size: 18px; }
.dot-finish { background: var(--purple) !important; width: 10px !important; height: 10px !important; }
.dot-section { width: 3px !important; height: 10px !important; border-radius: 2px !important; }

/* ── Completed hero card (home) ── */
.completed-hero { background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%) !important; }
.completed-hero .card-label { color: rgba(255,255,255,0.9); }
.card-check { margin-top: 8px; }
.card-check svg { stroke: white; width: 28px; height: 28px; }

/* ══════════════════════
   WORKOUT OVERVIEW
   ══════════════════════ */
/* Workout detail header — cream with dark text so back arrow reads
   like the /#history page. Coral gradient dropped per user request
   for consistency across deeper pages. */
.wo-header {
  background: var(--white);
  padding: calc(16px + var(--safe-top)) 20px 24px;
  position: relative;
  border-bottom: 1px solid var(--gray-border);
}
.wo-header::before { display: none; }
.wo-header-top {
  display: flex; align-items: center; justify-content: space-between;
}
.wo-date-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--accent); letter-spacing: 1px; margin-top: 16px;
}
.wo-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }

.wo-start-container {
  display: flex; justify-content: center; margin-top: -22px;
  position: relative; z-index: 2; padding: 0 20px;
}
.wo-start-btn {
  background: var(--white); color: var(--purple); border: 2px solid var(--purple);
  border-radius: 25px; padding: 12px 0; font-size: 16px; font-weight: 600;
  width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Completed workout actions */
.wo-completed-actions {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-top: -22px; position: relative; z-index: 2; padding: 0 20px;
}
.wo-completed-badge {
  background: #E8F5E9; color: var(--green); font-weight: 700;
  font-size: 14px; padding: 6px 20px; border-radius: 20px;
  margin-bottom: 4px;
}
.wo-edit-btn {
  background: var(--white); color: var(--purple); border: 2px solid var(--purple);
  border-radius: 25px; padding: 12px 0; font-size: 16px; font-weight: 600;
  width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.wo-cancel-btn {
  background: none; border: none; color: #E53935; font-size: 14px;
  font-weight: 600; padding: 8px 0; cursor: pointer;
}

/* Equipment */
.equipment-section { padding: 20px 20px 0; }
.equipment-label { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.equipment-chips { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.chip {
  background: var(--gray-light); border-radius: 20px; padding: 6px 14px;
  font-size: 13px; color: var(--text-primary);
}

/* Section */
.section { padding: 24px 20px 0; }
.section-header { display: flex; align-items: center; gap: 10px; }
.section-dot {
  width: 8px; height: 8px; background: var(--purple);
  border-radius: 50%; flex-shrink: 0;
}
.section-title {
  font-size: 18px; font-weight: 700; color: var(--text-primary); flex: 1;
}

/* Exercise Row */
.exercise-row {
  display: flex; align-items: center; padding: 12px 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.exercise-thumb {
  width: 50px; height: 50px; background: #fff; border-radius: 6px;
  border: 1px solid var(--gray-border, rgba(0,0,0,0.08));
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.exercise-thumb video,
.exercise-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.play-icon {
  width: 22px; height: 22px; background: rgba(255,255,255,0.9);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.play-icon svg { color: var(--purple); }
.exercise-info { flex: 1; margin-left: 12px; }
.exercise-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.exercise-prescription { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.exercise-sets { font-size: 14px; color: var(--text-secondary); flex-shrink: 0; margin-left: 8px; }

/* Superset label */
.superset-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #AAAAAA; letter-spacing: 0.5px; padding-top: 16px; padding-bottom: 4px;
}
.superset-group {
  border-bottom: 1px solid var(--gray-border);
  padding-bottom: 4px; margin-bottom: 4px;
}
.superset-group:last-child { border-bottom: none; }

/* ══════════════════════════
   ACTIVE EXERCISE / SUPERSET
   ══════════════════════════ */
.active-header {
  background: var(--purple);
  padding: calc(14px + var(--safe-top)) 20px 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.close-btn {
  font-size: 20px; color: white; cursor: pointer; width: 32px;
  text-align: center; line-height: 1; background: none; border: none;
}
.header-section-name {
  font-size: 16px; font-weight: 600; color: white;
  text-align: center; flex: 1;
}
.header-clock {
  width: 32px; height: 32px; border: 2px solid rgba(255,255,255,0.7);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 600;
}

.active-content { flex: 1; overflow-y: auto; }

/* Video area in active mode */
.active-video-area {
  width: 100%; height: 200px; background: var(--bg-overlay);
  position: relative; display: flex; align-items: center; justify-content: center;
}
.active-video-area video,
.active-video-area .active-still-image {
  width: 100%; height: 100%; object-fit: contain; background: var(--bg-inset);
}
.active-video-area .active-still-image {
  display: block;
}
.play-btn-big {
  width: 56px; height: 56px; background: rgba(255,255,255,0.9);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: absolute;
}
.play-btn-big svg { color: var(--purple); }
.info-btn {
  position: absolute; bottom: 10px; right: 10px;
  width: 28px; height: 28px; background: #4A90D9; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700; font-style: italic;
  cursor: pointer; border: none;
}

.active-exercise-title {
  font-size: 18px; font-weight: 700; color: var(--text-primary);
  padding: 16px 20px 0;
}
.active-exercise-note {
  font-size: 13px; color: var(--text-secondary); padding: 4px 20px 0;
}
/* Cali routines: full description shown where the video would be */
.active-exercise-instructions {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  padding: 12px 20px 0;
  white-space: normal;
}
/* Cali variant: row has no thumbnail slot. Give the title a bit of left
 * padding so it doesn't hug the card edge. */
.exercise-row.exercise-row-no-thumb { padding-left: 20px; }

/* Set table */
.set-table { margin: 8px 20px 0; }
.set-table-header {
  display: flex; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--gray-border);
}
.col-set {
  width: 50px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; color: var(--text-secondary);
}
.col-val {
  flex: 1; text-align: center; font-size: 12px; font-weight: 700;
  text-transform: uppercase; color: var(--text-secondary);
}
.col-check { width: 44px; display: flex; justify-content: center; }

.set-row {
  display: flex; align-items: center; padding: 14px 0;
  border-bottom: 1px solid var(--gray-border);
}
.set-num { width: 50px; font-size: 16px; font-weight: 500; color: var(--text-primary); }
.set-val {
  flex: 1; text-align: center; font-size: 16px;
  color: var(--purple); font-weight: 500;
}

.checkmark {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.checkmark.unchecked { border: 2px solid #C0C0C0; }
.checkmark.checked { background: var(--purple); border: none; }
.checkmark.checked svg { color: white; }

.mark-all {
  text-align: center; padding: 20px; font-size: 14px;
  font-weight: 600; color: var(--purple); cursor: pointer;
}

/* Superset in active mode */
.superset-section-active { padding: 20px 20px 0; }
.superset-title-active {
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  text-align: center; margin-bottom: 16px;
}
.exercise-card-active {
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 1px solid var(--gray-border);
}
.exercise-card-active:last-child { border-bottom: none; margin-bottom: 0; }
.exercise-top-active { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.video-thumb-sm {
  width: 60px; height: 60px; background: #fff; border-radius: 6px;
  border: 1px solid var(--gray-border, rgba(0,0,0,0.08));
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
}
.video-thumb-sm video,
.video-thumb-sm img { width: 100%; height: 100%; object-fit: cover; }

.superset-divider { height: 8px; background: var(--gray-bg); }

/* Pagination dots */
.pagination {
  display: flex; justify-content: center; gap: 8px;
  padding: 16px; flex-shrink: 0;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #D0D0D0; }
.dot.active { background: var(--purple); }

/* ══════════════════════
   EXERCISE DETAIL
   ══════════════════════ */
.exercise-search-bar {
  background: var(--white); padding: 12px 20px 0;
}
.exercise-search-bar input {
  width: 100%; padding: 10px 14px; font-size: 15px;
  border: 1px solid #E0E0E0; border-radius: 10px;
  background: #F5F5F5; outline: none; box-sizing: border-box;
}
.exercise-search-bar input:focus {
  border-color: var(--purple); background: var(--white);
}
.exercise-library-list {
  background: var(--white); padding: 10px 20px 40px; overflow-y: auto;
}

/* Exercise-detail header — cream with dark text, matching
   .history-header so every deeper-page back button reads the same. */
.detail-header {
  background: var(--white);
  padding: calc(14px + var(--safe-top)) 20px 14px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--gray-border);
}
.detail-header-title {
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  text-align: center; flex: 1;
}

.detail-sheet {
  background: var(--white); border-radius: 16px 16px 0 0;
  margin-top: -12px; position: relative; z-index: 2; padding: 12px 20px 40px;
}
.detail-exercise-title {
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  text-align: center; padding: 20px 0 16px;
}
.detail-video {
  width: 100%; position: relative;
}
.detail-video > video,
.detail-video > img {
  width: 100%; height: 220px; background: var(--bg-overlay); border-radius: 10px;
  object-fit: contain;
}
.detail-video video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.detail-video .detail-image {
  width: 100%; height: auto; max-height: 300px; object-fit: contain; border-radius: 10px;
}
.image-gallery {
  position: relative; width: 100%; overflow: hidden; border-radius: 10px;
}
.gallery-track {
  display: flex; transition: transform 0.3s ease; width: 100%;
}
.gallery-slide {
  min-width: 100%; width: 100%; height: auto; max-height: 300px; object-fit: contain;
}
video.gallery-slide {
  background: #000;
}
.gallery-dots {
  display: flex; justify-content: center; gap: 6px; padding: 10px 0;
}

.instructions-label {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  margin-top: 24px; margin-bottom: 12px;
}
.instructions-list { list-style: none; }
.instructions-list li {
  font-size: 14px; color: #333; line-height: 1.6; margin-bottom: 12px;
}
/* Prose variant for physio/cali — preserves line breaks and section
 * headers from the .txt body without forcing it into a numbered list. */
.instructions-prose {
  font-size: 14px; color: #333; line-height: 1.6;
  white-space: pre-line;
  word-break: break-word;
}

/* ══════════════════
   HISTORY
   ══════════════════ */
.history-header {
  display: flex; align-items: center;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  position: sticky; top: 0; z-index: 10; background: var(--white);
}
.history-title {
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  text-align: center; flex: 1;
}

.history-month-section {
  border-bottom: 1px solid var(--gray-border);
}
.history-month-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; cursor: pointer;
}
.history-month-label {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
}
.history-month-arrow {
  font-size: 22px; color: var(--text-secondary);
  transform: rotate(90deg); transition: transform 0.2s ease;
  line-height: 1;
}
.history-month-arrow.expanded {
  transform: rotate(-90deg);
}
.history-month-body {
  padding: 0 0 8px;
}
.timeline { padding: 0 20px; }
.timeline-entry { display: flex; gap: 16px; padding: 16px 0; }
.timeline-track {
  display: flex; flex-direction: column; align-items: center;
  width: 12px; flex-shrink: 0;
}
.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #D0D0D0; flex-shrink: 0; margin-top: 4px;
}
.timeline-dot.active { background: var(--purple); }
.timeline-line { width: 2px; flex: 1; background: #E8E8E8; margin-top: 4px; }
.timeline-content { flex: 1; }
.timeline-date { font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.timeline-date.active { color: var(--purple); }
.timeline-workout-card { padding: 14px 0; margin-top: 8px; }
.timeline-workout-name { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.workout-stat {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary); margin-bottom: 4px;
}

/* ══════════════════
   JOURNAL
   ══════════════════ */
.journal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 20px 14px;
}
.journal-counter {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  text-align: center; flex: 1;
}
.journal-content {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 0 20px; padding-bottom: 20px;
}
.question-number {
  font-size: 16px; font-weight: 600; color: var(--purple); margin-bottom: 6px;
}
.question-text {
  font-size: 22px; font-weight: 700; color: var(--text-primary);
  line-height: 1.3; margin-bottom: 16px;
}
.answer-area {
  background: var(--gray-light); border-radius: 12px; padding: 16px;
  min-height: 120px; font-size: 14px; border: none; width: 100%;
  resize: none; color: var(--text-primary); font-family: inherit;
}
.answer-area::placeholder { color: var(--text-secondary); }
.submit-btn {
  background: var(--purple); color: white; border: none; border-radius: 25px;
  padding: 14px 32px; font-size: 16px; font-weight: 600; margin-top: 20px;
  align-self: flex-start;
}
.journal-nav {
  display: flex; justify-content: space-between; padding: 16px 20px; flex-shrink: 0;
}
.nav-prev, .nav-next {
  font-size: 16px; font-weight: 600; color: var(--purple); cursor: pointer;
  background: none; border: none;
}
.nav-prev:disabled, .nav-next:disabled { visibility: hidden; }
.progress-bar { display: flex; gap: 3px; flex-shrink: 0; }
.progress-segment { flex: 1; height: 4px; background: #E0E0E0; }
.progress-segment.active { background: var(--purple); }

/* ══════════════════
   PROFILE
   ══════════════════ */
.profile-header-area { padding: calc(20px + var(--safe-top)) 20px 0; display: flex; justify-content: space-between; align-items: flex-start; }
.profile-title { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: white;
}

.stats-card {
  margin: 20px 20px 0; background: var(--purple-bg); border-radius: 12px;
  padding: 20px; display: flex;
}
.stat { flex: 1; display: flex; align-items: center; gap: 10px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-divider { width: 1px; background: var(--gray-border); margin: 0 12px; }

.menu-list { margin-top: 24px; }
.menu-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-border);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: inherit;
}
.menu-row:last-child { border-bottom: none; }
.menu-label { font-size: 16px; color: var(--text-primary); font-family: var(--font-sans); }
.menu-chevron { font-size: 16px; color: var(--text-secondary); }

.menu-list-danger {
  margin-top: 40px;
  border-top: 1px solid var(--gray-border);
}
.menu-row-signout .menu-label {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.menu-row-signout .menu-chevron { color: var(--red); }

/* Exercise metadata */
.exercise-meta {
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--gray-border);
}
.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--gray-border);
  font-size: 14px;
}
.meta-row strong {
  color: var(--text-primary); font-weight: 700;
}
.meta-row span {
  color: var(--text-secondary);
}

/* ── Utility ── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-secondary);
  font-size: 16px;
}
.hidden { display: none !important; }

/* ── Rest Timer Overlay ── */
#rest-timer-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.rest-timer-card {
  background: white; border-radius: 20px; padding: 30px;
  text-align: center; min-width: 220px; position: relative;
}
.rest-timer-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; font-size: 22px; color: var(--text-secondary); cursor: pointer;
}
.rest-timer-label {
  font-size: 14px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px;
}
.rest-timer-circle {
  position: relative; width: 120px; height: 120px; margin: 0 auto 16px;
}
.rest-timer-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest-timer-circle .rest-bg {
  fill: none; stroke: var(--gray-light); stroke-width: 6;
}
.rest-timer-circle .rest-progress {
  fill: none; stroke: var(--purple); stroke-width: 6;
  stroke-linecap: round; transition: stroke-dashoffset 1s linear;
}
.rest-timer-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 36px; font-weight: 700; color: var(--text-primary);
}
.rest-timer-skip {
  background: var(--purple-bg); color: var(--purple); border: none;
  border-radius: 10px; padding: 10px 28px; font-size: 14px;
  font-weight: 600; cursor: pointer;
}

/* ── Section Start Page ── */
.section-start-page {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; padding: 40px 20px;
  text-align: center;
}
.section-start-name {
  font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px;
}
.section-start-type {
  font-size: 14px; color: var(--text-secondary); margin-bottom: 8px;
}
.section-start-notes {
  font-size: 14px; color: var(--text-secondary); margin-bottom: 30px;
  max-width: 300px; line-height: 1.5;
}
.section-start-count {
  font-size: 14px; color: var(--text-secondary); margin-bottom: 30px;
}
.section-start-btn {
  background: var(--purple); color: white; border: none;
  border-radius: 12px; padding: 14px 48px; font-size: 16px;
  font-weight: 600; cursor: pointer;
}

/* ── Sync Status ── */
.sync-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  vertical-align: middle;
}
.sync-badge.offline { background: #FFF3E0; color: #E65100; }
.sync-badge.pending { background: #E3F2FD; color: #1565C0; }
.sync-badge.syncing { background: var(--purple-bg); color: var(--purple); }
.sync-spinner {
  display: inline-block; width: 10px; height: 10px;
  border: 2px solid var(--purple); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sync-info {
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 20px 12px;
}

.sync-progress-overlay {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: white;
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap;
}
.sync-progress-bar {
  width: 80px; height: 4px; background: rgba(255,255,255,0.3);
  border-radius: 2px; overflow: hidden;
}
.sync-progress-fill {
  height: 100%; background: var(--purple);
  transition: width 0.3s;
}
