/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-1: #0f0a1f;
  --bg-2: #1a1033;
  --bg-3: #2a1758;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.10);
  --text: #f5f3ff;
  --text-dim: #b8b2d1;
  --text-muted: #7a7395;

  --accent-1: #ff3d7f;     /* hot pink */
  --accent-2: #ff8a3d;     /* orange */
  --accent-3: #7c5cff;     /* violet */
  --accent-4: #00d9ff;     /* cyan */

  --gradient-primary: linear-gradient(135deg, #ff3d7f 0%, #ff8a3d 100%);
  --gradient-cool: linear-gradient(135deg, #7c5cff 0%, #00d9ff 100%);
  --gradient-warm: linear-gradient(135deg, #ff3d7f 0%, #7c5cff 100%);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 12px 40px rgba(255, 61, 127, 0.45);

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

[data-theme="light"] {
  --bg-1: #f5f3ff;
  --bg-2: #ffe8f0;
  --bg-3: #ffd6d6;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --border: rgba(40, 20, 80, 0.10);
  --text: #1a1033;
  --text-dim: #4a3d6e;
  --text-muted: #8a7fa8;
  --shadow-sm: 0 4px 12px rgba(80, 30, 100, 0.08);
  --shadow-md: 0 8px 28px rgba(80, 30, 100, 0.12);
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  /* Prevent iOS rubber-band overscroll from exposing the page's "behind" colour */
  overscroll-behavior: none;
}

/* The html element is what shows during iOS overscroll/bounce on standalone PWAs.
   Match it to the darkest app colour so no white peeks through.
   var(--bg-1) automatically swaps when [data-theme="light"] is set. */
html { background: var(--bg-1); }

body {
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top left, var(--bg-3) 0%, var(--bg-2) 35%, var(--bg-1) 70%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: -20%; left: -20%;
  width: 60%; height: 60%;
  background: radial-gradient(circle, rgba(255, 61, 127, 0.25), transparent 60%);
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
}

body::after {
  content: "";
  position: fixed;
  bottom: -20%; right: -20%;
  width: 60%; height: 60%;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.18), transparent 60%);
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------- App Shell ---------- */
.app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 100px);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Header ---------- */
.header { margin-bottom: 20px; }

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--gradient-primary);
  display: grid; place-items: center;
  color: white;
  box-shadow: var(--shadow-glow);
}
.brand-logo svg { width: 22px; height: 22px; }

.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tag { font-size: 13px; color: var(--text-dim); }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.15s ease, background 0.2s ease;
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.ghost { background: transparent; border: none; font-size: 20px; }
.icon-btn.ghost svg { width: 16px; height: 16px; }

/* Theme toggle: show moon when dark, sun when light */
#themeToggle .icon-sun { display: none; }
[data-theme="light"] #themeToggle .icon-moon { display: none; }
[data-theme="light"] #themeToggle .icon-sun  { display: block; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  position: relative;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.18;
  pointer-events: none;
}
.stat-1::before { background: var(--gradient-primary); }
.stat-2::before { background: var(--gradient-cool); }
.stat-3::before { background: var(--gradient-warm); }

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  color: var(--text);
  opacity: 0.95;
}
.stat-icon svg { width: 22px; height: 22px; display: block; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.7;
}

.search-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 15px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent-1); background: var(--surface-strong); }

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  white-space: nowrap;
  transition: transform 0.15s ease;
}
.filter-btn:active { transform: scale(0.96); }

/* ---------- Notes List ---------- */
.notes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Wrapper that hosts the red delete background under each card.
   It carries the visible border + radius so the "card" look is one solid unit. */
.note-swipe-wrap {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  touch-action: pan-y; /* let vertical scroll pass; we capture horizontal */
  animation: cardIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.note-swipe-delete {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  color: white;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.4px;
  border: none;
  cursor: pointer;
  z-index: 0;
  -webkit-tap-highlight-color: transparent;
}
.note-swipe-delete svg { width: 22px; height: 22px; display: block; }
.note-swipe-delete:active { filter: brightness(0.92); }

.note-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), background 0.2s ease, border-color 0.2s ease;
}
/* When inside a swipe-wrap the card sits above the delete background and
   must be fully opaque so the red button never shows through at rest. */
.note-swipe-wrap > .note-card {
  position: relative;
  z-index: 1;
  will-change: transform;
  border: none;
  border-radius: 0;
  /* Layer the translucent surface tint on top of an opaque base so the look
     matches the rest of the app while fully covering the delete button. */
  background:
    linear-gradient(var(--surface), var(--surface)),
    var(--bg-2);
}
[data-theme="light"] .note-swipe-wrap > .note-card {
  background:
    linear-gradient(var(--surface), var(--surface)),
    var(--bg-1);
}
.note-card:active { background: var(--surface-strong); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.note-icon {
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 28px;
  color: white;
  background: var(--gradient-primary);
  box-shadow: 0 6px 20px rgba(255, 61, 127, 0.35);
}
.note-icon svg { width: 28px; height: 28px; display: block; }
.note-card:nth-child(3n+2) .note-icon { background: var(--gradient-cool); box-shadow: 0 6px 20px rgba(0, 217, 255, 0.30); }
.note-card:nth-child(3n+3) .note-icon { background: var(--gradient-warm); box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35); }

.note-body { flex: 1; min-width: 0; }
.note-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.note-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.note-pill.intensity-Light    { color: #4ade80; border-color: rgba(74, 222, 128, 0.3); }
.note-pill.intensity-Moderate { color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
.note-pill.intensity-Intense  { color: #f87171; border-color: rgba(248, 113, 113, 0.35); }

.note-text {
  font-size: 13px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Empty state ---------- */
.empty-state {
  margin: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty-emoji {
  font-size: 64px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 16px rgba(255, 61, 127, 0.4));
}
/* SVG-based empty illustration — line-icon style with the accent colour */
.empty-emoji-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px; height: 96px;
  margin: 0 auto 16px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-1);
}
.empty-emoji-svg svg { width: 56px; height: 56px; display: block; }
.empty-illustration {
  display: block;
  width: 144px;
  height: 144px;
  object-fit: contain;
  margin: 0 auto 16px;
  background: white;
  border-radius: 50%;
  padding: 18px;
  box-shadow: 0 12px 32px rgba(168, 85, 247, 0.25), inset 0 0 0 1px rgba(168, 85, 247, 0.12);
}
[data-theme="light"] .empty-illustration { background: var(--surface); }
.empty-state h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.empty-state p { font-size: 14px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--safe-bottom) + 100px);
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  display: grid; place-items: center;
  box-shadow: var(--shadow-glow);
  z-index: 49;
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.92); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  max-height: 92dvh;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 8px 20px calc(var(--safe-bottom) + 20px);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: slideUp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--text-muted);
  opacity: 0.4;
  border-radius: 2px;
  margin: 8px auto 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-head h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Inline timer button shown inside the workout-edit modal header */
