/* ====== CSS VARIABLES FOR DYNAMIC LAYOUT ====== */
:root{
  --header-height: calc(13vh + env(safe-area-inset-top, 0px));

  /* Height of the bar itself */
  --bottom-button-height: 8vh;

  /* iOS notches / home indicator */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  /* Bar + safe area combined */
  --bottom-button-total: calc(var(--bottom-button-height) + var(--safe-area-bottom));

  /* Use svh first on iOS, then dvh, then vh as fallback */
  --main-app-height-svh: calc(100svh - var(--header-height) - var(--bottom-button-total));
  --main-app-height-dvh: calc(100dvh - var(--header-height) - var(--bottom-button-total));
  --main-app-height:     calc(100vh  - var(--header-height) - var(--bottom-button-total));

  /* ====== MONOCHROME COLOR PALETTE (USER PROVIDED) ====== */
  /* Exact colors from user palette */
  --color-white: #FFFFFF;
  --color-black: #000000;
  --color-light-grey: #B0B0B0;
  --color-medium-grey: #7D7D7D;
  --color-dark-grey: #4D4D4D;
  
  /* Aliases for semantic use */
  --color-bg-dark: #000000;
  --color-bg-card: #000000;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #B0B0B0;
  --color-text-muted: #7D7D7D;
  --color-border: #4D4D4D;
  
  /* Gradients using palette */
  --gradient-dark: linear-gradient(135deg, #000000 0%, #000000 100%);
  --gradient-card: linear-gradient(135deg, #000000 0%, #000000 100%);
  --gradient-button: linear-gradient(135deg, #FFFFFF 0%, #ffffff 100%);
  --gradient-button-hover: linear-gradient(135deg, #ffffff 0%, #FFFFFF 100%);
  --gradient-header: linear-gradient(135deg, #4D4D4D, #7D7D7D);
  --gradient-overlay: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.85) 80%, transparent 100%);
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.45);
  --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(255, 255, 255, 0.1);
  
  /* Borders */
  --border-subtle: 1px solid rgba(255, 255, 255, 0.08);
  --border-medium: 1px solid rgba(255, 255, 255, 0.15);
  --border-strong: 2px solid rgba(255, 255, 255, 0.25);
}


/* ====== RESPONSIVE ADJUSTMENTS FOR VARIABLES ====== */

/* Small mobile devices */

/* Very small devices */

/* Landscape orientation */


/* ====== RESET BASE ====== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh; /* Dynamic viewport height for mobile */
  height: 100svh; /* Small viewport height fallback */
  height: -webkit-fill-available; /* Safari fallback */
  overflow: hidden;
  margin: 0;
  padding: 0;
  position: fixed;
  width: 100%;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: none;
}

/* CRITICAL: Force dark background on html too (Safari iOS) */
html {
  background: var(--gradient-dark);
  background-color: var(--color-bg-dark) !important;
}

/* ====== iOS SAFARI BACKGROUND FIX ====== */

/* CRITICAL: Safari iOS fix for white background issue */
/* Create a fixed background layer that stays in place */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  background: var(--gradient-dark);
  background-color: var(--color-bg-dark);
  z-index: -1; /* Behind all content */
  pointer-events: none; /* Don't interfere with clicks */
  /* Safari specific */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Ensure all main sections have transparent/inherit background to see through */
#login-screen,
#main-app,
#setup-screen {
  position: relative;
  z-index: 1;
}


body {
  font-family: 'Staatliches', sans-serif;
  background: var(--gradient-dark);
  background-color: var(--color-bg-dark) !important;
  color: var(--color-white);

  /* CRITICAL: Ensure background fills everything */
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;

  /* Safari iOS specific */
  -webkit-background-size: cover;
  background-size: cover;
  background-attachment: fixed;
}


header {
  text-align: center;
  /* Include safe area in padding */
  padding: env(safe-area-inset-top, 0px) 0 0 0;
  margin: 0 !important;
  /* CRITICAL: Fixed height includes safe area now */

  flex-shrink: 0;
  display: flex;
  flex-direction: column; /* Changed to column so logo can fill with padding */


  box-sizing: border-box;
  /* Ensure no extra space */
  overflow: visible; /* Changed to visible so logo can extend into safe area */

  align-items: center;       /* center horizontally */
  justify-content: center;   /* center vertically */
  height: var(--header-height);
  padding-top: env(safe-area-inset-top, 0px);
}

header img {
  /* Fill available space after safe area */
  height: 100%; 
  width: auto;
  max-width: 95vw;
  border-radius: 0;
  object-fit: contain;
  display: block;
  margin: 0 !important;
  padding: 0 !important;
}

header audio {
  /* Hide audio player completely */
  display: none !important;
  visibility: hidden;
}

header h1 {
  /* Hide h1 if present */
  display: none !important;
}

header h1 {
  margin-top: 2%;
  /* Font size relative to parent height */
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  color: #fff;
}

main {
  max-width: min(600px, 95vw);
  margin: 0 auto;
  padding: 0 20px;
  /* CRITICAL: Explicit background for iOS */
  background: transparent;
  position: relative;
  z-index: 1;
}

/* ====== LOGIN SCREEN ====== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 100px);
  padding: clamp(12px, 2.5vw, 15px);
  /* CRITICAL: Explicit background for iOS */
  background: transparent;
  position: relative;
}

.login-card {
  background: var(--gradient-card);
  backdrop-filter: blur(20px);
  border: var(--border-medium);
  border-radius: clamp(16px, 3vw, 20px);
  padding: clamp(25px, 5vw, 35px) clamp(20px, 4vw, 25px);
  box-shadow: var(--shadow-xl);
  text-align: center;
  width: 100%;
  max-width: min(360px, 88vw);
  transition: all 0.3s ease;
  margin: auto;
}

.login-card:hover {
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  border-color: rgba(255, 255, 255, 0.2);
}

.login-card img {
  width: 80px;
  margin-bottom: clamp(15px, 3vw, 20px);
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.2));
}

.login-card h1 {
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 800;
  color: var(--color-white);
  margin-bottom: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.login-card h3 {
  font-size: clamp(14px, 2.8vw, 16px);
  color: var(--color-light-grey);
  margin-bottom: clamp(20px, 4vw, 25px);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: clamp(12px, 2.4vw, 14px) clamp(14px, 2.8vw, 16px);
  margin-bottom: clamp(14px, 2.8vw, 16px);
  border: var(--border-subtle);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--color-white);
  font-size: clamp(14px, 2.8vw, 16px);
  outline: none;
  transition: all 0.2s ease;
}

.login-card input::placeholder {
  color: #B0B0B0;
}

.login-card input:focus {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}

.login-card button {
  width: 100%;
  padding: clamp(12px, 2.4vw, 14px);
  background: var(--gradient-button);
  color: var(--color-black);
  font-size: clamp(15px, 3vw, 17px);
  font-weight: 800;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: var(--shadow-md);
}

.login-card button:hover {
  background: var(--gradient-button-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.login-card button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Mobile optimizations for login */


/* ====== SETUP SCREEN ====== */
#main-app {
  background: var(--gradient-dark);
  background-color: var(--color-bg-dark) !important;
  
  /* CRITICAL: Precise height calculation - ends exactly where button starts */
  height: var(--main-app-height-dvh);
  height: var(--main-app-height); /* Fallback */
  /* NO max-height - would override the calculated height! */
  
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
  
  /* NO padding-bottom - height is calculated precisely */
}

#setup-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--gradient-card);
  backdrop-filter: blur(10px);
  border-radius: clamp(16px, 3vw, 20px);
  box-shadow: var(--shadow-lg);
  /* Normal padding - no extra space needed */
  padding: clamp(18px, 3.5vw, 25px) clamp(15px, 3vw, 20px);
  margin: 20px auto;
  max-width: min(420px, 90vw);
  color: #fff;
  text-align: center;
}

#setup-screen h2 {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 800;
  color: var(--color-white);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: clamp(18px, 3.5vw, 25px);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#setup-screen label {
  font-weight: 700;
  margin-top: 20px;
  margin-bottom: 10px;
  width: 100%;
  max-width: min(340px, 85vw);
  text-align: center;
  font-size: clamp(14px, 2.8vw, 16px);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#setup-screen select {
  width: 100%;
  max-width: min(340px, 85vw);
  padding: 14px 16px;
  font-size: clamp(14px, 2.8vw, 16px);
  font-weight: 600;
  border-radius: clamp(10px, 2vw, 12px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(240, 240, 240, 0.15));
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  margin-bottom: 10px;
  transition: all 0.3s ease;
  cursor: pointer;
  text-align: center;
}

#setup-screen select:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(240, 240, 240, 0.25));
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

#setup-screen select:focus {
  outline: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(240, 240, 240, 0.3));
  border-color: var(--color-white);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

/* Pulsante Start Workout */
#start-button {
  display: none;
}

.start-button {
  background: linear-gradient(135deg, var(--color-white), var(--color-white));
  color: white;
  font-weight: bold;
  padding: 14px 24px;
  font-size: clamp(16px, 3vw, 18px);
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: background 0.3s, transform 0.2s;
}

