/* ===================================================================
   FORJA FITNESS - APPLE NATIVE DESIGN SYSTEM
   Inspired by Apple Fitness+, Apple Health & iOS Human Interface Guidelines
   Minimalist, Ultra-Clean, Mobile-First PWA
   Dark Mode & Light Mode Supported
   =================================================================== */

:root {
  /* Apple OLED True Black & System Grouped Hierarchy (Default Dark) */
  --bg-deep: #000000;
  --bg-surface: #121214;
  --bg-card: #1c1c1e;
  --bg-card-hover: #242426;
  --bg-elevated: #2c2c2e;
  --bg-subtle: #3a3a3c;
  --bg-translucent: rgba(28, 28, 30, 0.82);
  --bg-dock: rgba(22, 22, 24, 0.86);

  /* Apple Hairline Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.14);
  --border-active: rgba(255, 255, 255, 0.28);
  --divider: rgba(255, 255, 255, 0.06);

  /* Apple Fitness Soft Accent Palette */
  --apple-green: #30d158;
  --apple-green-soft: rgba(48, 209, 88, 0.16);
  --apple-green-glow: rgba(48, 209, 88, 0.28);
  
  --volt: #30d158;
  --volt-glow: rgba(48, 209, 88, 0.25);
  --volt-text: #000000;

  --apple-pink: #ff375f;
  --apple-pink-soft: rgba(255, 55, 95, 0.16);
  
  --apple-orange: #ff9f0a;
  --apple-orange-soft: rgba(255, 159, 10, 0.16);
  --fire: #ff9f0a;
  --fire-glow: rgba(255, 159, 10, 0.28);
  --amber: #ffd60a;

  --apple-blue: #0a84ff;
  --apple-blue-soft: rgba(10, 132, 255, 0.16);
  --apple-cyan: #64d2ff;
  --apple-purple: #bf5af2;
  --apple-purple-soft: rgba(191, 90, 242, 0.16);

  --success: #30d158;
  --success-glow: rgba(48, 209, 88, 0.2);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.15);
  --info: #0a84ff;

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(235, 235, 245, 0.65);
  --text-muted: rgba(235, 235, 245, 0.40);
  --text-tertiary: rgba(235, 235, 245, 0.22);

  /* Apple Typography */
  --font-heading: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: -apple-system-monospaced, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Apple Squircles & Radii */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Safe Area Insets for iPhone / Mobile notch */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: 0px;

  --nav-height: 44px;
}

/* ===================================================================
   APPLE LIGHT MODE PALETTE (iOS Grouped / Apple Fitness Light)
   =================================================================== */
body.theme-light {
  --bg-deep: #f2f2f7;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f7fa;
  --bg-elevated: #e5e5ea;
  --bg-subtle: #d1d1d6;
  --bg-translucent: rgba(255, 255, 255, 0.85);
  --bg-dock: rgba(249, 249, 249, 0.90);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-highlight: rgba(0, 0, 0, 0.12);
  --border-active: rgba(0, 0, 0, 0.22);
  --divider: rgba(0, 0, 0, 0.06);

  --apple-green: #34c759;
  --apple-green-soft: rgba(52, 199, 89, 0.15);
  --apple-green-glow: rgba(52, 199, 89, 0.22);
  
  --volt: #34c759;
  --volt-glow: rgba(52, 199, 89, 0.2);
  --volt-text: #ffffff;

  --apple-orange: #ff9500;
  --apple-orange-soft: rgba(255, 149, 0, 0.15);
  --fire: #ff9500;
  --fire-glow: rgba(255, 149, 0, 0.25);

  --apple-blue: #007aff;
  --apple-blue-soft: rgba(0, 122, 255, 0.12);
  --apple-cyan: #32ade6;
  --apple-pink: #ff2d55;
  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, 0.12);

  --text-primary: #000000;
  --text-secondary: rgba(60, 60, 67, 0.65);
  --text-muted: rgba(60, 60, 67, 0.45);
  --text-tertiary: rgba(60, 60, 67, 0.25);
}

