/* ============================================================
   BLUEPRINT — shared stylesheet
   Subject grounding: a rower's off-season strength program.
   Palette pulls from blade colors, boathouse green, chalk and
   cream. Bubbly = soft squircle radii, tactile press states,
   thick confident borders, a little spring in every motion.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap');

:root {
  /* ---- Color tokens ---- */
  --cream:        #F7F2E9;   /* base background — muted warm white */
  --cream-deep:   #EFE7D8;   /* recessed panels / wells */
  --paper:        #FFFDF8;   /* card surface, lighter than bg */
  --ink:          #1E2B23;   /* primary text — boathouse dark green-black */
  --ink-soft:     #5B6B60;   /* secondary text */
  --ink-faint:    #94A096;   /* tertiary / placeholder */

  --blade:        #FF5A36;   /* primary vibrant — racing blade orange */
  --blade-deep:   #E8431F;
  --blade-wash:   #FFE4D9;

  --boathouse:    #1F6F58;   /* secondary — deep green */
  --boathouse-deep:#15523F;
  --boathouse-wash:#DCEFE7;

  --buoy:         #FFC94A;   /* accent yellow — PRs, highlights */
  --buoy-deep:    #E8AC1F;
  --buoy-wash:    #FFF3D6;

  --lane-blue:    #3E7CC2;   /* Workout D */
  --lane-blue-wash:#DEEBF8;

  --bow-pink:     #E85D8A;   /* Workout E */
  --bow-pink-wash:#FCE1EA;

  --line:         #E2D9C7;   /* hairline borders on cream */
  --line-deep:    #D6CBB4;

  --success:      #2E9E5B;
  --danger:       #E2483C;

  /* ---- Radii: the "bubbly" squircle system ---- */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;
  --r-pill: 999px;

  /* ---- Shadows: soft, warm, never pure black ---- */
  --shadow-sm: 0 2px 0 rgba(30, 43, 35, 0.06), 0 4px 10px rgba(94, 73, 38, 0.07);
  --shadow-md: 0 4px 0 rgba(30, 43, 35, 0.07), 0 10px 24px rgba(94, 73, 38, 0.10);
  --shadow-lg: 0 8px 0 rgba(30, 43, 35, 0.06), 0 20px 40px rgba(94, 73, 38, 0.14);
  --shadow-press: 0 1px 0 rgba(30, 43, 35, 0.10), 0 2px 4px rgba(94, 73, 38, 0.10);

  /* ---- Type scale ---- */
  --fs-display: clamp(2.4rem, 5vw, 3.6rem);
  --fs-h1: clamp(1.8rem, 3.4vw, 2.4rem);
  --fs-h2: 1.5rem;
  --fs-h3: 1.15rem;
  --fs-body: 1rem;
  --fs-sm: 0.875rem;
  --fs-xs: 0.75rem;

  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* Icon SVGs ship with width="24" height="24" attributes as their natural
   size. We do NOT override that globally via CSS (CSS width/height always
   wins over the attribute, which would force every icon to one size
   regardless of context). Instead, each component below sets its own
   icon size explicitly where it needs to differ from 24px. */

body {
  margin: 0;
  background: var(--cream);
  background-image:
    radial-gradient(circle at 8% 8%, rgba(255, 90, 54, 0.05), transparent 38%),
    radial-gradient(circle at 92% 18%, rgba(31, 111, 88, 0.05), transparent 40%),
    radial-gradient(circle at 50% 95%, rgba(255, 201, 74, 0.06), transparent 45%);
  color: var(--ink);
  font-family: 'Lexend', system-ui, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 96px; /* room for mobile tab bar */
}

h1, h2, h3, h4 {
  font-family: 'Lexend', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

::selection { background: var(--buoy); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
body.calm-theme * {
  animation: none !important;
  transition-duration: 120ms !important;
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 242, 233, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--blade);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-mark svg { width: 19px; height: 19px; color: white; }

.nav-desktop {
  display: flex;
  gap: 6px;
  background: var(--cream-deep);
  padding: 5px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
}

.nav-link {
  padding: 9px 18px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
}
.nav-link:hover { color: var(--ink); background: rgba(255,255,255,0.6); }
.nav-link.active {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-sm);
}

.tabbar {
  display: none;
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  z-index: 50;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  justify-content: space-between;
}
.tab-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px;
  border-radius: var(--r-md);
  color: var(--ink-faint);
  font-size: 0.62rem;
  font-weight: 600;
  transition: all 0.18s var(--ease-bounce);
}
.tab-link svg { width: 18px; height: 18px; transition: transform 0.18s var(--ease-bounce); }
.tab-link.active { color: var(--blade); background: var(--blade-wash); }
.tab-link.active svg { transform: translateY(-1px) scale(1.08); }
.tab-link:active svg { transform: scale(0.85); }