.start-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #B0B0B0, var(--color-white));
  transform: translateY(-2px);
}

.start-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* BOTTOM BUTTONS CONTAINER - Settings + Start Workout */


/* START BUTTON - IN CONTAINER */
#start-button-bottom {
  flex: 1;
  max-width: min(400px, 70vw);
  /* Height relative to parent */
  height: 65%;
  padding: 0 5%;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6), 0 0 0 1px rgba(255, 255, 255, 0.3);
  background: linear-gradient(135deg, var(--color-white), var(--color-white));
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Settings button in bottom container */
#bottom-buttons-container .settings-btn {
  flex-shrink: 0;
  /* Square button, height relative to parent */
  height: 65%;
  aspect-ratio: 1;
  font-size: clamp(1rem, 3vw, 1.3rem);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#start-button-bottom:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(255, 255, 255, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.5);
  background: linear-gradient(135deg, #B0B0B0, var(--color-white));
}

#start-button-bottom:active:not(:disabled) {
  transform: translateY(-1px);
}

#start-button-bottom:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(135deg, #B0B0B0, #7D7D7D);
}

/* Hide button when workout is active */
#exercise-container:not([style*="display: none"]) ~ #start-button-bottom,
body:has(#exercise-container[style*="display: flex"]) #start-button-bottom {
  display: none;
}

/* Pulsante Logout in alto a destra del blocco */
#logout-button {
  align-self: flex-end;
  margin-bottom: clamp(15px, 3vw, 20px);
  background-color: rgba(255,255,255,0.1);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s;
}

#logout-button:hover {
  background-color: rgba(255,255,255,0.2);
}

/* ====== WORKOUT PREVIEW ====== */
#exercise-list {
  display: none !important;
}

#workout-preview {
  display: block !important;
  margin-top: 30px;
  width: 100%;
  max-width: min(340px, 85vw);
}

#workout-preview h3 {
  font-size: clamp(16px, 3vw, 18px);
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-bottom: clamp(12px, 2.5vw, 15px);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ====== INSTRUCTIONS SECTION (Collapsible) ====== */
#instructions-section {
  width: 100%;
  max-width: min(340px, 85vw);
  margin: 20px auto;
  background: var(--gradient-card);
  border: var(--border-subtle);
  border-radius: clamp(10px, 2vw, 12px);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.instructions-header {
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2.5vw, 16px);
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 10px);
  background: linear-gradient(135deg, #7D7D7D, #4D4D4D);
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: background 0.3s;
}

.instructions-header:hover {
  background: linear-gradient(135deg, #B0B0B0, #7D7D7D);
}

.instructions-icon {
  font-size: clamp(17px, 3.5vw, 20px);
}

.instructions-title {
  flex: 1;
  font-size: clamp(13px, 2.5vw, 15px);
  font-weight: 700;
  letter-spacing: 1.5px;
}

.collapse-icon {
  font-size: clamp(12px, 2.3vw, 14px);
  transition: transform 0.3s;
}

.instructions-header.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.instructions-content {
  max-height: min(500px, 60vh);
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.instructions-content.collapsed {
  max-height: 0;
}

#instructions-box {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 1));

  font-size: clamp(13px, 2.5vw, 15px);
  color: #4D4D4D;
  text-align: left;
  line-height: 1.6;
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

#instructions-text {
  margin: 0;
  color: #4D4D4D;
}

#instructions-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-top: 10px;
}

/* ====== MATERIALE SECTION ====== */
#materiale-section {
  width: 100%;
  max-width: min(600px, 95vw); /* Increased from 340px to allow more items per row */
  margin: 20px auto;
  background: var(--gradient-card);
  border: var(--border-subtle);
  border-radius: clamp(10px, 2vw, 12px);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.materiale-header {
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2.5vw, 16px);
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 10px);
  background: linear-gradient(135deg, #4D4D4D, #7D7D7D);
  color: #fff;
}

.materiale-icon {
  font-size: clamp(17px, 3.5vw, 20px);
}

.materiale-title {
  flex: 1;
  font-size: clamp(13px, 2.5vw, 15px);
  font-weight: 700;
  letter-spacing: 1.5px;
}

.materiale-content {
  background:#FFFFFF;

}

#materiale-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: clamp(8px, 1.5vw, 10px);
  justify-items: center;
}

/* Small screens: force 2 columns max */

/* Medium screens: 3 columns */

/* Larger screens: auto-fit with minimum 120px items */

.materiale-item {
  background: linear-gradient(135deg, #7D7D7D, #4D4D4D);
  color: white;
  padding: 10px 16px;
  border-radius: clamp(16px, 3vw, 20px);
  font-size: clamp(12px, 2.3vw, 14px);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%; /* Make items fill their grid cell */
  max-width: min(160px, 75vw);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.materiale-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.materiale-item::before {
  content: "";
  font-size: clamp(16px, 3vw, 18px);
}


#exercise-visuals {
  display: block !important;
  width: 100%;
  max-width: min(340px, 85vw);
  margin-top: clamp(18px, 3.5vw, 25px);
  margin-bottom: clamp(18px, 3.5vw, 25px);
}

#exercise-grid {
  display: flex;
  flex-direction: column;
  gap: clamp(15px, 3vw, 20px);
  width: 100%;
}

/* Workout Section */
.workout-section {
  width: 100%;
  background: var(--gradient-card);
  border-radius: clamp(12px, 2.3vw, 14px);
  overflow: hidden;
  border: var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  margin-bottom: clamp(12px, 2.5vw, 16px);
}

.section-header {
  padding: clamp(12px, 2.4vw, 14px) clamp(14px, 2.8vw, 18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-white);
  font-weight: 800;
  gap: 10px;
  background: linear-gradient(135deg, #4D4D4D, #7D7D7D);
  border-bottom: var(--border-subtle);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.section-icon {
  font-size: clamp(18px, 3.6vw, 22px);
  flex-shrink: 0;
  opacity: 0.9;
}

.section-title {
  font-size: clamp(14px, 2.8vw, 16px);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  flex: 1;
}

.section-count {
  font-size: clamp(11px, 2.2vw, 13px);
  background: rgba(255, 255, 255, 0.1);
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.section-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 2vw, 12px);
  padding: clamp(10px, 2vw, 12px);
  background: rgba(0, 0, 0, 0.1);
}

.exercise-card {
  background: linear-gradient(135deg, #FFFFFF, var(--color-white));
  padding: 12px;
  border-radius: clamp(12px, 2.4vw, 14px);
  color: var(--color-black);
  box-shadow: var(--shadow-md);
  text-align: center;
  border: 1px solid var(--color-light-grey);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}

.exercise-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-white);
}

.exercise-card img {
  width: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 2px solid #FFFFFF;
  flex-shrink: 0;
  clip-path: inset(3% 0 3% 0);
}

.exercise-name {
  font-weight: 700;
  font-size: clamp(10px, 2vw, 12px);
  color: #4D4D4D;
  line-height: 1.3;
  margin-top: 8px;
  text-align: center;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exercise-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.exercise-equipment,
.exercise-reps {
  font-size: clamp(9px, 1.8vw, 11px);
  color: #7D7D7D;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.exercise-equipment strong,
.exercise-reps strong {
  color: var(--color-light-grey);
  font-weight: 700;
}

/* ====== SECTIONED PREVIEW STYLES ====== */
.workout-section {
  background: var(--gradient-card);
  border: var(--border-subtle);
  border-radius: clamp(10px, 2vw, 12px);
  overflow: hidden;
  margin-bottom: clamp(12px, 2.5vw, 16px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.section-header {
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2.5vw, 16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: clamp(13px, 2.5vw, 15px);
  color: #fff;
}

.section-icon {
  font-size: clamp(17px, 3.5vw, 20px);
  margin-right: 8px;
}

.section-title {
  flex: 1;
  font-size: clamp(13px, 2.5vw, 15px);
  font-weight: 700;
  letter-spacing: 1.5px;
}

.section-count {
  background: rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: clamp(10px, 2vw, 12px);
  font-size: clamp(11px, 2.2vw, 13px);
  font-weight: 600;
}

.section-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 2vw, 12px);
  padding: clamp(10px, 2vw, 12px);
}

/* ====== WORKOUT SECTION - CLEAN RESPONSIVE ====== */

#exercise-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100vh;
  height: 100svh;
  max-height: 100vh;
  max-height: 100svh;
  /* Responsive padding with safe areas */
  padding: max(0.5vh, env(safe-area-inset-top)) clamp(8px, 2vw, 10px) max(0.5vh, env(safe-area-inset-bottom)) clamp(8px, 2vw, 10px);
  gap: clamp(2px, 0.5vh, 4px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden !important;
  -webkit-overflow-scrolling: none;
  overscroll-behavior: none;
  text-align: center;
}

/* Prevent scrolling on body when workout is active */
body:has(#exercise-container[style*="display: flex"]) {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ====== TIMER - RESPONSIVE SIZE ====== */
#timer.full-timer {
  display: block;
  /* Responsive font size - scales with viewport */
  font-size: clamp(2.5rem, 8vw, 3.8rem);
  font-weight: bold;
  color: var(--color-light-grey);
  text-align: center;
  z-index: 2;
  line-height: 1;
  margin: 0;
  padding: clamp(4px, 1vh, 8px) clamp(8px, 2vw, 10px);
  flex-shrink: 0;
  flex-grow: 0;
  width: 100%;
}

/* ====== EXERCISE NAME - RESPONSIVE SIZE ====== */
#exercise-name {
  /* Responsive font size */
  font-size: clamp(15px, 4vw, 18px);
  font-weight: bold;
  color: #fff;
  margin: 0 clamp(8px, 2vw, 10px) clamp(2px, 0.5vh, 4px) clamp(8px, 2vw, 10px);
  text-align: center;
  line-height: 1.2;
  flex-shrink: 0;
  flex-grow: 0;
  /* Responsive min-height */
  min-height: clamp(42px, 8vh, 48px);
  max-height: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 1.5vh, 8px) clamp(10px, 2.5vw, 14px);
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  z-index: 10;
  position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  width: clamp(calc(100% - 16px), 95%, calc(100% - 20px));
  max-width: min(600px, 95vw);
}