/* Base Reset & Anti-Overflow */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  max-width: 100vw;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  overflow-y: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* App Layout Frame */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-deep);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.95);
  overflow-x: hidden;
  box-sizing: border-box;
  transition: background-color 0.25s ease;
}

body.theme-light .app-container {
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.08);
}

/* ===================================================================
   APPLE TRANSLUCENT HEADER
   =================================================================== */
.app-header {
  height: calc(52px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 14px;
  padding-right: 14px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid var(--border-subtle);
  z-index: 50;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.25s ease, border-color 0.25s ease;
}

body.theme-light .app-header {
  background: rgba(249, 249, 249, 0.82);
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.12);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.brand-symbol {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--apple-green), #24ad47);
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--apple-green-glow);
  flex-shrink: 0;
}

.header-profile-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 4px 10px 4px 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 130px;
}

body.theme-light .header-profile-btn {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
}

.header-profile-btn:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.14);
}

body.theme-light .header-profile-btn:active {
  background: rgba(0, 0, 0, 0.12);
}

.profile-avatar-mini {
  font-size: 14px;
  line-height: 1;
}

.profile-name-mini {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.profile-caret {
  font-size: 9px;
  color: var(--text-muted);
  margin-left: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Badges & Buttons */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: var(--bg-elevated);
  border: 0.5px solid var(--border-highlight);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  flex-shrink: 0;
}

.streak-pill {
  background: var(--apple-orange-soft);
  border-color: rgba(255, 159, 10, 0.35);
  color: var(--apple-orange);
}

.streak-pill:active {
  transform: scale(0.94);
}

.flame-icon {
  font-size: 13px;
  display: inline-block;
  animation: pulse-flame 2s infinite ease-in-out;
}

@keyframes pulse-flame {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px var(--apple-orange)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 6px var(--apple-orange)); }
}

.icon-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  flex-shrink: 0;
}

body.theme-light .icon-btn {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(60, 60, 67, 0.8);
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.16);
}

body.theme-light .icon-btn:active {
  background: rgba(0, 0, 0, 0.12);
}

.icon-btn.active {
  color: var(--apple-green);
  background: var(--apple-green-soft);
}

/* ===================================================================
   MAIN CONTENT & VIEWS
   =================================================================== */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding-bottom: calc(var(--nav-height) + 16px);
}

.view-panel {
  display: none;
  padding: 16px 14px;
  width: 100%;
  box-sizing: border-box;
  animation: appleFadeIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.view-panel.active {
  display: block;
}

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

/* Apple iOS Large Title Section Header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.15;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 400;
}

/* ===================================================================
   TAB 1: HOY / WORKOUT VIEW (APPLE FITNESS STYLE)
   =================================================================== */
.today-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 16px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

body.theme-light .today-hero {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.today-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.meta-date {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--apple-green);
}

.routine-tag {
  background: var(--apple-green-soft);
  color: var(--apple-green);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.today-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.session-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

body.theme-light .btn-subtle {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(60, 60, 67, 0.8);
}

.btn-subtle:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.14);
}

body.theme-light .btn-subtle:active {
  background: rgba(0, 0, 0, 0.12);
}

/* Overall workout progress */
.workout-progress-box {
  margin-top: 10px;
}