@media (max-width: 760px) {
  .nav-desktop { display: none; }
  .tabbar { display: flex; }
  body { padding-bottom: 104px; }
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ============================================================
   CARDS & SURFACES
   ============================================================ */

.card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.card-flat {
  background: var(--cream-deep);
  border-radius: var(--r-lg);
  padding: 20px;
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.section-eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--blade);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 13px 22px;
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  transition: transform 0.15s var(--ease-bounce), box-shadow 0.15s var(--ease-out), background 0.15s;
  box-shadow: var(--shadow-sm);
  user-select: none;
}
.btn:active { transform: translateY(2px) scale(0.98); box-shadow: var(--shadow-press); }

.btn-primary { background: var(--blade); color: white; }
.btn-primary:hover { background: var(--blade-deep); transform: translateY(-1px); }

.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #15201A; transform: translateY(-1px); }

.btn-outline { background: transparent; border-color: var(--line-deep); color: var(--ink); }
.btn-outline:hover { background: var(--cream-deep); }

.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--cream-deep); }

.btn-sm { padding: 8px 15px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--cream-deep);
  border: 2px solid var(--line);
  transition: transform 0.15s var(--ease-bounce);
}
.icon-btn:hover { background: var(--paper); }
.icon-btn:active { transform: scale(0.9); }

/* ============================================================
   WORKOUT LETTER BADGES
   ============================================================ */

.letter-badge {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 1.5rem;
  flex-shrink: 0;
  position: relative;
}
.letter-badge.sm { width: 38px; height: 38px; font-size: 1.05rem; border-radius: var(--r-sm); }
.letter-badge.lg { width: 84px; height: 84px; font-size: 2.2rem; border-radius: var(--r-lg); }

.c-orange { background: var(--blade-wash); color: var(--blade-deep); }
.c-yellow { background: var(--buoy-wash); color: var(--buoy-deep); }
.c-green  { background: var(--boathouse-wash); color: var(--boathouse-deep); }
.c-blue   { background: var(--lane-blue-wash); color: var(--lane-blue); }
.c-pink   { background: var(--bow-pink-wash); color: var(--bow-pink); }

.fill-orange { background: var(--blade); color: white; }
.fill-yellow { background: var(--buoy); color: var(--ink); }
.fill-green  { background: var(--boathouse); color: white; }
.fill-blue   { background: var(--lane-blue); color: white; }
.fill-pink   { background: var(--bow-pink); color: white; }

/* ============================================================
   PROGRESS RING
   ============================================================ */

.ring-wrap { position: relative; display: inline-grid; place-items: center; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fill {
  fill: none; stroke: var(--blade); stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset 0.6s var(--ease-out);
}
.ring-label { position: absolute; text-align: center; }
.ring-label .num { display: block; font-size: 1.6rem; font-weight: 800; }
.ring-label .sub { display: block; font-size: 0.68rem; color: var(--ink-soft); font-weight: 600; }

/* ============================================================
   EXERCISE / SET ROWS
   ============================================================ */

.exercise-card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.exercise-card.complete { border-color: var(--success); }

.exercise-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
}

.exercise-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--cream-deep);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.exercise-card.complete .exercise-num { background: var(--success); color: white; }

.exercise-name { font-weight: 700; font-size: 1rem; }
.exercise-meta { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }

.exercise-chevron { margin-left: auto; transition: transform 0.25s var(--ease-bounce); color: var(--ink-faint); }
.exercise-card.open .exercise-chevron { transform: rotate(180deg); }

.exercise-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s var(--ease-out);
}
.exercise-card.open .exercise-body { max-height: 900px; }

.exercise-body-inner { padding: 0 18px 18px; }

.target-pill {
  display: inline-block;
  background: var(--cream-deep);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--boathouse-deep);
}

.set-grid {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.set-grid-head {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  text-align: center;
}
.set-grid input {
  width: 100%;
  border: 2px solid var(--line);
  background: var(--cream);
  border-radius: var(--r-sm);
  padding: 9px 6px;
  text-align: center;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.set-grid input:focus { outline: none; border-color: var(--blade); background: var(--paper); }
.set-grid input::placeholder { color: var(--ink-faint); font-weight: 400; }

.set-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--cream-deep);
  display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700; color: var(--ink-soft);
}