/* ====== GIF - ALWAYS 9:16 VERTICAL ====== */
#exercise-gif,
#next-exercise-gif {
  /* CRITICAL: Responsive width that maintains 9:16 aspect ratio */
  width: min(85vw, 75vh);
  max-width: 90vw;
  /* CRITICAL: Force 9:16 vertical aspect ratio */
  aspect-ratio: 9 / 16;
  /* Let height be calculated by aspect-ratio */
  height: auto;
  /* Cover and center the image */
  object-fit: cover;
  object-position: center;
  display: block;
  margin: 0 auto;
  border-radius: clamp(10px, 2vw, 12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  /* CRITICAL: Crop 5% from top and bottom */
  clip-path: inset(5% 0 5% 0);
  flex-shrink: 0;
}

/* ====== CONTROLS - RESPONSIVE ====== */
#controls-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2vw, 12px);
  margin: 0;
  padding: clamp(6px, 1.5vh, 8px) clamp(8px, 2vw, 10px);
  padding-bottom: max(clamp(6px, 1.5vh, 8px), env(safe-area-inset-bottom, 8px));
  flex-wrap: nowrap;
  flex-shrink: 0;
  flex-grow: 0;
  width: 100%;
}

#pause-button,
.settings-btn,
.nav-btn {
  /* Responsive padding and font */
  padding: clamp(7px, 2vh, 10px) clamp(12px, 3vw, 20px);
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: bold;
  border: none;
  border-radius: 8px;
  background-color: #000000;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

#pause-button:hover,
.settings-btn:hover,
.nav-btn:hover {
  background-color: #4D4D4D;
  transform: translateY(-2px);
}

.nav-btn {
  font-size: clamp(15px, 4vw, 18px);
  padding: clamp(7px, 2vh, 10px) clamp(10px, 2.5vw, 15px);
  background-color: rgba(176, 176, 176, 0.1);
  border: 1px solid rgba(176, 176, 176, 0.3);
}

.nav-btn:hover {
  background-color: rgba(176, 176, 176, 0.2);
  border-color: rgba(176, 176, 176, 0.5);
}

.nav-btn:active {
  transform: scale(0.95);
}

.settings-btn {
  font-size: clamp(16px, 4.5vw, 20px);
  padding: clamp(7px, 2vh, 10px) clamp(12px, 3vw, 16px);
}

/* Settings Popup Overlay */
#settings-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-content {
  background: linear-gradient(135deg, #4D4D4D, #000000);
  padding: clamp(20px, 4vw, 30px);
  border-radius: clamp(12px, 2.5vw, 16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  text-align: center;
  min-width: 300px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.settings-content h3 {
  color: var(--color-white);
  font-size: clamp(20px, 4.5vw, 24px);
  margin-bottom: clamp(15px, 3vw, 20px);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.settings-content label {
  display: block;
  color: #fff;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: clamp(14px, 2.8vw, 16px);
}

.settings-content select {
  width: 100%;
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2.5vw, 16px);
  font-size: clamp(14px, 2.8vw, 16px);
  font-weight: 600;
  border-radius: clamp(10px, 2vw, 12px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(240, 240, 240, 0.15));
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  margin-bottom: clamp(15px, 3vw, 20px);
  cursor: pointer;
}

.settings-content select:focus {
  outline: none;
  border-color: var(--color-white);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

#close-settings {
  width: 100%;
  padding: clamp(10px, 2vw, 12px);
  background: linear-gradient(135deg, var(--color-white), var(--color-white));
  color: white;
  font-size: clamp(14px, 2.8vw, 16px);
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#close-settings:hover {
  background: linear-gradient(135deg, #B0B0B0, var(--color-white));
  transform: translateY(-2px);
}

/* Exit Workout Button - Red warning style */
#exit-workout-button {
  width: 100%;
  padding: clamp(10px, 2vw, 12px);
  background: linear-gradient(135deg, #7D7D7D, #4D4D4D) !important;
  color: white !important;
  font-size: clamp(14px, 2.8vw, 16px);
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 15px !important;
}

#exit-workout-button:hover {
  background: linear-gradient(135deg, #B0B0B0, #7D7D7D) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

#exit-workout-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

/* Setup Settings Popup - Same styling as workout settings */
#setup-settings-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#close-setup-settings,
#logout-button {
  width: 100%;
  padding: clamp(10px, 2vw, 12px);
  font-size: clamp(14px, 2.8vw, 16px);
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
}

#close-setup-settings {
  background: linear-gradient(135deg, var(--color-white), var(--color-white));
  color: white;
}

#close-setup-settings:hover {
  background: linear-gradient(135deg, #B0B0B0, var(--color-white));
  transform: translateY(-2px);
}

#logout-button {
  background: linear-gradient(135deg, #7D7D7D, #4D4D4D);
  color: white;
}

#logout-button:hover {
  background: linear-gradient(135deg, #B0B0B0, #7D7D7D);
  transform: translateY(-2px);
}


.audio-setup-wrapper,
.audio-workout-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.audio-setup-wrapper select,
.audio-workout-wrapper select {
  padding: 6px 10px;
  font-size: 1rem;
  border-radius: 6px;
  background: #000000;
  color: #fff;
  border: none;
}

audio {
  display: none;
}


/* ====== TOP SELECTOR ABOVE SETUP CARD ====== */
#topbar-select {
  max-width: min(420px, 90vw);
  margin: 10px auto 0;
  padding: 14px 16px;
  text-align: center;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  border-radius: clamp(12px, 2.5vw, 16px);
  box-shadow: var(--shadow-lg);
}

#topbar-select label {
  display: block;
  font-weight: 700;
  font-size: clamp(14px, 2.8vw, 16px);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

#topbar-select select {
  width: 100%;
  max-width: min(340px, 85vw);
  padding: 14px 16px;
  font-size: clamp(14px, 2.8vw, 16px);
  font-weight: 600;
  border-radius: clamp(10px, 2vw, 12px);
  background: linear-gradient(135deg, rgba(106,176,76,0.15), rgba(88,160,57,0.15));
  color: #fff;
  border: 2px solid rgba(106,176,76,0.4);
  transition: all 0.3s ease;
  cursor: pointer;
  text-align: center;
}


/* ====== COMPREHENSIVE SPACE OPTIMIZATION ====== */
/* Ensures no content is hidden behind sticky buttons and optimizes space usage */

/* Setup Screen Sections - Tighter spacing */
#instructions-section,
#materiale-section {
  margin-bottom: clamp(15px, 3vw, 20px); /* Reduced from default */
}

#workout-preview-title {
  margin: 20px 0 15px !important; /* Reduced from 30px 0 20px */
}

#exercise-visuals {
  margin-top: 15px !important; /* Reduced from 20px */
  margin-bottom: clamp(15px, 3vw, 20px);
}

#start-point-selector {
  margin: 20px 0 30px !important; /* Optimized margins */
}

/* Exercise cards - more compact on mobile */
.exercise-card {
  min-height: 130px; /* Reduced from 140px */
  padding: 8px; /* Reduced from 10px */
}

.exercise-card img {
  margin-bottom: 6px; /* Reduced from 8px */
}

.exercise-name {
  margin-top: 6px; /* Reduced from 8px */
  font-size: clamp(9px, 1.8vw, 11px); /* Slightly smaller */
  min-height: clamp(24px, 4.5vw, 28px); /* Reduced from 30px */
}

.exercise-details {
  margin-top: 4px; /* Reduced from 6px */
  padding-top: 4px; /* Reduced from 6px */
}

/* Workout sections - tighter spacing */
.workout-section {
  margin-bottom: clamp(12px, 2.5vw, 15px); /* Reduced spacing between sections */
}

.section-header {
  padding: 10px 14px; /* Slightly reduced */
}