.progress-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.progress-percent {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

body.theme-light .progress-bar-track {
  background: rgba(0, 0, 0, 0.08);
}

.progress-bar-fill {
  height: 100%;
  background: var(--apple-green);
  border-radius: var(--radius-full);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Rest Day Card (Apple Health recovery style) */
.rest-day-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 36px 20px;
  text-align: center;
  box-sizing: border-box;
  margin-bottom: 16px;
}

body.theme-light .rest-day-card {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.rest-icon-large {
  font-size: 52px;
  margin-bottom: 14px;
}

.rest-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.rest-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 22px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.rest-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Exercise Cards (Grouped Apple Health List Item) */
.exercises-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  box-sizing: border-box;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background-color 0.25s ease;
}

body.theme-light .exercise-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.exercise-card.completed {
  border-color: rgba(48, 209, 88, 0.35);
}

.exercise-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.ex-info-block {
  flex: 1;
  min-width: 0;
}

.ex-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.ex-badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.muscle-badge {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 6px;
}

.rest-time-badge {
  background: var(--apple-blue-soft);
  color: var(--apple-blue);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.rest-time-badge:active {
  opacity: 0.7;
}

.ex-target-text {
  font-size: 11px;
  color: var(--text-muted);
}

.ex-complete-stamp {
  font-size: 11px;
  font-weight: 700;
  color: var(--apple-green);
  background: var(--apple-green-soft);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

/* ===================================================================
   SETS TABLE (APPLE HEALTH / COMPACT MOBILE-FIRST)
   =================================================================== */
.sets-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  box-sizing: border-box;
}

.sets-table th {
  padding: 6px 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-align: center;
  border-bottom: 0.5px solid var(--border-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.th-set {
  width: 32px;
}

.th-weight {
  width: auto;
}

.th-reps {
  width: auto;
}

.th-check {
  width: 44px;
}

.sets-table td {
  padding: 6px 2px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 0.5px solid var(--divider);
  box-sizing: border-box;
}

.set-index-col {
  width: 32px;
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.set-weight-col, .set-reps-col {
  padding: 6px 2px;
}

.set-check-col {
  width: 44px;
  padding: 6px 2px;
}

/* Apple iOS Segmented Steppers */
.stepper-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: 100%;
  max-width: 102px;
  margin: 0 auto;
  box-sizing: border-box;
  height: 35px;
  transition: background-color 0.25s ease;
}

.set-reps-col .stepper-box {
  max-width: 88px;
}

.stepper-btn {
  width: 26px;
  height: 35px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  flex-shrink: 0;
  padding: 0;
  transition: all 0.15s;
}

.stepper-btn:active {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.stepper-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 35px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  -moz-appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Apple Circular Completion Button */
.btn-set-check {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-highlight);
  color: transparent;
  font-size: 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.btn-set-check:active {
  transform: scale(0.9);
}

.btn-set-check.completed {
  background: var(--apple-green);
  border-color: var(--apple-green);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(48, 209, 88, 0.35);
  transform: scale(1.04);
}

.set-row.row-completed {
  background: var(--apple-green-soft);
}

.set-row.row-completed .set-index-col {
  color: var(--apple-green);
}

/* Card Footer with Apple Text Actions */
.exercise-card-footer {
  padding: 8px 6px 2px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-link-action {
  background: transparent;
  border: none;
  color: var(--apple-blue);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: opacity 0.15s;
}

.btn-link-action:active {
  opacity: 0.6;
}

.btn-link-danger {
  color: var(--danger);
}

/* Extra Actions */
.extra-actions-row {
  margin: 14px 0;
}

.btn-subtle-full {
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  border: 1px dashed var(--border-highlight);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-subtle-full:active {
  background: var(--bg-elevated);
  border-color: var(--apple-green);
  color: var(--text-primary);
}

/* Apple Live Activity Finish Bar */
.finish-bar-container {
  margin-top: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

body.theme-light .finish-bar-container {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.finish-summary {
  display: flex;
  justify-content: space-around;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--border-subtle);
}

.summary-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.summary-metric .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.4px;
}

.summary-metric .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.btn-finish {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--apple-green);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(48, 209, 88, 0.3);
  transition: transform 0.15s, opacity 0.15s;
}

.btn-finish:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* ===================================================================
   FLOATING REST TIMER (APPLE DYNAMIC ISLAND / LIVE ACTIVITY)
   Stays sleek dark island in both dark and light modes for maximum contrast
   =================================================================== */
.rest-timer-bar {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 440px;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75);
  z-index: 100;
  padding: 8px 14px;
  box-sizing: border-box;
  animation: dynamicIslandSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dynamicIslandSlide {
  from { opacity: 0; transform: translate(-50%, -15px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.rest-timer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timer-ring-container {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg-circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 7;
}

.timer-fg-circle {
  fill: none;
  stroke: var(--apple-green);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear;
}

.timer-seconds-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
}

.timer-details {
  flex: 1;
  min-width: 0;
}

.timer-label {
  font-size: 10px;
  color: var(--apple-green);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

.timer-exercise-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.timer-quick-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.timer-adj-btn, .timer-pause-btn, .timer-skip-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: var(--radius-full);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.timer-adj-btn:active, .timer-pause-btn:active, .timer-skip-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.22);
}

.timer-skip-btn {
  background: var(--apple-green-soft);
  color: var(--apple-green);
}

/* ===================================================================
   TAB 2: RUTINAS
   =================================================================== */
.routines-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.routine-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  transition: all 0.2s;
  box-sizing: border-box;
}

body.theme-light .routine-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.routine-card.active-routine {
  border-color: rgba(48, 209, 88, 0.35);
  box-shadow: 0 4px 18px rgba(48, 209, 88, 0.08);
}

.routine-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.routine-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.active-pill {
  background: var(--apple-green-soft);
  color: var(--apple-green);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.routine-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.routine-days-summary {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--bg-elevated);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.routine-day-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.routine-day-item.rest-day {
  color: var(--text-muted);
}

.routine-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===================================================================
   TAB 3: CALENDARIO & HISTORIAL (APPLE CALENDAR AESTHETIC)
   =================================================================== */
.calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 16px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

body.theme-light .calendar-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.calendar-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.calendar-month-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.nav-arrow-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

body.theme-light .nav-arrow-btn {
  background: rgba(0, 0, 0, 0.06);
}

.nav-arrow-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.16);
}

body.theme-light .nav-arrow-btn:active {
  background: rgba(0, 0, 0, 0.12);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.calendar-cell {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.calendar-cell.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.calendar-cell.is-today {
  border-color: var(--apple-green);
  color: var(--text-primary);
  font-weight: 700;
  background: var(--bg-subtle);
}

.calendar-cell.has-workout {
  background: var(--apple-green-soft);
  border-color: rgba(48, 209, 88, 0.4);
  color: var(--text-primary);
}

.calendar-cell.is-rest-day {
  background: var(--apple-orange-soft);
  border-color: rgba(255, 159, 10, 0.3);
}

.calendar-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-trained { background: var(--apple-green); }
.dot-rest { background: var(--apple-orange); }
.dot-today { background: var(--text-primary); }

/* History List */
.history-section {
  margin-top: 20px;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-bottom: 12px;
}

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

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

body.theme-light .history-card {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.history-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-routine-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-vol-badge {
  background: var(--bg-elevated);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--apple-green);
}

/* ===================================================================
   TAB 4: RACHA & STATS (APPLE FITNESS ACTIVITY RING LOOK)
   =================================================================== */
.streak-hero-card {
  background: radial-gradient(circle at 50% 25%, rgba(255, 159, 10, 0.12) 0%, var(--bg-card) 75%);
  border: 1px solid rgba(255, 159, 10, 0.25);
  border-radius: var(--radius-xl);
  padding: 28px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  margin-bottom: 18px;
  box-sizing: border-box;
}

body.theme-light .streak-hero-card {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

.streak-flame-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 4px;
}

.streak-fire-emoji {
  font-size: 48px;
  position: relative;
  z-index: 2;
  animation: pulse-flame 2s infinite ease-in-out;
}

.streak-fire-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  background: radial-gradient(circle, rgba(255, 159, 10, 0.5) 0%, transparent 70%);
  filter: blur(12px);
  z-index: 1;
}

.streak-big-number {
  font-family: var(--font-heading);
  font-size: 58px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.streak-big-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--apple-orange);
  margin-top: 4px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.streak-status-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--apple-orange-soft);
  border: 1px solid rgba(255, 159, 10, 0.35);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 12px;
  color: var(--apple-orange);
  margin-bottom: 14px;
}

.streak-rule-explanation {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.rule-icon {
  font-size: 18px;
  flex-shrink: 0;
}

/* Apple Health Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: left;
  box-sizing: border-box;
}

body.theme-light .metric-card {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.metric-icon {
  font-size: 20px;
  margin-bottom: 8px;
  display: inline-block;
}

.metric-val {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-lbl {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 3px;
}

/* PRs Section */
.prs-section {
  margin-top: 16px;
}

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

.prs-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pr-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--apple-green);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

body.theme-light .pr-card {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pr-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.pr-stat {
  text-align: right;
}

.pr-weight {
  font-size: 15px;
  font-weight: 700;
  color: var(--apple-green);
  font-variant-numeric: tabular-nums;
}

.pr-1rm {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===================================================================
   TAB 5: HERRAMIENTAS (APPLE SEGMENTED CONTROLS - 3 BALANCED TABS)
   =================================================================== */
.tools-subnav {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  gap: 3px;
  width: 100%;
  box-sizing: border-box;
}

body.theme-light .tools-subnav {
  background: #e5e5ea;
  border: none;
}

.subnav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.theme-light .subnav-btn {
  color: rgba(60, 60, 67, 0.7);
}

.subnav-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

body.theme-light .subnav-btn.active {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.tool-pane {
  display: none;
}

.tool-pane.active {
  display: block;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 16px;
  box-sizing: border-box;
}

body.theme-light .tool-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.tool-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tool-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* Form Styles */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-group input, .input-group select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
}

.input-group input:focus, .input-group select:focus {
  outline: none;
  border-color: var(--apple-green);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.15);
}

.rm-result-box {
  background: var(--apple-green-soft);
  border: 1px solid rgba(48, 209, 88, 0.3);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  margin-bottom: 18px;
}

.rm-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--apple-green);
  text-transform: uppercase;
  display: block;
}

.rm-number {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  display: block;
}

.rm-table-wrapper {
  overflow-x: auto;
}

.rm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.rm-table th {
  padding: 8px 6px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 0.5px solid var(--border-subtle);
}

.rm-table td {
  padding: 8px 6px;
  border-bottom: 0.5px solid var(--divider);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.rm-table tr:hover td {
  color: var(--text-primary);
}

/* Exercise Library List */
.library-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.filter-pills-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
}

.pill-btn {
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.pill-btn.active {
  background: var(--apple-green);
  color: #ffffff;
  font-weight: 600;
}

.search-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--apple-green);
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.library-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lib-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.lib-item-muscle {
  font-size: 11px;
  color: var(--text-muted);
}

/* Backup & Server Info */
.backup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.system-info-box {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.system-info-box h4 {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.system-info-box code {
  color: var(--apple-green);
  background: rgba(0, 0, 0, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
}

body.theme-light .system-info-box code {
  background: rgba(0, 0, 0, 0.06);
}

/* ===================================================================
   APPLE-STYLE BOTTOM TAB BAR
   =================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0 !important;
  left: 0;
  right: 0;
  margin: 0 auto !important;
  width: 100%;
  max-width: 540px;
  height: var(--nav-height) !important;
  min-height: var(--nav-height);
  padding: 0 !important;
  background: var(--bg-dock);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border-top: 0.5px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  box-sizing: border-box;
  transition: background 0.25s ease, border-color 0.25s ease;
}

body.theme-light .bottom-nav {
  background: rgba(249, 249, 249, 0.90);
  border-top: 0.5px solid rgba(0, 0, 0, 0.12);
}

.nav-tab {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 0 2px 0 !important;
  margin: 0 !important;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav-tab:active {
  transform: scale(0.92);
}

.nav-tab.active {
  color: var(--apple-green);
}

.tab-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-icon svg {
  width: 20px;
  height: 20px;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.1px;
  margin: 0;
  padding: 0;
}

/* ===================================================================
   MODALS & BOTTOM SHEETS (APPLE IOS NATIVE SHEETS)
   =================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-backdrop.hidden {
  display: none !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 8px 18px 24px 18px;
  box-sizing: border-box;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-light .modal-card {
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Centered Apple Sheet Grabber Bar */
.sheet-grabber {
  width: 36px;
  height: 5px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 3px;
  margin: 6px auto 14px auto;
  display: block;
}

body.theme-light .sheet-grabber {
  background: rgba(60, 60, 67, 0.3);
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

body.theme-light .modal-close {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(60, 60, 67, 0.7);
}

.modal-close:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.2);
}

body.theme-light .modal-close:active {
  background: rgba(0, 0, 0, 0.12);
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-text, .input-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  box-sizing: border-box;
}

.input-text:focus, .input-textarea:focus {
  outline: none;
  border-color: var(--apple-green);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.15);
}

.input-textarea {
  min-height: 70px;
  resize: vertical;
}

.modal-footer-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-footer-actions .btn {
  flex: 1;
}

/* ===================================================================
   ROUTINE BUILDER & EDITOR (APPLE NATIVE DESIGN)
   =================================================================== */
.modal-card.modal-large {
  max-width: 620px;
  max-height: 92vh;
}

.days-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.days-editor-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.days-editor-title-wrap h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.days-count-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--apple-green);
  border: 0.5px solid var(--border-subtle);
}

.days-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.routine-days-editor-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.routine-day-editor-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transition: border-color 0.2s;
}

body.theme-light .routine-day-editor-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.day-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-badge-num {
  font-size: 12px;
  font-weight: 800;
  color: var(--apple-green);
  background: var(--apple-green-soft);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.day-title-wrap {
  flex: 1;
  min-width: 0;
}

.day-name-input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.day-name-input:focus {
  border-color: var(--apple-green);
  box-shadow: 0 0 0 2px var(--apple-green-soft);
}

.day-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.weekday-select-wrap select.weekday-select {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  outline: none;
  cursor: pointer;
}

.btn-icon-danger {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 0;
  transition: transform 0.1s, opacity 0.15s;
}

.btn-icon-danger:active {
  transform: scale(0.92);
}

/* Day Type Segmented Pill */
.day-type-segmented {
  display: flex;
  background: var(--bg-deep);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.day-type-segmented .segment-btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: calc(var(--radius-md) - 3px);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.day-type-segmented .segment-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

body.theme-light .day-type-segmented .segment-btn.active {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Rest Notice */
.day-rest-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--apple-purple-soft);
  border: 0.5px solid rgba(191, 90, 242, 0.25);
  border-radius: var(--radius-md);
}

.rest-emoji {
  font-size: 26px;
  line-height: 1;
}

.rest-text strong {
  display: block;
  font-size: 13px;
  color: var(--apple-purple);
  margin-bottom: 2px;
}

.rest-text p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Exercises edit list */
.day-exercises-edit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-day-exercises {
  text-align: center;
  padding: 16px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 0.5px dashed var(--border-highlight);
}

.empty-day-exercises p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Edit Exercise Card */
.edit-ex-card {
  background: var(--bg-elevated);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.edit-ex-card:hover {
  border-color: var(--border-highlight);
}

.edit-ex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.edit-ex-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.ex-order-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ex-name-and-muscle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.edit-ex-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.muscle-pill-sm {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--apple-blue-soft);
  color: var(--apple-blue);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.btn-icon-danger-sm {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
  padding: 0;
}

.btn-icon-danger-sm:hover,
.btn-icon-danger-sm:active {
  background: var(--danger-soft);
  color: var(--danger);
}

/* 4-Column Param Grid */
.edit-param-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 380px) {
  .edit-param-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.edit-param-box {
  background: var(--bg-card);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 4px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.edit-param-box .param-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.mini-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

.mini-step-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 0.5px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  user-select: none;
  transition: transform 0.08s, background-color 0.12s;
  flex-shrink: 0;
}

.mini-step-btn:active {
  transform: scale(0.90);
  background: var(--border-subtle);
}

.mini-step-input {
  width: 34px;
  height: 24px;
  background: transparent;
  border: none;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0;
  outline: none;
  box-sizing: border-box;
  -moz-appearance: textfield;
}

.mini-step-input::-webkit-outer-spin-button,
.mini-step-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mini-step-input.reps-input {
  width: 40px;
  font-size: 12px;
}

.rest-input-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.rest-input-wrap .sec-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-add-ex-dashed {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--border-highlight);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  color: var(--apple-green);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

body.theme-light .btn-add-ex-dashed {
  background: rgba(0, 0, 0, 0.02);
}

.btn-add-ex-dashed:hover,
.btn-add-ex-dashed:active {
  background: var(--apple-green-soft);
  border-color: var(--apple-green);
}

/* ===================================================================
   AI ROUTINE IMPORTER MODAL STYLES
   =================================================================== */
.ai-import-guide {
  background: var(--bg-card);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.ai-guide-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 10px;
  line-height: 1.4;
}

.ai-guide-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-import-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-deep);
  color: var(--text-primary);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.ai-import-textarea:focus {
  border-color: var(--apple-green);
}

.ai-preview-badge {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 0.5px solid var(--border-subtle);
}

.ai-preview-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-preview-days-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.preview-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--apple-green-soft);
  color: var(--apple-green);
  border: 0.5px solid rgba(48, 209, 88, 0.25);
}