.set-check {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--line-deep);
  background: var(--paper);
  display: grid; place-items: center;
  transition: all 0.2s var(--ease-bounce);
}
.set-check.checked {
  background: var(--success);
  border-color: var(--success);
  transform: scale(1.08);
}
.set-check svg { width: 16px; height: 16px; opacity: 0; transition: opacity 0.15s; color: white; }
.set-check.checked svg { opacity: 1; }

/* ============================================================
   STAT TILES
   ============================================================ */

.stat-tile {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-tile .num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-tile .label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 700px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   PILLS / TOGGLES / CHIPS
   ============================================================ */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--cream-deep);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 0.8rem; font-weight: 600; color: var(--ink-soft);
}

.segmented {
  display: inline-flex;
  background: var(--cream-deep);
  border-radius: var(--r-pill);
  padding: 4px;
  border: 2px solid var(--line);
}
.segmented button {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  transition: all 0.2s var(--ease-out);
}
.segmented button.active { background: var(--ink); color: var(--paper); box-shadow: var(--shadow-sm); }

.toggle {
  width: 50px; height: 28px;
  border-radius: var(--r-pill);
  background: var(--line-deep);
  position: relative;
  border: none;
  transition: background 0.25s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease-bounce);
}
.toggle.on { background: var(--boathouse); }
.toggle.on::after { transform: translateX(22px); }

/* ============================================================
   MODALS / TOASTS
   ============================================================ */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30, 43, 35, 0.45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }

.modal-card {
  background: var(--paper);
  border-radius: var(--r-xl);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  width: 100%;
  padding: 28px;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s var(--ease-bounce);
}
.modal-backdrop.show .modal-card { transform: translateY(0) scale(1); }

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 18px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.4s var(--ease-bounce);
}
.toast.pr { background: var(--buoy); color: var(--ink); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@media (max-width: 600px) {
  .toast-stack { left: 14px; right: 14px; top: 14px; max-width: none; }
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mt-4 { margin-top: 32px; }
.text-soft { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hide-mobile { }
@media (max-width: 760px) { .hide-mobile { display: none !important; } }
.hide-desktop { display: none; }
@media (max-width: 760px) { .hide-desktop { display: block; } }

.divider { height: 2px; background: var(--line); border-radius: 1px; margin: 18px 0; }

.bounce-in { animation: bounceIn 0.5s var(--ease-bounce) backwards; }
@keyframes bounceIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.spin-slow { animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.confetti-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

textarea.app-textarea {
  width: 100%;
  border: 2px solid var(--line);
  background: var(--cream);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  resize: vertical;
  min-height: 70px;
}
textarea.app-textarea:focus { outline: none; border-color: var(--blade); background: var(--paper); }

select.app-select {
  border: 2px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-pill);
  padding: 9px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}

input.app-input {
  border: 2px solid var(--line);
  background: var(--cream);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  width: 100%;
}
input.app-input:focus { outline: none; border-color: var(--blade); background: var(--paper); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
}
.empty-state svg { margin-bottom: 14px; opacity: 0.5; }

a:focus-visible, button:focus-visible, input:focus-visible, .nav-link:focus-visible {
  outline: 3px solid var(--blade);
  outline-offset: 2px;
}

/* ============================================================
   STATS PAGE — mode tabstrip + calendar heatmap
   Tabstrip reuses the pill-tab visual language from Custom's
   workout-tabstrip (style.css is the shared sheet, so it lives
   here rather than duplicated per-page).
   ============================================================ */
.stats-mode-tabstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
}
.stats-mode-tabstrip::-webkit-scrollbar { display: none; }

.stats-mode-tab {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line);
  background: var(--paper);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}
.stats-mode-tab svg { width: 16px; height: 16px; }
.stats-mode-tab:hover { border-color: var(--line-deep); }
.stats-mode-tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.heatmap-wrap {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.heatmap-daylabels {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
  flex-shrink: 0;
  padding-top: 1px;
}
.heatmap-daylabel {
  font-size: 0.6rem;
  color: var(--ink-faint);
  font-weight: 700;
  display: flex;
  align-items: center;
  height: 14px;
}
.heatmap-grid {
  display: flex;
  gap: 3px;
}
.heatmap-col {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
}
.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.heatmap-cell.empty { background: transparent; }