.section-cards-grid {
  padding: 10px; /* Reduced from 12px */
  gap: clamp(8px, 1.5vw, 10px); /* Reduced from 12px */
}

/* Bottom button container - ensure it doesn't overlap */


#start-button-bottom {
  max-width: min(400px, 90vw);
  margin: 0 auto;
}

/* Mobile optimizations */

/* Small phones (< 375px) */

/* Tablets and larger phones */

/* Desktop and large tablets */


/* Very small phones during workout */


/* Ensure content is never cut off - force scroll if needed */
#main-app {
  scroll-behavior: smooth;
  scroll-padding-bottom: var(--footer-total); /* Padding when scrolling to anchors */
}

/* Improve scrollbar appearance */
#main-app::-webkit-scrollbar {
  width: 8px;
}

#main-app::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

#main-app::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
}

#main-app::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.7);
}
/* ====== TRIPLE VISUAL CUE SYSTEM ====== */


/* 1. EXERCISE NAME BAR - GOLDEN EFFECT at 10 seconds */
#exercise-name.next-preview-active {
  background: linear-gradient(135deg, rgba(176, 176, 176, 0.95), rgba(125, 125, 125, 0.95)) !important;
  border: 3px solid var(--color-light-grey) !important;
  box-shadow: 
    0 8px 32px rgba(176, 176, 176, 0.5),
    0 0 60px rgba(176, 176, 176, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  animation: barPulse 2s ease-in-out infinite !important;
  color: #000 !important;
}

#exercise-name.next-preview-active strong {
  color: #000 !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

#exercise-name.next-preview-active div {
  color: #000000 !important;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5) !important;
}

@keyframes barPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 
      0 8px 32px rgba(176, 176, 176, 0.5),
      0 0 60px rgba(176, 176, 176, 0.4);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 
      0 10px 40px rgba(176, 176, 176, 0.7),
      0 0 80px rgba(176, 176, 176, 0.6);
  }
}

/* 2. TIMER COLOR TRANSITIONS */
#timer.full-timer.warning-10 {
  color: var(--color-light-grey);
  text-shadow: 
    0 0 20px rgba(176, 176, 176, 0.8),
    0 0 40px rgba(176, 176, 176, 0.5);
  animation: timerGlow 1s ease-in-out infinite;
}

#timer.full-timer.warning-6 {
  color: #B0B0B0;
  text-shadow: 
    0 0 25px rgba(255, 140, 0, 0.9),
    0 0 50px rgba(255, 140, 0, 0.6);
  animation: timerGlow 0.8s ease-in-out infinite;
}

#timer.full-timer.warning-3 {
  color: #B0B0B0;
  text-shadow: 
    0 0 30px rgba(255, 68, 68, 1),
    0 0 60px rgba(255, 68, 68, 0.7);
  animation: timerGlow 0.5s ease-in-out infinite;
}

@keyframes timerGlow {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

/* 3. GIF BORDER GLOW (at 10 seconds) */
#exercise-gif.gif-glow {
  border: 4px solid var(--color-light-grey);
  box-shadow: 
    0 0 30px rgba(176, 176, 176, 0.8),
    0 0 60px rgba(176, 176, 176, 0.5),
    0 4px 20px rgba(0,0,0,0.3);
  animation: gifPulse 2s ease-in-out infinite;
}

@keyframes gifPulse {
  0%, 100% {
    border-color: var(--color-light-grey);
    box-shadow: 
      0 0 30px rgba(176, 176, 176, 0.8),
      0 0 60px rgba(176, 176, 176, 0.5),
      0 4px 20px rgba(0,0,0,0.3);
  }
  50% {
    border-color: #B0B0B0;
    box-shadow: 
      0 0 40px rgba(176, 176, 176, 1),
      0 0 80px rgba(176, 176, 176, 0.7),
      0 6px 25px rgba(0,0,0,0.4);
  }
}

/* RESPONSIVE ADJUSTMENTS */

/* ====== WORKOUT PROGRESS BAR ====== */

#workout-progress-container {
  width: 100%;
  /* CRITICAL: Add safe area for notch/status bar */
  padding-top: max(12px, env(safe-area-inset-top, 12px));
  padding-left: clamp(12px, 2.5vw, 16px);
  padding-right: 16px;
  padding-bottom: 8px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(176, 176, 176, 0.3);
  /* CRITICAL: Don't shrink, reserve space */
  flex-shrink: 0;
  flex-grow: 0;
  z-index: 100;
}

#progress-bar-wrapper {
  margin-bottom: 8px;
}

#progress-bar {
  position: relative;
  width: 100%;
  height: clamp(22px, 4vh, 26px);
  background: rgba(255, 255, 255, 0.08);
  border-radius: clamp(12px, 2.4vw, 14px);
  overflow: hidden;
  border: var(--border-subtle);
  box-shadow: var(--shadow-inset);
}

#progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--color-light-grey), #FFFFFF);
  border-radius: clamp(12px, 2.4vw, 14px);
  transition: width 0.5s ease;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#progress-percentage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(10px, 2vw, 12px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  z-index: 1;
}

#progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

#progress-info span {
  font-size: clamp(9px, 1.8vw, 11px);
  font-weight: 600;
  color: var(--color-light-grey);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Responsive adjustments */



/* ====== MOBILE VIEWPORT FIX ====== */

/* Ensure exercise container uses all available space on all browsers */
@supports (height: 100dvh) {
  #exercise-container {
    height: 100dvh !important;
  }
}

/* Safari fallback */
@supports (height: -webkit-fill-available) {
  #exercise-container {
    height: -webkit-fill-available !important;
  }
}

/* Prevent any scrolling during workout */
body:has(#exercise-container[style*="display: flex"]),
body:has(#exercise-container[style*="display: flex"]) html {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
  overscroll-behavior: none !important;
}
/* ====== RESPONSIVE ADJUSTMENTS - ORIENTATION BASED ====== */

/* Landscape optimization - reduce vertical space usage */
@media (orientation: landscape) {
  :root {
    --header-height: 10vh;
    --bottom-button-height: 10vh;
  }

  #exercise-gif {
    width: min(40vw, 65vh);
  }

  #timer {
    font-size: clamp(6vh, 12vw, 10vh);
  }

  .section-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Portrait is default - no override needed since main definition already handles it */


#exercise-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
}

/* Non-GIF parts keep their natural size */
#workout-progress-container,
#timer,
#exercise-name,
#controls-container {
  flex-shrink: 0;
}


/* --- Cropped GIF fills the leftover height, for ANY crop % --- */
#exercise-gif-viewport {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Set crop as FRACTIONS (0–1). Change these two only. */
#exercise-gif {
  --clip-top: 0.13;      /* 13% top crop  → set 0.05 for 5%, etc. */
  --clip-bottom: 0.07;   /*  7% bottom crop */

  /* After cropping (top+bottom), the visible height = 100% */
  height: calc(100% / (1 - (var(--clip-top) + var(--clip-bottom)))) !important;
  width: auto !important;
  max-width: none !important;

  aspect-ratio: 9 / 16;
  object-fit: cover;
  object-position: center;

  /* Convert the FRACTIONS above into percentages for clip-path */
  clip-path: inset(calc(var(--clip-top) * 100%) 0 calc(var(--clip-bottom) * 100%) 0);

  display: block;
  margin: 0;
  border-radius: clamp(10px, 2vw, 12px);
}

/* Remove #main-app background during workout */
#main-app:has(#exercise-container[style*="display: flex"]) {
  background: transparent !important;
  background-color: transparent !important;
}

/* LETTER-SPACING TUNING */
body, button, select, label, .exercise-name, .section-title, .section-count {
  letter-spacing: 0.15em;
}

h1, h2, h3, .settings-content h3, #workout-preview-title {
  letter-spacing: 0.1em;
}

.start-button, #pause-button, #prev-exercise-button, #next-exercise-button, #settings-button, #setup-settings-button {
  letter-spacing: 0.13em;
}

/* Ensure selects and option texts inherit spacing */
select option { letter-spacing: inherit; }


/* === Info line (peso, reps, durata) per corrente e prossimo === */
.exercise-info-line{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:24px;
  padding:6px 0 2px;
  font-size:16px;
  letter-spacing:.06em;
  width:100%;
  max-width:min(600px,95vw);
}
.exercise-info-line .info-item{
  flex:1 1 0;
  text-align:center;
  font-weight:700;
  white-space:nowrap;
}

/* Colori coerenti su barra nera (corrente) */
#exercise-name .exercise-info-line .info-item{
  color:var(--color-light-grey);
}
/* Colori coerenti su riquadro “prossimo esercizio” (giallo) */
#exercise-name.next-preview-active .exercise-info-line .info-item{
  color:#000;
}

.exercise-info-line {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 24px;
  padding: 4px 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.05em;
  width: 100%;
}

.exercise-info-line .info-item {
  flex: 1;
  text-align: center;
  color: var(--color-light-grey);
}