.preview-chip.rest {
  background: var(--apple-purple-soft);
  color: var(--apple-purple);
  border-color: rgba(191, 90, 242, 0.25);
}

/* Celebration Modal (Apple Fitness Achievement style) */
.celebration-card {
  text-align: center;
  padding: 16px 20px 28px 20px;
}

.celebration-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--apple-green);
  background: var(--apple-green-soft);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.celebration-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.celebration-quote {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-style: italic;
}

.celebration-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.celeb-stat {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 10px;
}

.celeb-val {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  font-variant-numeric: tabular-nums;
}

.celeb-lbl {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
  display: block;
}

.celeb-prs-box {
  background: var(--apple-orange-soft);
  border: 1px solid rgba(255, 159, 10, 0.35);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 18px;
}

.prs-crown {
  font-size: 13px;
  font-weight: 700;
  color: var(--apple-orange);
  margin-bottom: 6px;
}

/* ===================================================================
   APPLE-STYLE FAMILY PIN LOCK & KEYPAD
   =================================================================== */
.screen-pin-lock {
  position: fixed;
  inset: 0;
  z-index: 500;
  background-color: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  animation: appleFadeIn 0.25s ease-out;
}

.screen-pin-lock.hidden {
  display: none !important;
}

.pin-lock-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.pin-brand-symbol {
  width: 60px;
  height: 60px;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--apple-green);
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.theme-light .pin-brand-symbol {
  background: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

.pin-heading {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.pin-subheading {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.4;
  min-height: 38px;
}

/* Dots Display */
.pin-dots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 24px;
  height: 24px;
}

.pin-dots-row.shake {
  animation: pinShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--border-active);
  background: transparent;
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pin-dot.filled {
  background: var(--apple-green);
  border-color: var(--apple-green);
  box-shadow: 0 0 10px var(--apple-green-glow);
  transform: scale(1.15);
}

.pin-error-msg {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 18px;
  animation: appleFadeIn 0.2s ease;
}

/* iOS Circular Numeric Keypad */
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 14px 18px;
  justify-content: center;
  align-items: center;
  margin-top: 6px;
}