.modal-timer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.modal-timer-btn:active { transform: scale(0.95); }
.modal-timer-btn .modal-timer-icon { display: inline-flex; }
.modal-timer-btn .modal-timer-icon svg { width: 16px; height: 16px; display: block; }
.modal-timer-btn.running {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
}
.modal-timer-btn.paused {
  background: rgba(168, 85, 247, 0.85);
  border-color: transparent;
  color: white;
}
.modal-timer-btn.alarm {
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  border-color: transparent;
  color: white;
  animation: timerAlarm 0.55s ease-in-out infinite;
}

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1px;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  resize: vertical;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--accent-1); background: var(--surface-strong); }

input[type="date"].form-input { color-scheme: dark; }
[data-theme="light"] input[type="date"].form-input { color-scheme: light; }

/* Picked icon row */
.picked-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.picked-icon {
  flex-shrink: 0;
  width: 64px; height: 64px;
  border-radius: 18px;
  font-size: 32px;
  color: white;
  background: var(--gradient-primary);
  display: grid; place-items: center;
  box-shadow: var(--shadow-glow);
  transition: transform 0.15s ease;
  align-self: flex-end;
}
.picked-icon svg { width: 32px; height: 32px; display: block; }
.picked-icon:active { transform: scale(0.94); }
.picked-info { flex: 1; }

/* Icon picker */
.icon-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.icon-picker-head { margin-bottom: 10px; }

.cat-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-top: 8px;
  padding-bottom: 4px;
}
.cat-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.18s ease;
  white-space: nowrap;
}
.cat-tab.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 2px;
}
.icon-grid::-webkit-scrollbar { width: 6px; }
.icon-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.icon-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--text);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.icon-cell svg { width: 22px; height: 22px; display: block; }
.icon-cell.selected { color: var(--accent-1); }
.icon-cell:active { transform: scale(0.88); }
.icon-cell.selected {
  background: var(--surface-strong);
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(255, 61, 127, 0.25);
}

/* Row of two */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 12px;
}
@media (max-width: 380px) {
  .row-2 { grid-template-columns: 1fr; }
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Variant: stack each chip on its own full-width row */
.chip-row.chip-stack {
  flex-direction: column;
}
.chip-row.chip-stack .chip {
  flex: none;
  width: 100%;
  padding: 14px 16px;
  font-size: 14px;
  text-align: left;
}
.chip {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  transition: all 0.18s ease;
}
.chip.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 61, 127, 0.4);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.btn {
  flex: 1;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow);
}
.btn-ghost {
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
}

/* ---------- Workout Calendar ---------- */
.stat-card-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.18s ease;
  font-family: inherit;
}
.stat-card-clickable:active { transform: scale(0.97); }

.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 14px;
}
.cal-nav-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.18s ease;
}
.cal-nav-btn:active { transform: scale(0.92); background: var(--surface-strong); }
.cal-nav-btn svg { width: 16px; height: 16px; }
.cal-month-label {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  text-transform: capitalize;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 0 6px;
}
.cal-weekdays span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.cal-cell:hover { background: rgba(255, 255, 255, 0.05); }
.cal-cell.empty { cursor: default; pointer-events: none; background: transparent; }

.cal-cell.today {
  border-color: var(--accent-1);
  color: var(--text);
  font-weight: 800;
}

.cal-cell.has-workout {
  background: rgba(255, 61, 127, 0.14);
  color: var(--text);
}

.cal-cell.selected {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(255, 61, 127, 0.40);
  transform: scale(1.05);
}

.cal-day-dot {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-1);
}
.cal-cell.selected .cal-day-dot { background: white; }
.cal-cell.has-workout:not(.selected) .cal-day-num { font-weight: 800; }

.cal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 22px 0 18px;
  padding: 0;
  background: var(--border);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}
.cal-stat {
  text-align: center;
  padding: 14px 6px;
  background: var(--surface);
}
.cal-stat-num {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
  margin-bottom: 2px;
}
.cal-stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.cal-day-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  margin: 0;
}
.cal-day-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.cal-day-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.cal-day-item:active {
  transform: scale(0.98);
  background: var(--surface-strong);
}
.cal-day-icon {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: grid; place-items: center;
  font-size: 20px;
  color: white;
}
.cal-day-icon svg { width: 22px; height: 22px; display: block; }
.cal-day-body { flex: 1; min-width: 0; }
.cal-day-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-day-meta {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Celebration overlay (after completing a workout) ---------- */
.celebrate-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(40, 10, 60, 0.85) 0%, rgba(0, 0, 0, 0.92) 70%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  animation: fadeIn 0.3s ease;
  overflow: hidden;
}
.celebrate-overlay[hidden] { display: none; }

.celebrate-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: white;
  padding: 0 30px;
  animation: celebrateBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes celebrateBounce {
  0%   { opacity: 0; transform: scale(0.55); }
  100% { opacity: 1; transform: scale(1); }
}

.celebrate-emoji {
  font-size: 110px;
  line-height: 1;
  margin-bottom: 18px;
  animation: emojiPop 1s ease-out, emojiWiggle 2.4s ease-in-out 1s infinite;
  filter: drop-shadow(0 12px 30px rgba(0,0,0,0.40));
}
@keyframes emojiPop {
  0%   { transform: scale(0) rotate(-180deg); }
  60%  { transform: scale(1.25) rotate(15deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes emojiWiggle {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-8deg); }
  75%      { transform: rotate(8deg); }
}

.celebrate-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ff3d7f 0%, #ff8a3d 50%, #fbbf24 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 20px rgba(255, 61, 127, 0.40);
}

.celebrate-sub {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 22px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.40);
}

.celebrate-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
  letter-spacing: 0.5px;
  animation: hintPulse 1.5s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  will-change: transform, opacity;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translate3d(0, -20px, 0) rotate(0); opacity: 1; }
  10%  { opacity: 1; }
  100% { transform: translate3d(var(--drift, 0), 110vh, 0) rotate(var(--spin, 720deg)); opacity: 0.2; }
}

/* ---------- Timer-end fullscreen splash ---------- */
.timer-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; /* swallow tap so it can't synthesise a click on the page below */
  color: white;
  background:
    linear-gradient(
      to bottom,
      rgba(15, 5, 25, 0.55) 0%,
      rgba(15, 5, 25, 0.15) 28%,
      rgba(15, 5, 25, 0.15) 60%,
      rgba(15, 5, 25, 0.85) 100%
    ),
    url('media/splash-bg.webp') center/cover no-repeat;
  animation: timerSplashIn 0.35s ease;
  overflow: hidden;
}
.timer-splash[hidden] { display: none; }

/* Pulsing red vignette over the image for urgency */
.timer-splash::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(220, 38, 38, 0.45) 95%);
  animation: timerRedPulse 1.6s ease-in-out infinite;
}
@keyframes timerRedPulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