/* ====== CSS VARIABLES FOR DYNAMIC LAYOUT ====== */
:root {
  /* Heights for precise calculation - adapts to ANY screen */
  --header-height: 13vh;
  --bottom-button-height: 8vh;
  
  /* Safe areas */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  
  /* Calculated available height for main-app */
  --main-app-height: calc(100vh - var(--header-height) - var(--bottom-button-height));
  --main-app-height-dvh: calc(100dvh - var(--header-height) - var(--bottom-button-height));
}

/* ====== RESET BASE ====== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  height: 100svh;
  height: -webkit-fill-available;
  overflow: hidden;
  margin: 0;
  padding: 0;
  position: fixed;
  width: 100%;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: none;
}

/* Default (will be overridden by theme) */
html { background: #000000; }
body {
  font-family: 'Staatliches', sans-serif;
  background: #000000;
  color: #fff;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  -webkit-background-size: cover;
  background-size: cover;
  background-attachment: fixed;
}

header {
  text-align: center;
  padding: 1% 0;
  height: var(--header-height);
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-sizing: border-box;
}

header img { width: auto; max-width: 70vw; border-radius: 8px; }
header h1 { margin-top: 2%; font-size: clamp(0.9rem, 3vw, 1.2rem); color: #fff; }

main { max-width: min(600px, 95vw); margin: 0 auto; padding: 0 20px; background: transparent; position: relative; z-index: 1; }

/* ====== LOGIN SCREEN ====== */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  height: calc(100vh - 100px);
  padding: clamp(12px, 2.5vw, 15px);
  background: transparent; position: relative;
}

.login-card {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: clamp(12px, 2.5vw, 16px);
  padding: clamp(20px, 4vw, 30px) clamp(15px, 3vw, 20px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
  text-align: center;
  width: 100%;
  max-width: min(340px, 85vw);
  transition: all 0.3s ease;
  margin: auto;
}

.login-card h1 { font-size: clamp(17px, 3.5vw, 20px); font-weight: 700; color: #ffffff; margin-bottom: 10px; letter-spacing: 1px; }
.login-card h3 { font-size: clamp(14px, 2.8vw, 16px); color: #B0B0B0; margin-bottom: clamp(15px, 3vw, 20px); font-weight: 500; }

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2.3vw, 14px);
  margin-bottom: clamp(12px, 2.5vw, 15px);
  border: none; border-radius: 8px;
  background-color: rgba(255,255,255,0.1);
  color: #fff;
  font-size: clamp(13px, 2.5vw, 15px);
  outline: none; transition: background 0.2s ease;
}
.login-card input::placeholder { color: #B0B0B0; }

.login-card button {
  width: 100%; padding: clamp(10px, 2vw, 12px);
  background: #000000; color: white; font-size: clamp(14px, 2.8vw, 16px);
  font-weight: bold; border: none; border-radius: 8px; cursor: pointer;
  transition: background 0.3s, transform 0.2s, box-shadow .2s;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}
.login-card button:hover { background: #4D4D4D; transform: translateY(-1px); }

/* ====== SETUP SCREEN ====== */
#main-app {
  background: transparent;
  height: var(--main-app-height-dvh);
  height: var(--main-app-height);
  overflow-y: auto; overflow-x: hidden; position: relative; -webkit-overflow-scrolling: touch;
}

#setup-screen {
  display: flex; flex-direction: column; align-items: center;
  background: var(--gradient-card);
  backdrop-filter: blur(10px);
  border-radius: clamp(16px, 3vw, 20px);
  box-shadow: var(--shadow-lg);
  padding: clamp(18px, 3.5vw, 25px) clamp(15px, 3vw, 20px);
  margin: 20px auto; max-width: min(420px, 90vw); color: #fff; text-align: center;
}

#setup-screen h2 {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 800; color: #FFFFFF;
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: clamp(18px, 3.5vw, 25px);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#setup-screen label {
  font-weight: 700; margin-top: 20px; margin-bottom: 10px; width: 100%; max-width: min(340px, 85vw);
  text-align: center; font-size: clamp(14px, 2.8vw, 16px); color: #fff; text-transform: uppercase; letter-spacing: 0.5px;
}

#setup-screen select,
#topbar-select select,
.settings-content select,
.audio-setup-wrapper select,
.audio-workout-wrapper select {
  width: 100%; max-width: min(340px, 85vw);
  padding: 14px 16px; font-size: clamp(14px, 2.8vw, 16px);
  font-weight: 600; border-radius: clamp(10px, 2vw, 12px);
  background: #4D4D4D; color: #FFFFFF; border: 1px solid #4D4D4D;
  margin-bottom: 10px; transition: all 0.2s ease; cursor: pointer; text-align: center;
}
#setup-screen select:hover { background: #4D4D4D; border-color: #7D7D7D; transform: translateY(-1px); }

.start-button { background: #4D4D4D; color: white; font-weight: 700; padding: 14px 24px; font-size: clamp(16px, 3vw, 18px); border-radius: 10px; border: 1px solid #4D4D4D; cursor: pointer; box-shadow: var(--shadow-lg); transition: all 0.2s ease; }
.start-button:hover:not(:disabled) { background: #4D4D4D; transform: translateY(-2px); }
.start-button:disabled { opacity: .5; cursor: not-allowed; }



#start-button-bottom {
  flex: 1; max-width: min(400px, 90vw); height: 65%;
  padding: 0 5%; font-size: clamp(0.9rem, 2.5vw, 1.1rem); font-weight: 700;
  background: #4D4D4D; color: #fff; border: 1px solid #4D4D4D; border-radius: 8px;
  cursor: pointer; transition: all .2s ease; display: flex; align-items: center; justify-content: center;
}
#start-button-bottom:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.45); background:#4D4D4D; }

#bottom-buttons-container .settings-btn {
  height: 65%; aspect-ratio: 1; font-size: clamp(1rem, 3vw, 1.3rem);
  background:#000000; color:#FFFFFF; border:1px solid #4D4D4D; border-radius:8px; box-shadow:0 6px 16px rgba(0,0,0,.35);
}

#logout-button { align-self: flex-end; margin-bottom: clamp(15px,3vw,20px); background: #4D4D4D; border: 1px solid #2d2f35; padding: 8px 16px; border-radius: 6px; color: #fff; font-weight: bold; cursor: pointer; transition: background .2s; }
#logout-button:hover { background:#4D4D4D; }

/* ====== PREVIEW / INSTRUCTIONS / MATERIALE ====== */
#workout-preview { display: block !important; margin-top: 30px; width: 100%; max-width: min(340px,85vw); }
#workout-preview h3 { font-size: clamp(16px, 3vw, 18px); font-weight: 700; color: #fff; text-align: center; margin-bottom: clamp(12px, 2.5vw, 15px); text-transform: uppercase; letter-spacing: .5px; }

#instructions-section { width:100%; max-width:min(340px,85vw); margin:20px auto; background: rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius: clamp(10px,2vw,12px); overflow:hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.instructions-header { padding: clamp(10px,2vw,12px) clamp(12px,2.5vw,16px); display:flex; align-items:center; gap: clamp(8px,1.5vw,10px); background: linear-gradient(135deg,#4D4D4D,#4D4D4D); color:#FFFFFF; cursor:pointer; user-select:none; transition: filter .2s; }
.instructions-header:hover { filter: brightness(1.05); }
.instructions-icon { font-size: clamp(17px,3.5vw,20px); }
.instructions-title { flex:1; font-size: clamp(13px,2.5vw,15px); font-weight:700; letter-spacing:1.5px; }
.collapse-icon { font-size: clamp(12px,2.3vw,14px); transition: transform .3s; }
.instructions-header.collapsed .collapse-icon { transform: rotate(-90deg); }
.instructions-content { max-height: min(500px,60vh); overflow: hidden; transition: max-height .3s ease-out; }
.instructions-content.collapsed { max-height: 0; }
#instructions-box { background:#FFFFFF;  font-size: clamp(13px,2.5vw,15px); color:#000000; text-align:left; line-height:1.6; }
#instructions-text { margin:0; color:#000000; }
#instructions-image { width:100%; height:auto; border-radius:8px; margin-top:10px; }

#materiale-section { width:100%; max-width:min(600px,95vw); margin:20px auto; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: clamp(10px,2vw,12px); overflow:hidden; box-shadow:0 4px 12px rgba(0,0,0,.25); }
.materiale-header { padding: clamp(10px,2vw,12px) clamp(12px,2.5vw,16px); display:flex; align-items:center; gap: clamp(8px,1.5vw,10px); background: linear-gradient(135deg,#4D4D4D,#4D4D4D); color:#FFFFFF; }
.materiale-content { background:#FFFFFF }
#materiale-list { display:grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: clamp(8px,1.5vw,10px); justify-items:center; }
.materiale-item { background: #4D4D4D; color: #FFFFFF; padding:10px 16px; border-radius: clamp(16px,3vw,20px); font-size: clamp(12px,2.3vw,14px); font-weight:600; box-shadow: 0 2px 8px rgba(0,0,0,.25); width:100%; max-width:min(160px,75vw); white-space:nowrap; }

#exercise-visuals { display:block !important; width:100%; max-width:min(340px,85vw); margin-top: clamp(18px,3.5vw,25px); margin-bottom: clamp(18px,3.5vw,25px); }

#exercise-grid { display:flex; flex-direction:column; gap: clamp(15px,3vw,20px); width:100%; }

.workout-section { width:100%; background: rgba(255,255,255,0.04); border-radius: clamp(12px,2.3vw,14px); overflow:hidden; border:2px solid #FFFFFF; box-shadow: 0 2px 8px rgba(0,0,0,.2); margin-bottom: clamp(12px,2.5vw,16px); }
.section-header { padding: clamp(10px,2vw,12px) clamp(12px,2.5vw,16px); display:flex; align-items:center; justify-content:space-between; color:#FFFFFF; font-weight:700; gap:8px; background: #4D4D4D; }
.section-icon { font-size: clamp(17px,3.5vw,20px); flex-shrink: 0; }
.section-title { font-size: clamp(13px,2.5vw,15px); text-transform: uppercase; letter-spacing: 1.5px; flex:1; }
.section-count { font-size: clamp(11px,2.2vw,13px); background: rgba(255,255,255,0.12); padding: 4px 10px; border-radius: clamp(10px,2vw,12px); font-weight:600; }

.section-cards-grid { display:grid; grid-template-columns: 1fr 1fr; gap: clamp(8px,2vw,12px); padding: clamp(10px,2vw,12px); background: rgba(0,0,0,0.08); }
.exercise-card { background:#fbfbfc; padding:10px; border-radius: clamp(10px,2vw,12px); color:#000000; box-shadow: 0 2px 8px rgba(0,0,0,.12); text-align:center; border: 2px solid #FFFFFF; transition: all .2s ease; display:flex; flex-direction:column; min-height:140px; }
.exercise-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.exercise-card img { width:100%; object-fit:cover; object-position:center; border-radius:8px; margin-bottom:8px; border:1px solid rgba(0,0,0,0.08); flex-shrink:0; clip-path: inset(3% 0 3% 0); }
.exercise-name { font-weight:700; font-size: clamp(10px,2vw,12px); color:#4D4D4D; line-height:1.3; margin-top:8px; text-align:center; min-height:30px; display:flex; align-items:center; justify-content:center; }
.exercise-details { display:flex; flex-direction:column; gap:4px; margin-top:6px; padding-top:6px; border-top:1px solid rgba(0,0,0,0.08); }
.exercise-equipment,.exercise-reps { font-size: clamp(9px,1.8vw,11px); color:#7D7D7D; display:flex; align-items:center; justify-content:center; gap:4px; }

/* ====== WORKOUT SESSION ====== */
#exercise-container { display:flex; flex-direction:column; align-items:center; justify-content:flex-start; height:100dvh; max-height:100dvh; padding: max(0.5vh, env(safe-area-inset-top)) clamp(8px,2vw,10px) max(0.5vh, env(safe-area-inset-bottom)) clamp(8px,2vw,10px); gap: clamp(2px,0.5vh,4px); position: fixed; top:0; left:0; right:0; bottom:0; overflow:hidden !important; text-align:center; }
body:has(#exercise-container[style*="display: flex"]) { overflow:hidden !important; position: fixed; width:100%; height:100%; }

#timer.full-timer { display:block; font-size: clamp(2.5rem, 8vw, 3.8rem); font-weight: bold; color:#B0B0B0; text-align:center; z-index:2; line-height:1; margin:0; padding: clamp(4px,1vh,8px) clamp(8px,2vw,10px); width:100%; }

#exercise-name { font-size: clamp(15px,4vw,18px); font-weight:bold; color:#fff; margin: 0 clamp(8px,2vw,10px) clamp(2px,0.5vh,4px) clamp(8px,2vw,10px); line-height:1.2; min-height: clamp(42px,8vh,48px); display:flex; flex-direction:column; align-items:center; justify-content:center; padding: clamp(6px,1.5vh,8px) clamp(10px,2.5vw,14px); background: rgba(0,0,0,.85); backdrop-filter: blur(10px); border-radius:10px; box-shadow: 0 4px 16px rgba(0,0,0,.45); width: clamp(calc(100% - 16px), 95%, calc(100% - 20px)); max-width: min(600px,95vw); }

#exercise-gif,
#next-exercise-gif {
  width: min(85vw, 75vh); max-width: 90vw; aspect-ratio: 9/16; height:auto;
  object-fit: cover; object-position: center; display:block; margin:0 auto;
  border-radius: clamp(10px,2vw,12px); box-shadow: 0 4px 20px rgba(0,0,0,.35);
  clip-path: inset(5% 0 5% 0); flex-shrink: 0;
}

#controls-container { display:flex; justify-content:center; align-items:center; gap: clamp(6px,2vw,12px); padding: clamp(6px,1.5vh,8px) clamp(8px,2vw,10px); padding-bottom: max(clamp(6px,1.5vh,8px), env(safe-area-inset-bottom, 8px)); width:100%; }
#pause-button,.settings-btn,.nav-btn { padding: clamp(7px,2vh,10px) clamp(12px,3vw,20px); font-size: clamp(13px,3.5vw,16px); font-weight:bold; border:none; border-radius:8px; background:#000000; color:#FFFFFF; cursor:pointer; box-shadow: 0 4px 10px rgba(0,0,0,.3); transition: all .2s ease; border:1px solid #4D4D4D;}
#pause-button:hover,.settings-btn:hover,.nav-btn:hover { background:#4D4D4D; transform: translateY(-2px); }
.nav-btn { font-size: clamp(15px,4vw,18px); padding: clamp(7px,2vh,10px) clamp(10px,2.5vw,15px); background:#000000; border:1px solid #4D4D4D; }

#settings-popup, #setup-settings-popup { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index:10000; display:flex; align-items:center; justify-content:center; }
.settings-content { background: linear-gradient(135deg,#4D4D4D,#000000); padding: clamp(20px,4vw,30px); border-radius: clamp(12px,2.5vw,16px); box-shadow: 0 8px 32px rgba(0,0,0,.5); text-align:center; min-width: 300px; border: 1px solid #4D4D4D; }
.settings-content h3 { color:#B0B0B0; font-size: clamp(20px,4.5vw,24px); margin-bottom: clamp(15px,3vw,20px); text-transform: uppercase; letter-spacing: 1px; }
#close-settings,#close-setup-settings,#exit-workout-button,#logout-button {
  width:100%; padding: clamp(10px,2vw,12px); color:#fff; font-size: clamp(14px,2.8vw,16px); font-weight:bold; border:none; border-radius:8px; cursor:pointer; transition: all .2s ease; margin-top:10px;
}
#close-settings,#close-setup-settings { background:#4D4D4D; border:1px solid #4D4D4D; }
#exit-workout-button { background:#4D4D4D; border:1px solid #7D7D7D; }

/* ====== PROGRESS BAR ====== */
#workout-progress-container { width:100%; padding-top: max(12px, env(safe-area-inset-top, 12px)); padding-left: clamp(12px,2.5vw,16px); padding-right:16px; padding-bottom:8px; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255,255,255,0.12); flex-shrink:0; z-index:100; }
#progress-bar-wrapper { margin-bottom: 8px; }
#progress-bar { position:relative; width:100%; height: clamp(20px,3.5vh,24px); background: rgba(255,255,255,0.10); border-radius: clamp(10px,2vw,12px); overflow:hidden; border: 1px solid rgba(255,255,255,0.18); box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }
#progress-fill { position:absolute; left:0; top:0; height:100%; background: linear-gradient(90deg,#B0B0B0,#B0B0B0); border-radius: clamp(10px,2vw,12px); transition: width .5s ease; box-shadow: 0 0 10px rgba(255,255,255,0.25); }
#progress-percentage { position:absolute; left:50%; top:50%; transform: translate(-50%,-50%); font-size: clamp(10px,2vw,12px); font-weight:700; color:#FFFFFF; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
#progress-info { display:flex; justify-content:space-between; align-items:center; gap:8px; }
#progress-info span { font-size: clamp(9px,1.8vw,11px); font-weight:600; color:#B0B0B0; text-transform: uppercase; letter-spacing: 1.5px; white-space:nowrap; }

/* ====== VISUAL CUES (Monochrome) ====== */
#exercise-name.next-preview-active {
  background: linear-gradient(135deg, #ffffff, #FFFFFF) !important;
  border: 3px solid #B0B0B0 !important;
  box-shadow: 0 8px 32px rgba(255,255,255,0.25), 0 0 60px rgba(255,255,255,0.15), inset 0 1px 0 rgba(255,255,255,0.6) !important;
  animation: barPulse 2s ease-in-out infinite !important;
  color: #000 !important;
}
#exercise-name.next-preview-active div { color:#000000 !important; text-shadow:none !important; }

@keyframes barPulse { 0%,100%{transform:scale(1);box-shadow:0 8px 32px rgba(255,255,255,0.25),0 0 60px rgba(255,255,255,0.15);} 50%{transform:scale(1.02);box-shadow:0 10px 40px rgba(255,255,255,0.35),0 0 80px rgba(255,255,255,0.25);} }

#timer.full-timer.warning-10 { color:#FFFFFF; text-shadow: 0 0 24px rgba(255,255,255,.45); animation: timerGlow 1s ease-in-out infinite; }
#timer.full-timer.warning-6  { color:#FFFFFF; text-shadow: 0 0 28px rgba(255,255,255,.55); animation: timerGlow .8s ease-in-out infinite; }
#timer.full-timer.warning-3  { color:#ffffff; text-shadow: 0 0 32px rgba(255,255,255,.7);  animation: timerGlow .6s ease-in-out infinite; }
@keyframes timerGlow { 0%,100%{opacity:1} 50%{opacity:.85} }

#exercise-gif.gif-glow {
  border: 4px solid #ffffff;
  box-shadow: 0 0 30px rgba(255,255,255,0.35), 0 0 60px rgba(255,255,255,0.2), 0 4px 20px rgba(0,0,0,0.35);
  animation: gifPulse 2s ease-in-out infinite;
}
@keyframes gifPulse { 0%,100%{border-color:#ffffff;box-shadow:0 0 30px rgba(255,255,255,0.35),0 0 60px rgba(255,255,255,0.2),0 4px 20px rgba(0,0,0,0.35);} 50%{border-color:#f2f2f4;box-shadow:0 0 40px rgba(255,255,255,0.5),0 0 80px rgba(255,255,255,0.35),0 6px 25px rgba(0,0,0,0.4);} }

/* ====== VIEWPORT & UTILS ====== */
@supports (height: 100dvh) { #exercise-container { height: 100dvh !important; } }
@supports (height: -webkit-fill-available) { #exercise-container { height: -webkit-fill-available !important; } }
body:has(#exercise-container[style*="display: flex"]), body:has(#exercise-container[style*="display: flex"]) html { overflow:hidden !important; position:fixed !important; width:100% !important; height:100% !important; overscroll-behavior:none !important; }

/* Letter spacing kept */
body, button, select, label, .exercise-name, .section-title, .section-count { letter-spacing: .15em; }
h1, h2, h3, .settings-content h3, #workout-preview-title { letter-spacing: .1em; }
.start-button, #pause-button, #prev-exercise-button, #next-exercise-button, #settings-button, #setup-settings-button { letter-spacing: .13em; }
select option { letter-spacing: inherit; }


/* =========================
   EXPERT UI HIERARCHY SYSTEM
   Clear visual differentiation between interaction types
   ========================= */

/* ========================================
   1. PRIMARY ACTION BUTTONS (CTA)
   Purpose: Main user flow actions
   Visual: White, bold, prominent shadows
   Usage: Start Workout, Login, Continue
   ======================================== */
:root {
  --primary-bg: #FFFFFF;
  --primary-text: #000000;
  --primary-border: #E0E0E0;
  --primary-shadow: 0 6px 20px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  --primary-shadow-hover: 0 10px 30px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.4);
  --primary-shadow-active: 0 2px 8px rgba(0,0,0,0.25);
}

#start-button-bottom,
.start-button,
#login-button {
  appearance: none;
  background: var(--primary-bg) !important;
  color: var(--primary-text) !important;
  border: 2px solid var(--primary-border) !important;
  border-radius: 12px;
  padding: clamp(14px, 3vw, 18px) clamp(20px, 4vw, 28px);
  font-size: clamp(15px, 3.2vw, 18px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: var(--primary-shadow);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

#start-button-bottom:hover,
.start-button:hover,
#login-button:hover {
  transform: translateY(-3px);
  box-shadow: var(--primary-shadow-hover);
  background: #FFFFFF !important;
}

#start-button-bottom:active,
.start-button:active,
#login-button:active {
  transform: translateY(0);
  box-shadow: var(--primary-shadow-active);
}

/* ========================================
   2. SECONDARY BUTTONS (Navigation & Tools)
   Purpose: Support actions, navigation, settings
   Visual: Dark grey, subtle, less prominent
   Usage: Settings, Pause, Navigation arrows
   ======================================== */
:root {
  --secondary-bg: #4D4D4D;
  --secondary-text: #FFFFFF;
  --secondary-border: #7D7D7D;
  --secondary-shadow: 0 3px 10px rgba(0,0,0,0.3);
  --secondary-shadow-hover: 0 5px 15px rgba(0,0,0,0.4);
}

#pause-button,
.nav-btn,
.settings-btn,
#setup-settings-button,
#close-settings,
#close-setup-settings {
  appearance: none;
  background: var(--secondary-bg) !important;
  color: var(--secondary-text) !important;
  border: 1px solid var(--secondary-border) !important;
  border-radius: 10px;
  padding: clamp(10px, 2.2vw, 14px) clamp(16px, 3.2vw, 20px);
  font-size: clamp(13px, 2.8vw, 15px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: var(--secondary-shadow);
  transition: all 0.2s ease;
}

#pause-button:hover,
.nav-btn:hover,
.settings-btn:hover,
#setup-settings-button:hover,
#close-settings:hover,
#close-setup-settings:hover {
  background: #5D5D5D !important;
  transform: translateY(-2px);
  box-shadow: var(--secondary-shadow-hover);
  border-color: #8D8D8D !important;
}

#pause-button:active,
.nav-btn:active,
.settings-btn:active,
#setup-settings-button:active,
#close-settings:active,
#close-setup-settings:active {
  transform: translateY(0);
  background: #3D3D3D !important;
}

/* ========================================
   3. DESTRUCTIVE BUTTONS (Dangerous Actions)
   Purpose: Exit, logout, terminate session
   Visual: Outlined/hollow, strong border, no fill
   Usage: Exit Workout, Logout, End Session
   ======================================== */
:root {
  --destructive-bg: rgba(0, 0, 0, 0.3);
  --destructive-text: #FFFFFF;
  --destructive-border: #FFFFFF;
  --destructive-border-hover: #B0B0B0;
  --destructive-shadow: 0 0 0 1px rgba(255,255,255,0.2) inset, 0 3px 10px rgba(0,0,0,0.3);
  --destructive-shadow-hover: 0 0 0 2px rgba(255,255,255,0.4) inset, 0 5px 15px rgba(0,0,0,0.4);
}

#exit-workout-button,
#logout-button,
#reset-start-point {
  appearance: none;
  background: var(--destructive-bg) !important;
  color: var(--destructive-text) !important;
  border: 2px solid var(--destructive-border) !important;
  border-radius: 10px;
  padding: clamp(10px, 2.2vw, 13px) clamp(16px, 3.2vw, 20px);
  font-size: clamp(13px, 2.8vw, 15px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: var(--destructive-shadow);
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
}

#exit-workout-button:hover,
#logout-button:hover,
#reset-start-point:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: var(--destructive-border-hover) !important;
  box-shadow: var(--destructive-shadow-hover);
  transform: translateY(-1px);
}

#exit-workout-button:active,
#logout-button:active,
#reset-start-point:active {
  transform: translateY(0);
  background: rgba(0, 0, 0, 0.5) !important;
}

/* ========================================
   4. DISABLED STATE
   Purpose: Clearly show when actions are unavailable
   Visual: Low contrast, no shadow, no hover
   ======================================== */
button:disabled,
#start-button-bottom:disabled,
.start-button:disabled,
#login-button:disabled {
  background: rgba(77, 77, 77, 0.3) !important;
  color: #7D7D7D !important;
  border-color: #4D4D4D !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  transform: none !important;
  opacity: 0.5;
}

button:disabled:hover,
#start-button-bottom:disabled:hover,
.start-button:disabled:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* ========================================
   5. READ-ONLY SECTIONS (Information Display)
   Purpose: Headers, info cards, stats - NOT clickable
   Visual: Flat, no shadows, no hover, clear borders
   Usage: Instructions header, Material section, Progress info
   ======================================== */

/* Instructions Section - Read Only */
.instructions-header,
.materiale-header {
  background: linear-gradient(135deg, rgba(77, 77, 77, 0.3) 0%, rgba(77, 77, 77, 0.2) 100%);
  border: 1px solid rgba(176, 176, 176, 0.2);
  border-radius: 10px;
  padding: clamp(12px, 2.5vw, 16px) clamp(15px, 3vw, 20px);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: default;
  box-shadow: none; /* NO shadow - flat appearance */
  transition: none; /* NO hover effects */
}

/* Info Cards - Read Only */


#workout-preview-title {
  background: rgba(77, 77, 77, 0.15);

  border-radius: 8px;
  padding: clamp(12px, 2.5vw, 16px);
  box-shadow: none; /* Flat - no depth */
  cursor: default;
  transition: none;
}

#materiale-list,

#progress-info {
  background: rgba(77, 77, 77, 0.15);
  border: 1px solid rgba(176, 176, 176, 0.15);
  border-radius: 8px;
  padding: clamp(12px, 2.5vw, 16px);
  box-shadow: none; /* Flat - no depth */
  cursor: default;
  transition: none;
}

#materiale-list{background: rgb(255, 255, 255)}
/* Progress Bar Container - Read Only */
#workout-progress-container {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(176, 176, 176, 0.2);
  border-radius: 8px;
  padding: clamp(10px, 2vw, 14px);
  box-shadow: none;
}

/* Ensure headers have no interactive appearance */
#workout-preview-title,
.instructions-title,
.materiale-title {
  cursor: default;
  user-select: none;
  pointer-events: none;
}

/* Remove any hover effects from read-only elements */
.instructions-header:hover,
.materiale-header:hover,
#instructions-box:hover,
#materiale-list:hover,
#progress-info:hover {
  transform: none;
  box-shadow: none;
}

/* ========================================
   6. FOCUS STATES (Accessibility)
   Purpose: Keyboard navigation and screen readers
   ======================================== */
button:focus-visible,
#start-button-bottom:focus-visible,
.start-button:focus-visible,
#login-button:focus-visible {
  outline: none;
  box-shadow: var(--primary-shadow-hover), 0 0 0 4px rgba(255,255,255,0.3);
}

.nav-btn:focus-visible,
.settings-btn:focus-visible,
#pause-button:focus-visible,
#close-settings:focus-visible,
#close-setup-settings:focus-visible {
  outline: none;
  box-shadow: var(--secondary-shadow-hover), 0 0 0 3px rgba(255,255,255,0.15);
}

#exit-workout-button:focus-visible,
#logout-button:focus-visible,
#reset-start-point:focus-visible {
  outline: none;
  box-shadow: var(--destructive-shadow-hover), 0 0 0 3px rgba(255,255,255,0.25);
}

/* ========================================
   7. GENERIC BUTTON RESET
   Purpose: Ensure all other buttons follow system
   ======================================== */
button {
  appearance: none;
  border-radius: 10px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.1em;
}

/* Remove any gradient backgrounds */
button,
#start-button-bottom,
.start-button,
#login-button,
#close-settings,
#close-setup-settings {
  background-image: none !important;
}





/* Replace every bottom-buttons-container block with this ONE */
#bottom-buttons-container{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: var(--footer-total);           /* exact rendered height */
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 20px;                       
  padding-bottom: env(safe-area-inset-bottom, 0px); /* iOS safe area */
  background: linear-gradient(to top, rgba(0,0,0,.95), rgba(0,0,0,.9) 80%, transparent);
  backdrop-filter: blur(10px);
  z-index: 9999;
  transform: translateZ(0);
}

/* Hide bottom buttons on login screen */
#login-screen ~ #bottom-buttons-container,
body:has(#login-screen:not([style*="display: none"])) #bottom-buttons-container {
  display: none !important;
}

/* Show bottom buttons only when main-app is visible */
#main-app:not([style*="display: none"]) ~ #bottom-buttons-container {
  display: flex !important;
}