.pin-key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

body.theme-light .pin-key {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.pin-key:active {
  transform: scale(0.90);
  background: var(--bg-elevated);
  border-color: var(--border-highlight);
}

body.theme-light .pin-key:active {
  background: #e5e5ea;
}

.pin-num {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

.pin-letters {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 1px;
}

.pin-key-backspace {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-size: 22px;
  color: var(--text-secondary);
}

.pin-key-backspace:active {
  color: var(--text-primary);
  transform: scale(0.88);
}

.pin-key-placeholder {
  width: 72px;
  height: 72px;
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-14px); }
  30%, 60%, 90% { transform: translateX(14px); }
}

/* ===================================================================
   APPLE PROFILE PICKER (APPLE TV / IPAD MULTI-PROFILE STYLE)
   =================================================================== */
.screen-profile-picker {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 250;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  animation: appleFadeIn 0.25s ease-out;
}

.screen-profile-picker.hidden {
  display: none !important;
}

.profile-picker-container {
  width: 100%;
  max-width: 440px;
  text-align: center;
  margin: auto;
}

.picker-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.picker-heading {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

.picker-subheading {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.profiles-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-sizing: border-box;
}

body.theme-light .profile-card {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.profile-card:active {
  transform: scale(0.96);
  background: var(--bg-elevated);
}

.profile-card-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body.theme-light .profile-card-avatar {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.profile-card-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.profile-card-streak {
  font-size: 11px;
  font-weight: 600;
  color: var(--apple-orange);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Profile Add Card */
.profile-add-card {
  background: rgba(28, 28, 30, 0.4);
  border: 1px dashed var(--border-highlight);
  border-radius: var(--radius-xl);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-sizing: border-box;
}

body.theme-light .profile-add-card {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.18);
}

.profile-add-card:active {
  transform: scale(0.96);
  background: var(--bg-elevated);
}

.profile-add-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.profile-add-label {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Profile Menu Actions List (Apple Inset Grouped style) */
.profile-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  box-sizing: border-box;
}

.menu-action-btn:active {
  background: var(--bg-subtle);
  transform: scale(0.98);
}

.menu-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.menu-text-block strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.menu-text-block p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.menu-action-danger {
  background: var(--danger-soft);
  border-color: rgba(255, 69, 58, 0.2);
}

.menu-action-danger strong {
  color: var(--danger);
}

/* Avatar Select Grid */
.avatar-select-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.avatar-pick-btn {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-sm);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.avatar-pick-btn:active {
  transform: scale(0.9);
}

.avatar-pick-btn.active {
  border-color: var(--apple-green);
  background: var(--apple-green-soft);
}

/* ===================================================================
   GENERIC BUTTONS & HELPERS (APPLE NATIVE CONTROLS)
   =================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-sizing: border-box;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.btn-primary {
  background: var(--apple-green);
  color: #ffffff;
  font-weight: 700;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.chip {
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--apple-green);
  color: #ffffff;
  font-weight: 600;
}

.picker-filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.picker-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.picker-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.picker-item:active {
  background: var(--bg-subtle);
  transform: scale(0.98);
}

.day-switcher-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-switch-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.day-switch-item:active {
  background: var(--bg-subtle);
}

.day-switch-item.active {
  border: 1px solid var(--apple-green);
  background: var(--apple-green-soft);
}

/* Toast Notifications (Apple iOS Capsule notification) */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: rgba(28, 28, 30, 0.95);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: toastPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

body.theme-light .toast {
  background: rgba(255, 255, 255, 0.95);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  color: #000000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

@keyframes toastPop {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.hidden {
  display: none !important;
}

/* ===================================================================
   RESPONSIVE TUNING FOR NARROW MOBILE PHONES (<= 375px)
   =================================================================== */
@media (max-width: 375px) {
  .app-header {
    padding-left: 10px;
    padding-right: 10px;
  }
  .session-title {
    font-size: 19px;
  }
  .stepper-box {
    max-width: 92px;
  }
  .set-reps-col .stepper-box {
    max-width: 80px;
  }
  .stepper-btn {
    width: 22px;
  }
  .stepper-input {
    font-size: 13px;
  }
  .btn-set-check {
    width: 32px;
    height: 32px;
  }
  .th-set {
    width: 28px;
  }
  .th-check {
    width: 38px;
  }
  .subnav-btn {
    font-size: 12px;
    padding: 8px 2px;
  }
}