@keyframes timerSplashIn {
  from { opacity: 0; transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}

.timer-splash-inner {
  position: relative;
  z-index: 2; /* sit above the ::after vignette */
  text-align: center;
  animation: timerSplashPulse 1.6s ease-in-out infinite;
}
@keyframes timerSplashPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.timer-splash-icon {
  width: 96px; height: 96px;
  margin: 0 auto 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.18);
  display: grid; place-items: center;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.20);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.timer-splash-icon svg { width: 56px; height: 56px; display: block; }

.timer-splash-title {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -1.6px;
  line-height: 1.05;
  margin-bottom: 14px;
  text-shadow:
    0 4px 24px rgba(0, 0, 0, 0.65),
    0 2px 8px rgba(0, 0, 0, 0.55);
}
.timer-splash-sub {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.92;
  text-shadow:
    0 2px 12px rgba(0, 0, 0, 0.65),
    0 1px 4px rgba(0, 0, 0, 0.45);
}

@media (min-width: 768px) {
  .timer-splash-title { font-size: 72px; }
  .timer-splash-icon { width: 112px; height: 112px; }
  .timer-splash-icon svg { width: 64px; height: 64px; }
}

/* ---------- Rest Timer ---------- */
/* Hidden by default — only shown while a workout is open or a timer is active */
.timer-btn { display: none !important; }
body.workout-open .timer-btn,
body.timer-active .timer-btn { display: grid !important; }

.timer-btn {
  position: fixed;
  right: 20px;
  bottom: calc(var(--safe-bottom) + 174px);
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  background: rgba(15, 10, 31, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.40);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 49;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.timer-btn:active { transform: scale(0.92); }

/* Light-mode override: light bubble on bright background */
[data-theme="light"] .timer-btn {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(20, 12, 50, 0.08);
  color: #1a1033;
  box-shadow: 0 10px 24px rgba(80, 30, 100, 0.18);
}
/* Countdown progress ring around the floating timer button.
   Hidden until the timer is running/paused — pure cosmetic on the idle state. */
.timer-btn-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* rotate so the stroke starts at 12 o'clock */
  transform: rotate(-90deg);
  display: none;
}
.timer-btn.running .timer-btn-ring,
.timer-btn.paused  .timer-btn-ring,
.timer-btn.alarm   .timer-btn-ring { display: block; }
.timer-btn-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 3;
}
.timer-btn-ring-progress {
  fill: none;
  stroke: white;
  stroke-width: 3;
  stroke-linecap: round;
  /* circumference = 2 * π * 27 ≈ 169.65 */
  stroke-dasharray: 169.65;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear;
}

.timer-btn-icon,
.timer-btn-label {
  grid-area: 1 / 1;
  align-items: center;
  justify-content: center;
}
/* Default state (idle): icon visible, label hidden */
.timer-btn-icon  { display: inline-flex; }
.timer-btn-label { display: none; }
.timer-btn-icon svg { width: 24px; height: 24px; display: block; }

/* While running/paused/alarming: swap — countdown visible, icon hidden */
.timer-btn.running .timer-btn-icon,
.timer-btn.paused  .timer-btn-icon,
.timer-btn.alarm   .timer-btn-icon { display: none; }
.timer-btn.running .timer-btn-label,
.timer-btn.paused  .timer-btn-label,
.timer-btn.alarm   .timer-btn-label { display: inline-flex; }

.timer-btn.running {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
  box-shadow: 0 10px 28px rgba(255, 61, 127, 0.45);
}
.timer-btn.paused {
  background: rgba(168, 85, 247, 0.85);
  color: white;
  border-color: transparent;
}
.timer-btn.alarm {
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  color: white;
  border-color: transparent;
  animation: timerAlarm 0.55s ease-in-out infinite;
}
@keyframes timerAlarm {
  0%, 100% { transform: scale(1);    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.50); }
  50%      { transform: scale(1.10); box-shadow: 0 14px 36px rgba(220, 38, 38, 0.70); }
}

/* Big countdown inside the timer sheet */
.timer-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 22px;
}
.timer-display-time {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}
.timer-display-status {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.timer-preset {
  padding: 14px 8px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}
.timer-preset:active { transform: scale(0.97); background: var(--surface-strong); }
.timer-preset.selected {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(255, 61, 127, 0.30);
}

.timer-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.timer-actions .btn { flex: 1; padding: 14px; font-size: 15px; }
.btn-secondary {
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-secondary:active { transform: scale(0.98); background: var(--surface-strong); }

/* ---------- Confirm dialog ---------- */
.confirm-modal {
  align-items: center !important;
  z-index: 200; /* sits above workout modal (100) and timer sheet (110) */
}
.confirm-dialog {
  position: relative;
  width: calc(100% - 40px);
  max-width: 340px;
  padding: 26px 22px 18px;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
  z-index: 1;
  animation: confirmIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes confirmIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.confirm-icon {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 12px;
}
.confirm-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
  color: var(--text);
}
.confirm-message {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 20px;
}
.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.confirm-btn {
  padding: 14px 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.18s ease;
}
.confirm-btn:active { transform: scale(0.97); }
.confirm-btn.cancel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
}
.confirm-btn.cancel:active { background: rgba(255, 255, 255, 0.10); }
.confirm-btn.primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 6px 18px rgba(255, 61, 127, 0.30);
}
.confirm-btn.primary.danger {
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}

/* Update banner — appears when the server has a newer build than the loaded page */
.update-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(255, 61, 127, 0.40);
  max-width: calc(100% - 24px);
  animation: updateBannerIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.update-banner[hidden] { display: none; }