/* Replace ALL other #main-app rules for height/padding with this */
#main-app{
  height: calc(100svh - var(--header-height) - var(--footer-total));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  /* NO padding-bottom - container height already ends at footer's edge */
}

/* Add bottom margin to last element so content doesn't touch button when scrolled */
#main-app > *:last-child {
  margin-bottom: clamp(25px, 5vw, 35px);
}






/* Remove any older footer rule that sets a fixed height + big vertical % padding */


:root{
  --footer-base: 72px;                   /* tune to your design */
  --footer-safe: env(safe-area-inset-bottom, 0px);
  --footer-total: calc(var(--footer-base) + var(--footer-safe));
}
/* ====== TRAINING SELECTOR (LOGIN SCREEN) ====== */
.training-selector-container {
  margin: 40px auto 30px;
  max-width: 400px;
  padding: 0 20px;
}

.selector-instruction {
  text-align: center;
  color: var(--color-light-grey);
  font-size: 14px;
  margin-bottom: 20px;
  font-weight: 300;
  letter-spacing: 0.5px;
  animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.training-image-wrapper {
  position: relative;
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.training-base-image {
  width: 100%;
  height: auto;
  display: block;
}

/* Clickable zones overlaid on image */
.training-zone {
  position: absolute;
  width: 100%;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: transparent;
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Zone positioning - L-shaped layout */
.nutrition-zone {
  top: 0;
  left: 0;
  width: 28%;
  height: 100%;
  background: linear-gradient(to right, rgba(176, 176, 176, 0.05), transparent);
  border-right: 1px solid rgba(125, 125, 125, 0.2);
}

.aerobic-zone {
  top: 0;
  left: 27%;
  width: 73%;
  height: 43%;
  background: linear-gradient(to bottom, rgba(125, 125, 125, 0.05), transparent);
  border-bottom: 1px solid rgba(125, 125, 125, 0.2);
}

.muscle-zone {
  top: 43%;
  left: 27%;
  width: 73%;
  height: 58%;
  background: linear-gradient(to bottom, rgba(77, 77, 77, 0.05), transparent);
}

/* Hover/Tap effects */
.training-zone:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.1);
}

.training-zone.tapped {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid var(--color-white);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2);
  animation: tap-pulse 0.6s ease-out;
}

/* Specific border styling for each zone when tapped */
.nutrition-zone.tapped {
  border-right: 2px solid var(--color-white);
  border-top: 2px solid var(--color-white);
  border-bottom: 2px solid var(--color-white);
  border-left: 2px solid var(--color-white);
}

.aerobic-zone.tapped {
  border-top: 2px solid var(--color-white);
  border-right: 2px solid var(--color-white);
  border-bottom: 2px solid var(--color-white);
  border-left: none;
}

.muscle-zone.tapped {
  border-bottom: 2px solid var(--color-white);
  border-right: 2px solid var(--color-white);
  border-top: 2px solid var(--color-white);
  border-left: none;
}

@keyframes tap-pulse {
  0% {
    box-shadow: inset 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.4);
  }
  100% {
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2);
  }
}

.zone-label {
  position: absolute;
  color: transparent;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.tap-icon {
  position: absolute;
  font-size: 24px;
  animation: tap-bounce 2s ease-in-out infinite;
  filter: grayscale(100%) brightness(0.8);
  opacity: 0.5;
  color: #7D7D7D;
}

/* Position tap icons appropriately for each zone */
.nutrition-zone .tap-icon {
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
}

.aerobic-zone .tap-icon {
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
}

.muscle-zone .tap-icon {
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
}

@keyframes tap-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.training-zone:active .tap-icon {
  animation: none;
  transform: scale(1.3);
}

/* Bottom Sheet */
.bottom-sheet {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bottom-sheet.active {
  pointer-events: all;
  opacity: 1;
}

.bottom-sheet-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bottom-sheet.active .bottom-sheet-overlay {
  opacity: 1;
}

.bottom-sheet-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-dark-grey);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + var(--safe-area-bottom));
  max-height: 70vh;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.8);
}