.update-banner-icon { display: inline-flex; align-items: center; }
.update-banner-icon svg { width: 18px; height: 18px; display: block; }
.update-banner-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-banner-btn {
  background: white;
  color: #c2185b;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.2px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease;
}
.update-banner-btn:active { transform: scale(0.95); }
.update-banner-close {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: none;
  border-radius: 50%;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  font-family: inherit;
  flex-shrink: 0;
}
@keyframes updateBannerIn {
  from { opacity: 0; transform: translate(-50%, -120%); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 200;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Larger screens */
@media (min-width: 700px) {
  .app { padding-top: 32px; }
  .stats { gap: 14px; }
  .stat-card { padding: 18px 16px; }
  .stat-value { font-size: 26px; }
}

/* ---------- Tabs (mobile: fixed bottom dock with icon-over-label) ----------
   Sits as close to the bottom edge as possible while clearing the iOS
   home-indicator area via env(safe-area-inset-bottom). */
.tabs {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
  left: 12px;
  right: 12px;
  z-index: 50;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: rgba(15, 10, 31, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  margin-bottom: 0;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 22px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  transition: all 0.22s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}
.tab:active { transform: scale(0.95); }
.tab.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 6px 16px rgba(255, 61, 127, 0.40);
}
.tab.active .tab-icon { color: white; }
.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
}
.tab-icon svg { width: 18px; height: 18px; display: block; }

/* ---------- Views ---------- */
.view { display: none; animation: fadeView 0.3s ease; }
.view.active { display: block; }
@keyframes fadeView {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Section header ---------- */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.section-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ---------- Body part grid ---------- */
.body-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 380px) {
  .body-grid { grid-template-columns: 1fr; }
}

.body-card {
  position: relative;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
  min-height: 130px;
}
.body-card:active { transform: scale(0.97); background: var(--surface-strong); }
.body-card::before {
  content: "";
  position: absolute;
  top: -30%; right: -30%;
  width: 80%; height: 80%;
  background: var(--gradient-primary);
  opacity: 0.12;
  border-radius: 50%;
  filter: blur(20px);
  pointer-events: none;
}
.body-card:nth-child(2n)::before { background: var(--gradient-cool); opacity: 0.14; }
.body-card:nth-child(3n)::before { background: var(--gradient-warm); opacity: 0.14; }

.body-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.body-card-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px;
  background: rgba(255, 61, 127, 0.12);
  color: var(--accent-1);
}
.body-card-icon svg { width: 22px; height: 22px; display: block; }
.body-card-trend {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-dim);
}
.body-card-trend.up   { color: #4ade80; background: rgba(74, 222, 128, 0.15); }
.body-card-trend.down { color: #f87171; background: rgba(248, 113, 113, 0.18); }

.body-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  position: relative;
}
.body-card-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  position: relative;
}
.body-card-num {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.body-card-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
.body-card-num.empty {
  background: none;
  -webkit-text-fill-color: var(--text-muted);
  color: var(--text-muted);
  font-size: 18px;
}

/* Mini sparkline inside card */
.body-card-spark {
  position: relative;
  height: 22px;
  margin-top: auto;
}
.body-card-spark svg { width: 100%; height: 100%; display: block; }

/* Add custom part button */
.add-part-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
}
.add-part-btn:active { transform: scale(0.98); background: var(--surface-strong); color: var(--text); }

/* ---------- Body part history sheet ---------- */
.part-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.part-head-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--gradient-primary);
  display: grid; place-items: center;
  font-size: 24px;
  color: white;
  box-shadow: var(--shadow-glow);
}
.part-head-icon svg { width: 26px; height: 26px; display: block; }
.part-head-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.part-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.part-summary-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.part-current {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.part-current-unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dim);
}
.part-trend {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  white-space: nowrap;
}
.part-trend.up   { color: #4ade80; background: rgba(74, 222, 128, 0.15); }
.part-trend.down { color: #f87171; background: rgba(248, 113, 113, 0.18); }
.part-trend.flat { color: var(--text-dim); }

/* Chart */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px 8px;
  margin-bottom: 16px;
  min-height: 140px;
}
.chart-wrap.empty {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}
.chart-wrap svg { width: 100%; height: 130px; display: block; }
.chart-bar { transition: opacity 0.2s ease; }
.chart-bar:hover { opacity: 0.85; }
.chart-label {
  font-size: 9px;
  fill: var(--text-muted);
  text-anchor: middle;
}
.chart-value {
  font-size: 9px;
  fill: var(--text-dim);
  text-anchor: middle;
  font-weight: 700;
}

/* Block button */
.btn-block { width: 100%; margin-bottom: 10px; }
.btn-block span { font-size: 18px; margin-right: 4px; }

/* Mark-as-completed full-width button (workout modal) */
.btn-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.32);
  transition: transform 0.15s ease, box-shadow 0.18s ease, opacity 0.2s ease;
  font-family: inherit;
}
.btn-complete:active { transform: scale(0.98); }
.btn-complete svg { width: 20px; height: 20px; display: block; }
.btn-complete.completed {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  box-shadow: none;
  cursor: default;
}
.btn-complete.completed:active { transform: none; }

/* "Inactive" state — workout has unfilled exercises. Visually muted but
   still clickable so we can show the "Beende dein Training zuerst" modal. */
.btn-complete.inactive {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
  opacity: 0.85;
}
.btn-complete.inactive svg { opacity: 0.5; }