.bottom-sheet.active .bottom-sheet-panel {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-medium-grey);
  border-radius: 2px;
  margin: 0 auto 20px;
  opacity: 0.5;
}

.bottom-sheet-content {
  text-align: center;
}

.bottom-sheet-content h3 {
  color: var(--color-white);
  font-size: 24px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.bottom-sheet-content p {
  color: var(--color-light-grey);
  font-size: 15px;
  margin-bottom: 30px;
  line-height: 1.5;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-btn {
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sheet-btn.primary {
  background: var(--color-white);
  color: var(--color-black);
}

.sheet-btn.primary:active {
  transform: scale(0.97);
  background: var(--color-light-grey);
}

.sheet-btn.secondary {
  background: transparent;
  color: var(--color-white);
  border: 2px solid var(--color-medium-grey);
}

.sheet-btn.secondary:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.05);
}

/* Mobile optimization */
@media (max-width: 480px) {
  .training-selector-container {
    margin: 30px auto 20px;
    padding: 0 15px;
  }
  
  .selector-instruction {
    font-size: 13px;
    margin-bottom: 15px;
  }
  
  .tap-icon {
    font-size: 20px;
    right: 10px;
  }
  
  .bottom-sheet-content h3 {
    font-size: 20px;
  }
  
  .bottom-sheet-content p {
    font-size: 14px;
  }
}

/* Ensure login card appears below */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: calc(100vh - var(--header-height));
}


/* Make zones slightly more visible on initial load */
.training-zone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.nutrition-zone::before {
  border-top: none;
}

/* Enhance tap icon visibility on active zone */
.training-zone:active .tap-icon,
.training-zone.tapped .tap-icon {
  transform: scale(1.3);
  opacity: 1;
  filter: grayscale(100%) brightness(1.5);
}

.nutrition-zone:active .tap-icon,
.nutrition-zone.tapped .tap-icon {
  transform: translateX(-50%) scale(1.3);
}

.aerobic-zone:active .tap-icon,
.aerobic-zone.tapped .tap-icon {
  transform: translateY(-50%) scale(1.3);
}

.muscle-zone:active .tap-icon,
.muscle-zone.tapped .tap-icon {
  transform: translateY(-50%) scale(1.3);
}