/* Edit / delete part toolbar */
.part-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.part-tool {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s ease;
}
.part-tool:active { transform: scale(0.96); background: var(--surface-strong); }
.part-tool.danger { color: #f87171; border-color: rgba(248, 113, 113, 0.3); }

/* History list */
.history-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.history-item:active { transform: scale(0.98); background: var(--surface-strong); }

.history-month {
  width: 44px;
  flex-shrink: 0;
  text-align: center;
}
.history-month-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.history-month-day {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.history-body { flex: 1; min-width: 0; }
.history-value {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.history-value-unit { font-size: 13px; color: var(--text-dim); margin-left: 3px; }
.history-notes {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.history-delta {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  white-space: nowrap;
}
.history-delta.up   { color: #4ade80; background: rgba(74, 222, 128, 0.15); }
.history-delta.down { color: #f87171; background: rgba(248, 113, 113, 0.18); }

/* ---------- Measurement modal helpers ---------- */
.form-input.static {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  cursor: default;
}
.value-input {
  position: relative;
  display: flex;
  align-items: center;
}
.value-input .form-input { padding-right: 48px; }
.value-unit {
  position: absolute;
  right: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  pointer-events: none;
}

/* Simple icon grid (parts modal) */
.icon-grid.simple {
  max-height: 160px;
  margin-top: 8px;
}

/* ---------- Exercises in workout modal ---------- */
.exercises-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.exercises-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.exercises-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exercises-list:empty { display: none; }

.exercise-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: cardIn 0.25s ease;
}
.exercise-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.exercise-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.3;
}
.exercise-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.exercise-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.exercise-row-actions {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.exercise-swap {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(124, 92, 255, 0.15);
  color: var(--accent-3);
  display: grid; place-items: center;
  transition: transform 0.15s ease, background 0.18s ease;
  border: none;
  cursor: pointer;
}
.exercise-swap:active { transform: scale(0.9); background: rgba(124, 92, 255, 0.30); }
.exercise-swap svg { width: 14px; height: 14px; display: block; }
.exercise-remove {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  font-size: 14px;
  font-weight: 700;
  display: grid; place-items: center;
  transition: transform 0.15s ease;
}
.exercise-remove:active { transform: scale(0.9); }

.sets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sets-header {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 28px;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 2px;
}
.sets-header span:first-child { text-align: center; }
.sets-header span:nth-child(2),
.sets-header span:nth-child(3) { text-align: left; padding-left: 4px; }

.set-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 28px;
  gap: 8px;
  align-items: center;
}
.set-num-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  font-size: 12px;
  font-weight: 800;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(255, 61, 127, 0.35);
}
.set-input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.set-input::-webkit-outer-spin-button,
.set-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.set-input:focus { border-color: var(--accent-1); background: var(--surface-strong); }

.set-remove {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 700;
  display: grid; place-items: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.set-remove:active { transform: scale(0.9); background: rgba(248, 113, 113, 0.18); color: #f87171; }

.add-set-btn {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-1);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 61, 127, 0.10);
  border: 1px solid rgba(255, 61, 127, 0.25);
  transition: all 0.15s ease;
}
.add-set-btn:active { transform: scale(0.95); background: rgba(255, 61, 127, 0.20); }

.btn-add-exercise {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
}
.btn-add-exercise:active { transform: scale(0.98); background: var(--surface-strong); color: var(--text); border-color: var(--accent-1); }

/* ---------- Exercise Picker ---------- */
.picker-sheet {
  display: flex;
  flex-direction: column;
  height: 92vh;
  height: 92dvh;
  overflow: hidden; /* outer doesn't scroll — only the picker-list inside */
}
.picker-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.picker-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.picker-filters::-webkit-scrollbar { display: none; }
.picker-filter {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  transition: all 0.18s ease;
}
.picker-filter.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}

.picker-status {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.picker-status.error { color: #f87171; }

.picker-list {
  flex: 1;
  min-height: 0; /* allow flex shrink so overflow-y works on iOS */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
}
.picker-list::-webkit-scrollbar { width: 4px; }
.picker-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  text-align: left;
}
.picker-item:active { transform: scale(0.98); background: var(--surface-strong); }

.picker-item-icon {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--gradient-primary);
  display: grid; place-items: center;
  font-size: 18px;
  color: white;
}
.picker-item-icon svg { width: 20px; height: 20px; display: block; }
.picker-item-body { flex: 1; min-width: 0; }
.picker-item-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.picker-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.picker-item-add {
  font-size: 18px;
  color: var(--accent-1);
  font-weight: 700;
}

/* ---------- Stats view ---------- */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stats-overview .stat-card { padding: 14px 12px; }

.exercise-stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exercise-stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  text-align: left;
}
.exercise-stats-row:active { transform: scale(0.98); background: var(--surface-strong); }

.exercise-stats-icon {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: grid; place-items: center;
  font-size: 22px;
  color: white;
  box-shadow: 0 4px 14px rgba(255, 61, 127, 0.3);
}
.exercise-stats-icon svg { width: 24px; height: 24px; display: block; }
.exercise-stats-row:nth-child(3n+2) .exercise-stats-icon { background: var(--gradient-cool); box-shadow: 0 4px 14px rgba(0, 217, 255, 0.25); }
.exercise-stats-row:nth-child(3n+3) .exercise-stats-icon { background: var(--gradient-warm); box-shadow: 0 4px 14px rgba(124, 92, 255, 0.30); }

.exercise-stats-body { flex: 1; min-width: 0; }
.exercise-stats-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exercise-stats-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.exercise-stats-pr {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 61, 127, 0.12);
  color: var(--accent-1);
  white-space: nowrap;
}

/* PR cards */
.pr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.pr-card {
  position: relative;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  overflow: hidden;
}
.pr-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.18;
}
.pr-1::before { background: var(--gradient-primary); }
.pr-2::before { background: var(--gradient-cool); }
.pr-3::before { background: var(--gradient-warm); }

.pr-label {
  position: relative;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pr-value {
  position: relative;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

/* ---------- Video player ---------- */
.video-sheet { padding-bottom: calc(var(--safe-bottom) + 16px); }
.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  margin-bottom: 12px;
  box-shadow: var(--shadow-md);
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.video-attribution {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 10px;
}
.video-attribution a {
  color: var(--accent-1);
  text-decoration: none;
  font-weight: 600;
}
.video-description {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.video-description:empty { display: none; }

/* Picker row video badge */
.picker-item-video {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px;
  background: rgba(255, 61, 127, 0.15);
  color: var(--accent-1);
  border: 1px solid rgba(255, 61, 127, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.18s ease;
  margin-right: 4px;
}
.picker-item-video:active { transform: scale(0.88); background: rgba(255, 61, 127, 0.30); }

/* Play button on workout exercise rows + stats sheet header */
.btn-play {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px;
  background: var(--gradient-primary);
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease;
  box-shadow: 0 4px 12px rgba(255, 61, 127, 0.35);
}
.btn-play:active { transform: scale(0.9); }
.exercise-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Push the play button to the right edge of the stats sheet header */
.part-head .btn-play { margin-left: auto; }

/* ================================================================
   AUTH VIEW (Login / Register)
   Hero photo background, dark gradient overlay, white form on top.
   ================================================================ */
.auth-view {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.auth-view[hidden] { display: none; }

.auth-content {
  position: relative;
  z-index: 2;
  padding: 28px 28px calc(var(--safe-bottom) + 28px);
  color: white;
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
}
.auth-brand-logo {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: var(--gradient-primary);
  color: white;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(255, 61, 127, 0.45);
}
.auth-brand-logo svg { width: 18px; height: 18px; }
.auth-brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.auth-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 8px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.auth-subtitle {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 28px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  opacity: 0.85;
}
.auth-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.18s ease, background 0.2s ease;
}
.auth-input::placeholder { color: rgba(255, 255, 255, 0.45); font-weight: 500; }
.auth-input:focus {
  border-color: white;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.10);
}

.auth-submit {
  margin-top: 6px;
  padding: 16px;
  border-radius: 16px;
  background: white;
  color: #1a1a1a;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0,0,0,0.30);
  transition: transform 0.15s ease;
}
.auth-submit:active { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-switch {
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
}
.auth-switch-btn {
  background: none;
  border: none;
  color: white;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 4px;
  text-decoration: underline;
}

@media (min-width: 768px) {
  .auth-view { justify-content: center; }
  .auth-content {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 28px;
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    margin: 40px auto;
    padding: 32px;
  }
}

body.auth-active { overflow: hidden; }

/* ================================================================
   ONBOARDING — multi-step (Splash → Profil → Gewicht → Größe → Ziel)
   Always rendered light-mode regardless of theme.
   ================================================================ */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #f4f6f7;
  color: #1a1a1a;
  overflow: hidden;
}
.onboarding[hidden] { display: none; }
body.onboarding-active { overflow: hidden; }

/* Step screens — single one visible at a time */
.ob-screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  animation: obSlideIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.ob-screen.active { display: flex; }
@keyframes obSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- Splash ---------- */
.splash-screen {
  padding: 0 !important;
  overflow: hidden;
}
.splash-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  border-radius: 0;
}
.splash-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.25) 50%, rgba(0,0,0,0.85) 100%);
}
.splash-content {
  position: absolute;
  left: 28px; right: 28px;
  top: calc(var(--safe-top) + 60px);
  color: white;
  z-index: 2;
}
.splash-title {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1.2px;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.splash-subtitle {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  opacity: 0.9;
  max-width: 280px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.splash-cta {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 32px);
  right: 28px;
  height: 60px;
  padding: 0 24px 0 18px;
  border-radius: 999px;
  background: rgba(255,255,255,0.95);
  color: #1a1a1a;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,0.30);
  z-index: 2;
  transition: transform 0.18s ease;
}
.splash-cta:active { transform: scale(0.96); }
.splash-cta svg {
  width: 22px; height: 22px;
  background: #1a1a1a;
  color: white;
  border-radius: 50%;
  padding: 5px;
  box-sizing: border-box;
}

/* ---------- Form steps (Profil / Gewicht / Größe / Ziel) ---------- */
.form-step {
  background: #f4f6f7;
}
.step-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  padding-top: 8px;
}
.step-progress {
  display: flex;
  gap: 6px;
  flex: 1;
  max-width: 320px;
}
.dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(0,0,0,0.12);
  transition: background 0.25s ease;
}
.dot.active {
  background: #1a1a1a;
}

.step-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-align: center;
  margin-bottom: 8px;
  color: #1a1a1a;
}
.step-sub {
  font-size: 13px;
  color: rgba(26,26,26,0.6);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.5;
}
/* When step-sub is used inside a modal sheet (plan picker, goal picker, etc.)
   it sits on the app's dark/light surface — use the theme-aware text colour
   instead of the onboarding-specific dark grey. */
.modal-sheet .step-sub { color: var(--text-dim); }

/* Step 1 fields (Name + Age) */
.step-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 360px;
  width: 100%;
  margin: 0 auto;
}
.ob-field { display: flex; flex-direction: column; gap: 8px; }
/* Base .ob-label — used by the profile sheet */
.ob-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}
/* Base .ob-input — used by the profile sheet (dark theme) */
.ob-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.ob-input::placeholder { color: var(--text-muted); font-weight: 400; }
.ob-input:focus {
  border-color: var(--accent-1);
  background: var(--surface-strong);
  box-shadow: 0 0 0 4px rgba(255, 61, 127, 0.12);
}

/* Profile-sheet segmented control + optional label suffix */
.ob-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.ob-seg {
  padding: 12px 8px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}
.ob-seg.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 14px rgba(255, 61, 127, 0.30);
  transform: translateY(-1px);
}
.ob-optional {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}

/* Override .ob-input inside the onboarding flow — light theme */
.onboarding .ob-input {
  background: white;
  border: 1px solid rgba(0,0,0,0.08);
  color: #1a1a1a;
  font-weight: 600;
  padding: 14px 18px;
}
.onboarding .ob-input::placeholder { color: rgba(26,26,26,0.3); font-weight: 500; }
.onboarding .ob-input:focus {
  border-color: #1a1a1a;
  background: white;
  box-shadow: 0 0 0 4px rgba(26,26,26,0.05);
}
.onboarding .ob-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(26,26,26,0.6);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Unit toggle (kg/lb, cm/in) */
.ob-unit-toggle {
  display: inline-flex;
  align-self: center;
  background: rgba(0,0,0,0.05);
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.ob-unit-toggle button {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(26,26,26,0.6);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ob-unit-toggle button.active {
  background: #1a1a1a;
  color: white;
}

/* Big colored value card (weight/height) */
.ob-value-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 16px;
  border-radius: 28px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.ob-card-yellow { background: #f4ed7d; }
.ob-card-mint   { background: #c9e8e1; }

.ob-value-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.ob-value-num {
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -3px;
  color: #1a1a1a;
}
.ob-value-unit {
  font-size: 22px;
  font-weight: 700;
  color: rgba(26,26,26,0.7);
}

/* Horizontal ruler */
.ob-ruler {
  position: relative;
  width: 100%;
  height: 70px;
  margin-top: 12px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 12%, black 88%, transparent 100%);
          mask-image: linear-gradient(to right, transparent 0%, black 12%, black 88%, transparent 100%);
}
.ob-ruler::after {
  /* center indicator */
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 3px;
  height: 38px;
  background: #1a1a1a;
  border-radius: 2px;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
}
.ob-ruler-track {
  display: flex;
  align-items: flex-start;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
}
.ob-ruler-track::-webkit-scrollbar { display: none; }
.ob-ruler-tick {
  flex-shrink: 0;
  width: 12px;
  height: 100%;
  scroll-snap-align: center;
  position: relative;
}
.ob-ruler-tick::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1.5px;
  height: 16px;
  background: rgba(26,26,26,0.35);
  transform: translateX(-50%);
  border-radius: 1px;
}
.ob-ruler-tick.major::before {
  height: 28px;
  width: 2px;
  background: rgba(26,26,26,0.7);
}
.ob-ruler-tick .tick-label {
  position: absolute;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: rgba(26,26,26,0.55);
  white-space: nowrap;
}

/* Goals (step 4) */
.ob-goals {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  overflow-y: auto;
}
.ob-goal {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: white;
  border: 2px solid rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-align: left;
  width: 100%;
}
.ob-goal:active { transform: scale(0.99); }
.ob-goal.selected {
  border-color: #1a1a1a;
  background: white;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.ob-goal img {
  width: 56px; height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}
.goal-label {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
}
.goal-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: transparent;
  transition: all 0.2s ease;
}
.goal-check svg { width: 16px; height: 16px; }
.ob-goal.selected .goal-check {
  background: #1a1a1a;
  color: white;
}

/* Step navigation buttons (back + next) */
.step-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  max-width: 380px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.step-back-btn {
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: 999px;
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  color: #1a1a1a;
  display: grid; place-items: center;
  cursor: pointer;
  transition: all 0.18s ease;
}
.step-back-btn:active { transform: scale(0.94); }
.step-back-btn svg { width: 18px; height: 18px; }

.step-next-btn {
  flex: 1;
  height: 56px;
  border-radius: 999px;
  background: #1a1a1a;
  color: white;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}
.step-next-btn:active { transform: scale(0.98); }
.step-next-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.next-chevrons {
  font-size: 16px;
  letter-spacing: -2px;
  font-weight: 700;
  opacity: 0.85;
}

/* Larger viewports — keep onboarding centered with reasonable width */
@media (min-width: 768px) {
  .form-step {
    align-items: center;
  }
  .form-step .step-progress { max-width: 320px; }
  .form-step .step-title,
  .form-step .step-sub { max-width: 480px; }
  .ob-value-card {
    max-width: 460px;
    width: 100%;
    align-self: center;
  }
}

/* ================================================================
   HYROX SIM QUICK-START (Workouts view top)
   ================================================================ */
.hyrox-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #ff6b3d 0%, #ff3d7f 70%, #7c5cff 100%);
  border: none;
  color: white;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(255, 107, 61, 0.30);
  transition: transform 0.15s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}
.hyrox-cta::before {
  content: "";
  position: absolute;
  top: -40%; right: -20%;
  width: 60%; height: 180%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 60%);
  pointer-events: none;
}
.hyrox-cta:hover { transform: translateY(-1px); box-shadow: 0 16px 40px rgba(255, 107, 61, 0.40); }
.hyrox-cta:active { transform: scale(0.99); }

.hyrox-cta.glutes-cta {
  background: linear-gradient(135deg, #ec4899 0%, #d946ef 50%, #8b5cf6 100%);
  box-shadow: 0 12px 30px rgba(236, 72, 153, 0.30);
}
.hyrox-cta.glutes-cta:hover { box-shadow: 0 16px 40px rgba(236, 72, 153, 0.40); }

.hyrox-cta.plan-cta {
  background: linear-gradient(135deg, #06b6d4 0%, #6366f1 50%, #8b5cf6 100%);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.30);
}
.hyrox-cta.plan-cta:hover { box-shadow: 0 16px 40px rgba(99, 102, 241, 0.40); }

/* Trainingsziel picker */
.goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.goal-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 2px solid var(--border);
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  color: var(--text);
}
.goal-pick:active { transform: scale(0.98); }
.goal-pick.active {
  border-color: var(--accent-1);
  background: rgba(255, 61, 127, 0.08);
  box-shadow: 0 6px 18px rgba(255, 61, 127, 0.20);
}
.goal-pick img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
}
.goal-pick-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.goal-pick-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

/* Plan focus picker grid */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.plan-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  color: var(--text);
}
.plan-card:active { transform: scale(0.98); }
.plan-card.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(255, 61, 127, 0.35);
}
.plan-card-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: rgba(255, 61, 127, 0.12);
  color: var(--accent-1);
  display: grid; place-items: center;
}
.plan-card.active .plan-card-icon {
  background: rgba(255, 255, 255, 0.20);
  color: white;
}
.plan-card-icon svg { width: 20px; height: 20px; display: block; }
.plan-card-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.plan-card-sub {
  font-size: 11px;
  opacity: 0.72;
  font-weight: 600;
}
.hyrox-cta-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  display: grid; place-items: center;
  font-size: 22px;
  color: #ffffff;
  position: relative;
}
.hyrox-cta-icon svg { width: 24px; height: 24px; display: block; }
.hyrox-cta-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  position: relative;
}
.hyrox-cta-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.hyrox-cta-sub {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}
.hyrox-cta-arrow {
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  opacity: 0.85;
  position: relative;
}

/* ================================================================
   WEEKLY ACTIVITY CARD (Workouts view top)
   ================================================================ */
.activity-card {
  position: relative;
  padding: 18px 18px 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 61, 127, 0.08) 0%, rgba(124, 92, 255, 0.06) 100%), var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  margin-bottom: 16px;
  overflow: hidden;
}
.activity-card[hidden] { display: none; }
.activity-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.activity-card-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  margin-bottom: 2px;
}
.activity-card-sub {
  font-size: 12px;
  color: var(--text-dim);
}
.activity-streak {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-1);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 61, 127, 0.12);
  white-space: nowrap;
}
.activity-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: flex-end;
  height: 78px;
}
.activity-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}
.activity-bar-track {
  flex: 1;
  width: 100%;
  max-width: 22px;
  display: flex;
  align-items: flex-end;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  min-height: 8px;
}
.activity-bar-fill {
  width: 100%;
  background: var(--gradient-primary);
  border-radius: 6px;
  transition: height 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  min-height: 4px;
}
.activity-day.today .activity-bar-track { background: rgba(255, 61, 127, 0.10); }
.activity-day.today .activity-day-label { color: var(--accent-1); font-weight: 800; }
.activity-day-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ================================================================
   STATS RANGE TABS (Day / Week / Month / All)
   ================================================================ */
.range-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 18px;
}
.range-tab {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.range-tab.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 61, 127, 0.30);
}

/* ================================================================
   PROFILE / SETTINGS VIEW
   Full-screen settings page replacing the modal sheet on the Profil tab.
   ================================================================ */
#viewProfile {
  padding-top: 8px;
}
.settings-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.settings-avatar-wrap {
  position: relative;
  width: 96px; height: 96px;
  margin-bottom: 14px;
}
.settings-avatar-lg {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gradient-primary);
  color: white;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease;
  font-family: inherit;
}
.settings-avatar-lg:active { transform: scale(0.96); }
.settings-avatar-edit {
  position: absolute;
  bottom: 0; right: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 2.5px solid var(--bg-1);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.18s ease;
  z-index: 2;
}
.settings-avatar-edit:active { transform: scale(0.92); }
.settings-avatar-edit svg { width: 14px; height: 14px; display: block; }
.settings-avatar-remove {
  position: absolute;
  top: 0; right: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.95);
  border: 2px solid var(--bg-1);
  color: white;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease;
  z-index: 2;
}
.settings-avatar-remove:active { transform: scale(0.92); }
.settings-avatar-remove svg { width: 12px; height: 12px; display: block; }

/* Image rendering inside any of the avatar containers */
.avatar-text,
.sidebar-user-avatar,
.settings-avatar-lg,
.profile-avatar-lg,
.cal-day-icon { overflow: hidden; }
.avatar-text img,
.sidebar-user-avatar img,
.settings-avatar-lg img,
.profile-avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: inherit;
  image-orientation: from-image; /* respect EXIF rotation on iPhone photos */
}
.settings-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.settings-meta {
  font-size: 13px;
  color: var(--text-dim);
}
.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0 16px;
  margin: 22px 0 8px;
}
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--text);
  border: none;
  cursor: pointer;
  transition: background 0.18s ease;
  text-align: left;
  width: 100%;
}
.settings-row:active { background: var(--surface-strong); }
.settings-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255, 61, 127, 0.12);
  color: var(--accent-1);
  flex-shrink: 0;
}
.settings-row-icon svg { width: 16px; height: 16px; display: block; }
.settings-row-icon .icon-sun { display: none; }
[data-theme="light"] .settings-row-icon .icon-moon { display: none; }
[data-theme="light"] .settings-row-icon .icon-sun  { display: block; }
.settings-row-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}
.settings-row-value {
  font-size: 13px;
  color: var(--text-dim);
}
.settings-row-arrow {
  font-size: 22px;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1;
}

.settings-row.danger { background: var(--surface); }
.settings-row.danger .settings-row-icon {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}
.settings-row.danger .settings-row-label { color: #f87171; }

.settings-version {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 32px;
  margin-bottom: 16px;
}

/* ================================================================
   PROFILE — header avatar + sheet
   ================================================================ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-btn {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gradient-primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.3px;
  border: none;
  box-shadow: 0 4px 14px rgba(255, 61, 127, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease;
}
.avatar-btn:active { transform: scale(0.92); }
/* Fill the round button so an inserted <img> has a proper square 1:1 box */
.avatar-text {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: inherit;
  overflow: hidden;
  line-height: 1;
}

/* Profile sheet — view + edit + logout */
.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 24px;
}
.profile-avatar-lg {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gradient-primary);
  color: white;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-glow);
}
.profile-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  text-align: center;
}
.profile-meta {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.profile-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0 16px;
}

.btn-logout {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: rgba(248, 113, 113, 0.10);
  color: #f87171;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid rgba(248, 113, 113, 0.25);
  transition: transform 0.15s ease, background 0.18s ease;
  cursor: pointer;
}
.btn-logout:active { transform: scale(0.98); background: rgba(248, 113, 113, 0.20); }

.profile-info-text {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  line-height: 1.5;
}

/* ================================================================
   DESKTOP DASHBOARD (>= 1024px)
   Sidebar + main-content layout. Violet color scheme.
   Mobile experience untouched below this breakpoint.
   ================================================================ */

/* Default — mobile: sidebar hidden, main-content is layout-transparent */
.sidebar { display: none; }
.main-content { display: contents; }

@media (min-width: 1024px) {

  /* --- Violet palette overrides --- */
  :root {
    --accent-1: #a855f7;     /* violet-500 */
    --accent-2: #6366f1;     /* indigo-500 */
    --accent-3: #7c3aed;     /* violet-600 */
    --accent-4: #06b6d4;     /* cyan-500 */
    --gradient-primary: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    --gradient-cool:    linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --gradient-warm:    linear-gradient(135deg, #c026d3 0%, #6366f1 100%);
    --shadow-glow:      0 12px 40px rgba(168, 85, 247, 0.40);
    --bg-1: #08081a;
    --bg-2: #11122c;
    --bg-3: #1d1a3d;
  }
  [data-theme="light"] {
    --bg-1: #f5f3ff;
    --bg-2: #ede9fe;
    --bg-3: #ddd6fe;
  }

  /* Tone down the radial bg blobs — too playful for desktop */
  body::before, body::after {
    width: 40%; height: 40%;
    opacity: 0.5;
    filter: blur(80px);
  }

  /* --- Layout: sidebar + main --- */
  .app {
    display: flex;
    align-items: stretch;
    max-width: none;
    padding: 0;
    min-height: 100vh;
  }

  .main-content {
    display: block;
    flex: 1;
    min-width: 0;
    max-width: 1400px;
    padding: 32px 40px 48px;
    margin: 0 auto;
  }

  /* --- Sidebar --- */
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 256px;
    flex-shrink: 0;
    padding: 24px 16px;
    background: linear-gradient(180deg, rgba(168, 85, 247, 0.06) 0%, rgba(0, 0, 0, 0) 100%), var(--surface);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px 24px;
    margin-bottom: 4px;
  }
  .sidebar-brand-name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .sidebar-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 24px;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.35);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
  }
  .sidebar-cta:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(168, 85, 247, 0.45); }
  .sidebar-cta:active { transform: scale(0.98); }
  .sidebar-cta svg { width: 16px; height: 16px; }

  .sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 0 12px;
    margin-bottom: 8px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
    background: transparent;
    border: none;
  }
  .sidebar-link:hover {
    background: rgba(168, 85, 247, 0.08);
    color: var(--text);
  }
  .sidebar-link.active {
    background: rgba(168, 85, 247, 0.18);
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--accent-1);
  }
  .sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    color: var(--accent-1);
    flex-shrink: 0;
  }
  .sidebar-icon svg { width: 18px; height: 18px; display: block; }
  .sidebar-link.active .sidebar-icon { color: white; }

  .sidebar-footer { margin-top: auto; }

  .sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .sidebar-user:hover { background: var(--surface-strong); border-color: var(--accent-1); }

  .sidebar-user-avatar {
    width: 36px; height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--gradient-primary);
    color: white;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.3px;
  }
  .sidebar-user-info {
    display: flex;
    flex-direction: column;
    text-align: left;
    min-width: 0;
    flex: 1;
  }
  .sidebar-user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar-user-action {
    font-size: 11px;
    color: var(--text-muted);
  }

  /* --- Hide mobile-only chrome on desktop --- */
  .tabs { display: none !important; }
  .fab  { display: none !important; }

  /* Hide brand block in header (it lives in sidebar now) */
  .header .brand { display: none; }
  .header-top {
    /* greeting becomes the page title */
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .brand-tag {
    font-size: 22px !important;
    font-weight: 800 !important;
    letter-spacing: -0.5px !important;
    color: var(--text) !important;
  }

  /* --- Bigger, more breathable layouts --- */
  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
  .stat-card { padding: 22px 20px; }
  .stat-value { font-size: 28px; }

  .toolbar { margin-bottom: 24px; }
  .search-input { padding-top: 14px; padding-bottom: 14px; font-size: 15px; }

  /* Workouts list — two columns on desktop */
  .notes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  /* Body grid — four columns */
  .body-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .body-card { min-height: 150px; }

  /* Section heads bigger on desktop */
  .section-title { font-size: 26px; }
  .section-sub   { font-size: 14px; }

  /* Stats overview cards: 3 columns */
  .stats-overview { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .pr-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }

  /* Modals slightly wider on desktop */
  .modal-sheet { max-width: 560px; border-radius: var(--radius-xl); }
  .picker-sheet { max-width: 640px; }

  /* Subtle violet glow on focus inputs */
  .form-input:focus,
  .ob-input:focus,
  .search-input:focus {
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
  }
}

/* Wider screens — more horizontal space for workouts */
@media (min-width: 1440px) {
  .notes { grid-template-columns: repeat(3, 1fr); }
  .body-grid { grid-template-columns: repeat(5, 1fr); }
}

/* Chart toggle */
.chart-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 12px;
}
.chart-toggle-btn {
  flex: 1;
  padding: 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  transition: all 0.2s ease;
}
.chart-toggle-btn.active {
  background: var(--gradient-primary);
  color: white;
}

/* Timer sheet always sits above the workout-edit modal when both are open */
#timerSheet { z-index: 110; }

/* ---------- Mobile: workout-edit modal full-screen, internal scroll only ---------- */
@media (max-width: 767px) {
  /* Workout-edit modal becomes a full-page view; body stays fixed behind it */
  #modal .modal-sheet {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    animation: slideUp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  }
  #modal .sheet-handle { display: none; }

  /* Sticky header with title + timer + close */
  #modal .modal-head {
    flex-shrink: 0;
    margin: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    z-index: 2;
  }
  #modal .modal-head h2 { font-size: 17px; }
  #modal .modal-timer-btn { padding: 6px 10px; font-size: 12px; }

  /* Only the form scrolls — body and the rest of the page do not move */
  #modal #workoutForm {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px calc(var(--safe-bottom) + 16px);
    gap: 16px;
  }
}
