  :root {
    --bg: #050505;
    /* Glass variables */
    --glass-bg: rgba(20, 20, 20, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    /* Fallback surface/border used by workout entries */
    --surface: rgba(20, 20, 20, 0.45);
    --border: rgba(255, 255, 255, 0.08);

    --accent: #e8ff47;
    --accent2: #ff6b35;
    --text: #f0f0f0;
    --muted: #888;
    --red: #ff4444;
    --green: #44ff88;
  }

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

  body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* LIQUID GLASS BACKGROUND: Grid + Glowing Orbs */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      radial-gradient(circle at 15% 50%, rgba(232, 255, 71, 0.07), transparent 30%),
      radial-gradient(circle at 85% 30%, rgba(255, 107, 53, 0.07), transparent 30%),
      linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    pointer-events: none;
    z-index: 0;
  }

  .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 0px;
    position: relative;
    z-index: 1;
  }

  /* GLASS UTILITY CLASS */
  .glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255, 255, 255, 0.15); /* Subtle light catch */
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--glass-shadow);
  }

  /* HEADER */
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 0 24px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 32px;
  }

  .logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.6rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 20px rgba(232, 255, 71, 0.2);
  }

  .logo span { color: var(--text); }

  .date-display {
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: right;
  }

  /* TABS */
  .tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 28px;
    padding: 6px;
    border-radius: 12px;
  }

  .tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  }

  .tab.active {
    background: var(--accent);
    color: #000;
    font-weight: 500;
    box-shadow: 0 0 15px rgba(232, 255, 71, 0.3);
  }

  .tab:hover:not(.active) { color: var(--text); background: rgba(255, 255, 255, 0.05); }

  /* VIEWS */
  .view { display: none; animation: fadeIn 0.4s ease; }
  .view.active { display: block; }
  
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* STAT CARDS */
  .stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
  }

  .stat-card {
    border-radius: 16px;
    padding: 20px;
    position: relative;
    overflow: hidden;
  }

  .stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
  }

  .stat-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
  }

  .stat-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.2rem;
    letter-spacing: 0.05em;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 10px rgba(232, 255, 71, 0.1);
  }

  .stat-sub {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 4px;
  }

  /* CARDS */
  .card {
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
  }

  .card-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .card-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
  }

  /* FORMS & INPUTS (Inset Glass) */
  label {
    display: block;
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.8;
    margin-bottom: 8px;
  }

input, select, textarea {
    width: 100%;
    min-width: 0; /* Forces grid children to shrink below their intrinsic width */
    max-width: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    padding: 12px 14px;
    outline: none;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  }

/* Specific fix for stubborn date pickers on iOS Safari */
  input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
    overflow: hidden; /* Clips the internal native calendar UI if it tries to stretch */
    white-space: nowrap;
    font-family: 'DM Mono', monospace;
    font-size: 16px !important; /* Prevents the iOS auto-zoom bug that breaks grid widths */
    padding: 12px 10px;
  }
  
  /* Safari sometimes adds a weird clear button inside the shadow DOM that adds invisible width */
  input[type="date"]::-webkit-clear-button,
  input[type="date"]::-webkit-inner-spin-button {
    display: none;
  }

  input:focus, select:focus, textarea:focus {
    border-color: rgba(232, 255, 71, 0.5);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 0 12px rgba(232, 255, 71, 0.1);
  }

  /* Fix for input date icon in some browsers */
  ::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.6; cursor: pointer; }

  select option { background: #111; color: #fff; }

  textarea { resize: vertical; min-height: 80px; }

  .form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
  .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .form-row > div, .form-row-2 > div { min-width: 0; }

  .exercises-list { margin-bottom: 16px; }

  .exercise-item {
    display: grid;
    grid-template-columns: 1fr 100px 70px 70px 80px 36px 36px;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .exercise-item input,
  .exercise-item select { margin-bottom: 0; padding: 10px; }

  /* BUTTONS */
  .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  }

  .btn-primary {
    background: var(--accent);
    color: #000;
    font-weight: 500;
    width: 100%;
    padding: 14px;
    box-shadow: 0 4px 15px rgba(232, 255, 71, 0.2);
  }

  .btn-primary:hover { 
    background: #d4eb2a; 
    transform: translateY(-2px); 
    box-shadow: 0 6px 20px rgba(232, 255, 71, 0.3);
  }
  
  .btn-primary:active { transform: translateY(0); }

  .btn-ghost {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(4px);
  }

  .btn-ghost:hover { 
    border-color: rgba(255,255,255,0.2); 
    background: rgba(255,255,255,0.08);
  }

  .btn-danger {
    background: rgba(255, 68, 68, 0.1);
    color: #ff7777;
    border: 1px solid rgba(255, 68, 68, 0.2);
  }

  .btn-danger:hover { background: rgba(255, 68, 68, 0.2); border-color: rgba(255, 68, 68, 0.4); }

  .btn-icon {
    background: rgba(255, 68, 68, 0.05);
    color: var(--red);
    border: 1px solid rgba(255, 68, 68, 0.15);
    padding: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
  }

  .btn-icon:hover { background: rgba(255, 68, 68, 0.15); border-color: var(--red); transform: scale(1.05); }

  .btn-confirm {
    background: rgba(68, 255, 136, 0.06);
    color: var(--green);
    border: 1px solid rgba(68, 255, 136, 0.2);
  }
  .btn-confirm:hover { background: rgba(68, 255, 136, 0.15); border-color: var(--green); transform: scale(1.05); }

  .btn-add-exercise {
    background: rgba(255,255,255,0.02);
    border: 1px dashed rgba(255,255,255,0.15);
    color: var(--text);
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all 0.3s;
    margin-bottom: 20px;
  }

  .btn-add-exercise:hover { 
    border-color: var(--accent); 
    color: var(--accent); 
    background: rgba(232,255,71,0.05);
  }

  /* WORKOUT HISTORY */
  .workout-entry {
    background: var(--surface);
    /* Base border for top, right, and bottom */
    border: 1px solid var(--border); 
    /* The "Orange Bar" implemented as a native left border */
    border-left: 4px solid var(--accent2); 
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    /* Remove overflow: hidden if it's interfering, 
       but keeping it is fine for internal content */
    overflow: hidden; 
  }

  .workout-entry:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  }

  .workout-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .workout-entry-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.3rem;
    letter-spacing: 0.06em;
    color: var(--text);
  }

  .workout-meta { display: flex; flex-wrap: wrap; gap: 10px; }

  .meta-pill {
    background: rgba(0,0,0,0.3);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--text);
    opacity: 0.9;
  }

  .meta-pill strong { color: var(--accent); font-weight: 500; }

  .exercise-chips { display: flex; flex-wrap: wrap; gap: 8px; }

  .chip {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    color: var(--text);
    opacity: 0.8;
    letter-spacing: 0.05em;
  }

  .expanded-detail {
    margin-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: none;
    animation: fadeIn 0.3s ease;
  }

  .workout-entry.open .expanded-detail { display: block; }

  .exercise-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
  }

  .exercise-table th {
    text-align: left;
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.65rem;
    padding: 8px 8px 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  .exercise-table td { padding: 10px 8px 10px 0; color: var(--text); }
  .exercise-table tr:not(:last-child) td { border-bottom: 1px solid rgba(255,255,255,0.05); }

  /* HISTORY TAB BUTTONS */
  .btn-share {
    background: rgba(232,255,71,0.08);
    border: 1px solid rgba(232,255,71,0.2);
    color: var(--accent);
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-share:hover { background: rgba(232,255,71,0.15); box-shadow: 0 0 10px rgba(232,255,71,0.2); }

  .delete-workout {
    background: transparent;
    border: 1px solid rgba(255,68,68,0.2);
    color: #ff7777;
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.2s;
  }

  .delete-workout:hover { background: rgba(255,68,68,0.1); border-color: rgba(255,68,68,0.4); }

  /* PROGRESS VIEW */
  .pr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;      /* Removed the huge 28px margin */
    
    /* Scroll Settings */
    max-height: 380px;     
    overflow-y: auto;      
    padding-right: 8px;    
    padding-bottom: 4px;   /* Just 4px so the inner shadows don't clip */
  }
  
  /* Optional: Make the scrollbar look sleek and match the glass theme */
  .pr-grid::-webkit-scrollbar {
    width: 6px;
  }
  .pr-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
  }
  .pr-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
  }
  .pr-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 255, 71, 0.4); /* Glows with your accent color on hover */
  }

  .pr-card {
    border-radius: 16px;
    padding: 18px 18px 14px 18px; /* Slightly tighter at the bottom */
  }

  .pr-exercise {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.8;
    margin-bottom: 8px;
  }

  .pr-weight {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    letter-spacing: 0.05em;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 10px rgba(232, 255, 71, 0.1);
  }

  .pr-detail {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 6px;
    font-family: 'DM Mono', monospace;
  }

  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text);
    opacity: 0.6;
    font-family: 'DM Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
  }

  .empty-icon { font-size: 2.8rem; margin-bottom: 16px; opacity: 0.5; }

  /* CHART CONTROLS */
  .chart-controls { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
  
  .chart-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    color: var(--text);
    opacity: 0.7;
    border-radius: 8px;
    padding: 8px 14px;
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.2s;
  }

  .chart-btn.active { 
    background: rgba(232,255,71,0.1); 
    color: var(--accent); 
    border-color: rgba(232,255,71,0.3); 
    opacity: 1; 
  }
  
  .chart-btn:hover:not(.active) { opacity: 1; background: rgba(255,255,255,0.08); }

  .chart-wrap { border-radius: 16px; padding: 20px; position: relative; }
  canvas { display: block; max-height: 220px; }

  /* QUICK TIMER */
  .quick-timers { display: flex; gap: 10px; }
  .btn-timer {
    flex: 1;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    border-radius: 10px;
    padding: 10px;
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  }
  .btn-timer:hover {
    border-color: rgba(232,255,71,0.4);
    color: var(--accent);
    background: rgba(232,255,71,0.05);
    transform: translateY(-2px);
  }

  /* FULL PAGE REST TIMER WIDGET (Glassy Overlay) */
  .rest-timer-widget {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
  }

  .rest-timer-widget.active { opacity: 1; pointer-events: auto; }
  .rest-timer-widget.blinking { animation: blinkGlassTimer 1.2s infinite alternate; }

  @keyframes blinkGlassTimer {
    0% { background: rgba(5, 5, 5, 0.6); }
    100% { background: rgba(232, 255, 71, 0.15); }
  }

  .timer-display {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 8rem;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 30px;
    text-shadow: 0 0 30px rgba(232,255,71,0.3);
    font-variant-numeric: tabular-nums;
  }

  .timer-controls { display: flex; gap: 24px; margin-bottom: 50px; }

  .timer-btn-adjust {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text);
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
  }

  .timer-btn-adjust:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(232, 255, 71, 0.08);
    box-shadow: 0 0 15px rgba(232,255,71,0.2);
  }

  .timer-btn-close {
    background: rgba(255, 68, 68, 0.2);
    color: #ffaaaa;
    border: 1px solid rgba(255, 68, 68, 0.3);
    padding: 16px 40px;
    border-radius: 30px;
    font-family: 'DM Mono', monospace;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
  }

  .timer-btn-close:hover {
    background: rgba(255, 68, 68, 0.4);
    color: #fff;
    box-shadow: 0 0 20px rgba(255,68,68,0.3);
  }

  .timer-btn-close:active { transform: scale(0.95); }

  /* ── FLOATING MINI TIMER PILL ── */
  .mini-timer-pill {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.6rem;
    padding: 6px 24px;
    border-radius: 30px;
    z-index: 4000;
    backdrop-filter: blur(12px);
    cursor: pointer;
    display: none; /* Hidden by default */
    box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 15px rgba(232,255,71,0.15);
    letter-spacing: 0.05em;
  }
  .mini-timer-pill.blinking { 
    animation: blinkGlassTimer 1.2s infinite alternate; 
    color: #000;
  }

  /* TOAST */
  .toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: rgba(232, 255, 71, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #000;
    padding: 12px 24px;
    border-radius: 30px;
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    font-weight: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(232,255,71,0.3);
  }

  .toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

  .toast.lifted { bottom: 100px; }

  /* HIDDEN SHARE NODE CONTAINER */
  #share-container { position: absolute; top: -9999px; left: -9999px; }
  .share-card {
    width: 600px; background: #050505; padding: 50px; color: var(--text); font-family: 'DM Sans', sans-serif; position: relative;
  }
  .share-content { position: relative; z-index: 1; }

  /* ── SPECIFIC GRID FOR EDIT MODAL (DESKTOP) ── */
  #editExercisesList .exercise-item {
    grid-template-columns: 1fr 100px 70px 70px 80px 36px;
  }

  /* ── FLOATING END SESSION BUTTON ── */
  .fab-end-session {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 68, 68, 0.15);
    color: #ff7777;
    border: 1px solid rgba(255, 68, 68, 0.4);
    padding: 14px 28px;
    border-radius: 30px;
    font-family: 'DM Mono', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  }
  
  .fab-end-session:hover {
    background: rgba(255, 68, 68, 0.25);
    color: #fff;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 12px 40px rgba(255, 68, 68, 0.3);
  }

  /* MOBILE RESPONSIVE FIXES */
  @media (max-width: 600px) {
    header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .date-display { text-align: left; }
    .stats-row { grid-template-columns: 1fr 1fr; } 
    .form-row, .form-row-2 { grid-template-columns: 1fr; } 
    .pr-grid { grid-template-columns: 1fr; }
    .card { padding: 20px; }

    .form-row > div, .form-row-2 > div { min-width: 0; width: 100%; }
    
    #exerciseHeaders, #editExerciseHeaders { display: none !important; }
    
    /* New exercise block mobile layout */
    .exercise-block { padding: 8px; }
    .exercise-block-header { grid-template-columns: 1fr 28px; }
    .exercise-block-header .muscle-select-wrap { display: none; }

    .load-row { grid-template-columns: 1fr 1fr 1fr 36px 36px; }
    .load-row-labels { grid-template-columns: 1fr 1fr 1fr 36px 36px; }
    .load-row input { min-width: 0; margin-bottom: 0; }

    /* Edit modal exercise-item (flat rows, unchanged) */
    .exercise-item { 
      grid-template-columns: 1fr 1fr 1fr 38px !important; 
      grid-template-rows: auto auto auto;
      gap: 0 8px;
    }
    .exercise-item > *:nth-child(1) { grid-column: 1 / span 3; grid-row: 1; }
    .exercise-item > *:nth-child(2) { grid-column: 1 / span 3; grid-row: 2; }
    .exercise-item > *:nth-child(3) { grid-column: 1; grid-row: 3; }
    .exercise-item > *:nth-child(4) { grid-column: 2; grid-row: 3; }
    .exercise-item > *:nth-child(5) { grid-column: 3; grid-row: 3; }
    #editExercisesList .exercise-item > .btn-icon {
      grid-column: 4; grid-row: 1 / span 2; height: calc(100% - 12px); width: 100%;
    }
    .exercise-item input { min-width: 0; margin-bottom: 0; }
    
    .timer-display { font-size: 6.5rem; }
  }

  /* REFINED CHECK-IN STYLING */
  .checkin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
  }

  /* Glass Input Styling */
  .glass-input-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s ease;
  }

  .glass-input-group:focus-within {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(68, 255, 136, 0.4);
    box-shadow: 0 0 15px rgba(68, 255, 136, 0.1);
  }

  .glass-input-group label {
    margin-bottom: 4px;
    font-size: 0.6rem;
    color: var(--muted);
  }

  .glass-input-group input {
    background: transparent !important;
    border: none !important;
    padding: 4px 0 !important;
    margin-bottom: 0 !important;
    font-family: 'DM Mono', monospace;
    font-size: 1.1rem;
    box-shadow: none !important;
  }

  /* Slider Styling */
  .soreness-slider-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
  }

  /* Custom Toggle Switch for Zinc */
  .switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
  }

  .switch input { opacity: 0; width: 0; height: 0; }

  .slider-round {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
  }

  .slider-round:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--muted);
    transition: .4s;
    border-radius: 50%;
  }

  input:checked + .slider-round { background-color: rgba(68, 255, 136, 0.2); border-color: var(--green); }
  input:checked + .slider-round:before { transform: translateX(20px); background-color: var(--green); }

  .insights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 24px;
  }

  .chart-container-glass {
    border-radius: 20px;
    padding: 24px;
    position: relative;
    overflow: hidden;
  }

  .legend-overlay {
    display: flex;
    flex-wrap: wrap; /* <-- Add this to allow new lines */
    gap: 16px;       /* This handles both horizontal and vertical spacing when wrapped */
    margin-bottom: 20px;
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .legend-item { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    white-space: nowrap; /* <-- Add this to keep the dot and text together */
  }

  .dot-vol { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  .dot-rec { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }

  .nutrition-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
  }

  .nutrient-card {
    padding: 16px;
    border-radius: 14px;
    text-align: center;
    position: relative;
  }

  .nutrient-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    display: block;
  }

  .nutrient-count {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    color: var(--accent);
    line-height: 1;
  }

  .nutrient-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 4px;
  }

  .streak-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(68, 255, 136, 0.1);
    color: var(--green);
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(68, 255, 136, 0.2);
  }

  /* HEATMAP STYLING */
  .heatmap-container {
    margin-top: 24px;
    padding: 16px;
    border-radius: 16px;
    overflow-x: auto; /* Ensures it's scrollable on small screens */
  }

  .heatmap-grid {
    display: grid;
    grid-template-columns: repeat(13, 1fr); /* Shows approx 3 months of weeks */
    gap: 4px;
    min-width: 300px;
  }

  .heatmap-column {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    gap: 4px;
  }

  .heatmap-day {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    width: 100%;
    transition: transform 0.2s ease;
  }

  .heatmap-day:hover {
    transform: scale(1.3);
    z-index: 2;
  }

  /* Intensity Levels based on --accent color */
  .level-0 { background: rgba(255, 255, 255, 0.05); }
  .level-1 { background: rgba(232, 255, 71, 0.2); }
  .level-2 { background: rgba(232, 255, 71, 0.4); }
  .level-3 { background: rgba(232, 255, 71, 0.7); }
  .level-4 { background: rgba(232, 255, 71, 1); box-shadow: 0 0 8px var(--accent); }

  .heatmap-labels {
    display: flex;
    justify-content: space-between;
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: var(--muted);
    margin-top: 8px;
    text-transform: uppercase;
    min-width: 300px;
  }

  /* ── REST DAY HEATMAP COLOR ── */
  .level-rest { 
    background: rgba(100, 180, 255, 0.25); 
    border: 1px solid rgba(100, 180, 255, 0.4); 
  }
  .level-rest:hover { 
    background: rgba(100, 180, 255, 0.4); 
    box-shadow: 0 0 10px rgba(100, 180, 255, 0.5); 
  }

  /* ── REST DAY HISTORY CARD ── */
  .rest-entry {
    background: rgba(100, 180, 255, 0.05);
    border: 1px solid rgba(100, 180, 255, 0.15);
    border-left: 4px solid #64b4ff;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
  }
  
  .rest-entry-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    color: #64b4ff;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* RADAR CHART CONTAINER */
  .radar-container {
    max-height: 300px;
    margin: 20px 0;
    display: flex;
    justify-content: center;
  }

  /* QUICK PEEK POPOVER */
  .name-wrapper {
    grid-column: 1; /* Default for desktop */
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
  }

  .history-peek-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background: rgba(232, 255, 71, 0.15);
    border: 1px solid rgba(232, 255, 71, 0.3);
    color: var(--accent);
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
  }

  .history-peek-btn:hover {
    background: var(--accent);
    color: #000;
  }

  /* Ensure the text doesn't hide under the button */
  .name-wrapper input {
    padding-right: 55px !important;
    margin-bottom: 0 !important;
  }

  .history-peek-btn:hover { background: rgba(232, 255, 71, 0.1); }

  /* CONFETTI ANIMATION FOR VOLUME PR */
  @keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
  }
  .confetti {
    position: fixed; width: 10px; height: 10px; background: var(--accent);
    z-index: 3000; pointer-events: none; animation: confetti-fall 3s linear forwards;
  }

  /* ── PEEK POPOVER ── */
  .peek-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 200;
    background: rgba(14,14,14,0.97);
    border: 1px solid rgba(232,255,71,0.25);
    border-radius: 10px;
    padding: 12px 14px;
    min-width: 260px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: fadeIn 0.15s ease;
  }
  .peek-popover-title {
    font-family: 'DM Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
  }
  .peek-popover table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
  }
  .peek-popover td {
    padding: 5px 6px 5px 0;
    color: var(--text);
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }
  .peek-popover td:first-child { color: var(--muted); white-space: nowrap; }
  .peek-popover tr:last-child td { border-bottom: none; }
  .peek-popover-empty { font-family:'DM Mono',monospace; font-size:0.72rem; color:var(--muted); }

  /* ── UNTAGGED EXERCISE HIGHLIGHT ── */
  .exercise-item.no-muscle .muscle-select-wrap select {
    border-color: rgba(255,200,50,0.35) !important;
    color: rgba(255,200,50,0.8) !important;
  }

  /* ── MULTI-LOAD ROWS ── */
  .exercise-block {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 10px 10px 6px;
    margin-bottom: 10px;
    background: rgba(0,0,0,0.15);
    animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  .exercise-block-header {
    display: grid;
    grid-template-columns: 1fr 100px 28px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
  }
  .exercise-block-header input,
  .exercise-block-header select { margin-bottom: 0; }

  .load-row {
    display: grid;
    grid-template-columns: 70px 70px 80px 36px 36px;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px; /* Default tight spacing */
    transition: margin-bottom 0.2s ease;
    position: relative;
  }

  /* Only expand when the JS detects history and adds the deltas */
  .load-row.has-deltas {
    margin-bottom: 22px; 
  }

  .load-row input { margin-bottom: 0; padding: 10px; }
  .load-row:first-of-type { margin-top: 4px; }

  .load-row-labels {
    display: grid;
    grid-template-columns: 70px 70px 80px 36px 36px;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 2px;
  }
  .load-row-labels span {
    font-family: 'DM Mono', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .btn-add-load {
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.12);
    color: var(--muted);
    width: 100%;
    padding: 6px;
    border-radius: 7px;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    transition: all 0.2s;
    margin-top: 4px;
  }
  .btn-add-load:hover { border-color: var(--accent); color: var(--accent); background: rgba(232,255,71,0.04); }

  .btn-remove-block {
    background: rgba(255,68,68,0.05);
    color: var(--red);
    border: 1px solid rgba(255,68,68,0.15);
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
  }
  .btn-remove-block:hover { background: rgba(255,68,68,0.15); border-color: var(--red); }

  @media (max-width: 600px) {
    .load-row { 
      grid-template-columns: 1fr 1fr 1fr 36px 36px; 
      /* No need to redefine margins here, it inherits the logic above! */
    }
    .load-row-labels { grid-template-columns: 1fr 1fr 1fr 36px 36px; }
    .exercise-block-header { grid-template-columns: 1fr 28px; }
    .exercise-block-header .muscle-select-wrap { display: none; } /* hidden on mobile, use block-level muscle */
  }

  /* ── BODYWEIGHT CHART ── */
  .bw-chart-wrap { border-radius: 16px; padding: 20px; position: relative; }

  /* ── WORKOUT SESSION TIMER BAR ── */
  .session-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: rgba(232,255,71,0.08);
    border: 1px solid rgba(232,255,71,0.25);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    gap: 16px;
  }
  .session-bar.active { display: flex; }

  .session-clock {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    color: var(--accent);
    letter-spacing: 0.06em;
    line-height: 1;
    text-shadow: 0 0 20px rgba(232,255,71,0.3);
    font-variant-numeric: tabular-nums;
  }

  .session-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .btn-start-session {
    width: 100%;
    padding: 14px;
    background: rgba(232,255,71,0.08);
    border: 1px dashed rgba(232,255,71,0.35);
    border-radius: 10px;
    color: var(--accent);
    font-family: 'DM Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 24px;
  }
  .btn-start-session:hover { background: rgba(232,255,71,0.14); }
  .btn-start-session.running {
    background: rgba(255,68,68,0.08);
    border-color: rgba(255,68,68,0.35);
    color: #ff7777;
  }
  .btn-start-session.running:hover { background: rgba(255,68,68,0.14); }

  /* ── SESSION RECAP OVERLAY ── */
  .recap-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,5,5,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 4000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    padding: 40px 20px 60px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
  }
  .recap-overlay.active { opacity: 1; pointer-events: auto; }

  .recap-inner {
    width: 100%;
    max-width: 680px;
    animation: slideIn 0.5s cubic-bezier(0.25,1,0.5,1);
  }

  .recap-hero {
    text-align: center;
    margin-bottom: 40px;
  }

  .recap-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3.5rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 40px rgba(232,255,71,0.3);
    margin-bottom: 8px;
  }

  .recap-subtitle {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .recap-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
  }

  .recap-stat {
    background: rgba(20,20,20,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-top-color: rgba(232,255,71,0.3);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 90px;
  }

  .recap-stat-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 4px;
  }

  .recap-stat-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .recap-exercise-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
    margin-bottom: 32px;
  }
  .recap-exercise-table th {
    text-align: left;
    color: var(--muted);
    font-weight: 400;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 8px 10px 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .recap-exercise-table td {
    padding: 10px 10px 10px 0;
    color: var(--text);
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }
  .recap-exercise-table tr:last-child td { border-bottom: none; }

  .recap-pr-badge {
    display: block; /* Forces the badge onto a new line */
    width: fit-content; /* Keeps the background hugging the text tightly */
    margin-top: 4px; /* Adds a little breathing room above it */
    background: rgba(232,255,71,0.15);
    color: var(--accent);
    border: 1px solid rgba(232,255,71,0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
  }

  /* ─── LIGHT MODE OVERRIDES ────────────────────────────────────────────── */
  body.light-mode {
    --bg: #f4f4f5; /* Soft, clean off-white */
    --glass-bg: rgba(255, 255, 255, 0.75); /* Crisp frosted white */
    --glass-border: rgba(0, 0, 0, 0.08); /* Subtle dark border */
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.06); /* Airy, soft shadow */
    --surface: rgba(255, 255, 255, 0.9);
    --border: rgba(0, 0, 0, 0.12);

    /* Darkened the neon colors so they are readable on white! */
    --accent: #9eb300; /* Deep, sporty lime */
    --accent2: #e04f1a; /* Deeper orange */
    --text: #171717; /* Near black for ultimate readability */
    --muted: #6b7280; /* Clean medium gray */
  }

  /* 1. Fix the Liquid Background Orbs & Grid */
  body.light-mode::before {
    background-image:
      radial-gradient(circle at 15% 50%, rgba(158, 179, 0, 0.12), transparent 30%),
      radial-gradient(circle at 85% 30%, rgba(224, 79, 26, 0.12), transparent 30%),
      linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
  }

  /* 2. Fix the Input Fields & Textareas */
  body.light-mode input, 
  body.light-mode select, 
  body.light-mode textarea {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  }

  body.light-mode input:focus, 
  body.light-mode select:focus, 
  body.light-mode textarea:focus {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(158, 179, 0, 0.15); /* Soft lime glow ring */
  }

  /* 3. Fix Ghost Buttons & Tabs */
  body.light-mode .btn-ghost {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text);
  }

  body.light-mode .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.08);
  }

  body.light-mode .tab:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
  }

  /* 4. Fix Swipe-to-Delete Background */
  body.light-mode .swipe-delete-bg {
    background: #ff4444;
    color: white;
  }

  /* ── LIGHT MODE: UI ELEMENTS OVERRIDES ── */
  
  /* 1. Modals */
  body.light-mode .modal {
    background: rgba(245, 245, 245, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-top-color: #ffffff; /* Crisp white highlight for 3D effect */
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
  }

  /* 2. Chips & Pills (Exercise tags, muscle groups) */
  body.light-mode .chip {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text);
  }
  body.light-mode .meta-pill {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text);
  }

  /* 3. Date Picker Calendar Icon */
  body.light-mode ::-webkit-calendar-picker-indicator {
    filter: invert(0); /* Stops the icon from turning white */
    opacity: 0.7;
  }

  /* 4. Empty States ("No activity found") */
  body.light-mode .empty-state {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
  }
  
  /* 5. Full Screen Timer Widget & Buttons */
  body.light-mode .rest-timer-widget {
    background: rgba(245, 245, 245, 0.95);
  }
  body.light-mode .timer-btn-adjust, 
  body.light-mode .timer-btn-close {
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--text) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
  }

  /* 6. Glass Panel Reflections (Fixes the flat look) */
  body.light-mode .glass-panel {
    border-top: 1px solid #ffffff;
    border-left: 1px solid #ffffff;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  /* ── LIGHT MODE: CONFIRMATION POPUP OVERRIDE ── */
  body.light-mode .confirm-box {
    background: rgba(245, 245, 245, 0.98) !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15) !important;
  }
  body.light-mode .confirm-box h3 {
    color: var(--text) !important;
  }
  body.light-mode .confirm-box p {
    color: var(--muted) !important;
  }
  body.light-mode .confirm-btn-cancel {
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--text) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
  }

  /* ── LIGHT MODE: SESSION RECAP OVERLAY ── */

  /* 1. The main full-screen overlay background */
  body.light-mode .recap-overlay {
    background: rgba(245, 245, 245, 0.85) !important; /* Brighten the dark backdrop */
    backdrop-filter: blur(12px);
  }

  /* 2. The dynamic stat boxes injected into #recapStats */
  body.light-mode #recapStats > div {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
  }

  /* 3. The Recap Exercise Table headers and borders */
  body.light-mode .recap-exercise-table th {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--muted) !important;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1) !important;
  }
  
  body.light-mode .recap-exercise-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    color: var(--text) !important;
  }
  
  /* 4. The dynamically generated "NEW PR" badges inside the table */
  body.light-mode .recap-pr-badge {
    background: rgba(158, 179, 0, 0.15) !important;
    border: 1px solid rgba(158, 179, 0, 0.3) !important;
    color: var(--accent) !important; 
  }

  /* ── LIGHT MODE: CONSISTENCY HEATMAP OVERRIDE ── */
  /* Empty days */
  body.light-mode .heatmap-day {
    background: rgba(0, 0, 0, 0.06); 
    border: 1px solid rgba(0, 0, 0, 0.04);
  }
  /* Active days (Using the darkened lime accent #9eb300) */
  body.light-mode .heatmap-day.level-1 { 
    background: rgba(158, 179, 0, 0.3); 
    border-color: rgba(158, 179, 0, 0.4); 
  }
  body.light-mode .heatmap-day.level-2 { 
    background: rgba(158, 179, 0, 0.5); 
    border-color: rgba(158, 179, 0, 0.6); 
  }
  body.light-mode .heatmap-day.level-3 { 
    background: rgba(158, 179, 0, 0.7); 
    border-color: rgba(158, 179, 0, 0.8); 
  }
  body.light-mode .heatmap-day.level-4 { 
    background: rgba(158, 179, 0, 1); 
    border-color: rgba(158, 179, 0, 1); 
  }
  /* Rest days (Deepen the icy blue for white backgrounds) */
  body.light-mode .heatmap-day.level-rest {
    background: rgba(100, 180, 255, 0.4);
    border-color: rgba(100, 180, 255, 0.6);
  }

  /* ── WEEKLY TARGET BAR ── */
  .weekly-target-wrap {
    margin-bottom: 28px;
  }
  .weekly-target-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .weekly-target-header strong { color: var(--accent); font-size: 0.85rem; }
  .weekly-bar-bg {
    height: 8px;
    background: rgba(255,255,255,0.07);
    border-radius: 99px;
    overflow: hidden;
  }
  .weekly-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1);
    max-width: 100%;
  }

  /* ── SET COUNTER BADGE ── */
  .set-counter {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: #000;
    font-family: 'DM Mono', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 99px;
    padding: 2px 5px;
    pointer-events: none;
    z-index: 10;
    line-height: 1.4;
    white-space: nowrap;
  }

  /* ── SWIPE-TO-DELETE ── */
  .workout-entry-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .swipe-delete-bg {
    position: absolute;
    inset: 0;
    background: rgba(255,68,68,0.15);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 20px;
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
    color: var(--red);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-left: 4px solid var(--accent2);
    border-radius: 10px;
    pointer-events: none;
  }
  .workout-entry {
    margin-bottom: 0;
    border-radius: 10px;
    position: relative;
    touch-action: pan-y;
    transition: transform 0.15s ease;
    will-change: transform;
  }

  /* ── LAST SESSION INFO BAR ── */
  .last-session-bar {
    display: none;
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 0.05em;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
  }
  .last-session-bar.visible { display: block; }
  .last-session-bar strong { color: var(--accent); }

  /* ── HISTORY SORT/FILTER BAR ── */
  .history-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
  .history-controls select {
    margin-bottom: 0;
    flex: 1;
    min-width: 110px;
    font-size: 0.78rem;
    padding: 9px 10px;
  }

  /* ── STRENGTH CHART ── */
  .strength-exercise-picker {
    margin-bottom: 14px;
  }
  .strength-exercise-picker select {
    margin-bottom: 0;
    font-size: 0.82rem;
  }


  /* ── CUSTOM CONFIRM DIALOG ── */
  .confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,5,5,0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .confirm-overlay.active { opacity: 1; pointer-events: auto; }
  .confirm-box {
    background: rgba(18,18,18,0.97);
    border: 1px solid rgba(255,255,255,0.12);
    border-top-color: rgba(255,255,255,0.22);
    border-radius: 16px;
    padding: 28px 24px 20px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
    transform: scale(0.95) translateY(8px);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  }
  .confirm-overlay.active .confirm-box { transform: scale(1) translateY(0); }
  .confirm-icon { font-size: 2rem; margin-bottom: 12px; line-height: 1; }
  .confirm-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.25rem;
    letter-spacing: 0.07em;
    color: var(--text);
    margin-bottom: 8px;
  }
  .confirm-body {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 22px;
    font-family: 'DM Sans', sans-serif;
  }
  .confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .confirm-btn {
    padding: 12px;
    border-radius: 10px;
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
  }
  .confirm-btn-cancel {
    background: rgba(255,255,255,0.06);
    color: var(--muted);
    border: 1px solid var(--glass-border);
  }
  .confirm-btn-cancel:hover { background: rgba(255,255,255,0.1); color: var(--text); }
  .confirm-btn-ok { background: var(--accent); color: #000; font-weight: 600; }
  .confirm-btn-ok:hover { filter: brightness(1.1); transform: translateY(-1px); }
  .confirm-btn-ok:active { transform: translateY(0); }
  .confirm-btn-ok.danger {
    background: rgba(255,68,68,0.12);
    color: #ff7777;
    border: 1px solid rgba(255,68,68,0.3);
  }
  .confirm-btn-ok.danger:hover { background: rgba(255,68,68,0.25); }

  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,5,5,0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
  }
  .modal-overlay.active { opacity: 1; pointer-events: auto; }

  .modal {
    background: rgba(18,18,18,0.95);
    border: 1px solid rgba(255,255,255,0.12);
    border-top-color: rgba(255,255,255,0.22);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior: contain; /* Prevents background scrolling */
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    transform: translateY(16px);
    transition: transform 0.3s cubic-bezier(0.25,1,0.5,1);
  }
  .modal-overlay.active .modal { transform: translateY(0); }

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

  .modal-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    color: var(--accent);
  }

  .modal-close {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--muted);
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
  }
  .modal-close:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }

  /* ── PR MUSCLE GROUP TABS ── */
  .muscle-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
  }
  .muscle-tab-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    color: var(--muted);
    border-radius: 20px;
    padding: 5px 14px;
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
  }
  .muscle-tab-btn.active {
    background: rgba(232,255,71,0.12);
    border-color: rgba(232,255,71,0.4);
    color: var(--accent);
  }
  .muscle-tab-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.06); }

  /* MAGIC WAND OVERLOAD BUTTON */
  .weight-wrapper {
    position: relative;
    display: flex;
    align-items: center;
  }

  .predict-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    padding: 0;
  }

  .predict-btn:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
  }

  /* Indent text so it doesn't overlap the wand */
  .weight-wrapper input {
    padding-left: 28px !important;
  }

  .delta-box {
    position: absolute;
    bottom: -18px;
    left: 4px;
    font-size: 0.6rem;
    font-family: 'DM Mono', monospace;
    font-weight: bold;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .delta-pos { color: var(--green); }
  .delta-neg { color: var(--red); opacity: 0.8; }
  .delta-neutral { color: var(--muted); }

  /* Ensure wrappers have space for the labels below */
  .exercise-item > div, .exercise-item > input {
    position: relative;
    margin-bottom: 12px !important; 
  }

  /* =========================================
   v4.0 UI POLISH & MICRO-INTERACTIONS
   ========================================= */

/* 2. Tactile Micro-Interactions for Cards and Buttons */
.workout-entry, .btn {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, filter 0.2s;
}
.workout-entry:hover, .btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}
.workout-entry:active, .btn:active {
  transform: translateY(1px) scale(0.98); /* The "Squish" effect */
  filter: brightness(0.95);
}

/* 3. Skeleton Loader Animations */
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.skeleton {
  background: rgba(255, 255, 255, 0.03);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.05) 20%, rgba(255, 255, 255, 0) 40%);
  background-size: 1000px 100%;
  background-repeat: no-repeat;
  animation: shimmer 2s infinite linear;
  border-radius: 12px;
}
.skeleton-card {
  height: 90px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(10px);
}

/* =========================================
   PREMIUM AUTH OVERLAY STYLES
   ========================================= */

/* The Modal Container */
.auth-modal {
  max-width: 380px;
  width: 90%;
  text-align: center;
  padding: 40px 30px;
  background: rgba(20, 20, 20, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  
  /* Entrance Animation */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  animation: modalEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalEnter {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Floating Label Inputs */
.input-group {
  position: relative;
  margin-bottom: 24px;
  text-align: left;
}

.input-group input {
  width: 100%;
  
  /* 👉 ADD THIS: Fixes the horizontal centering */
  box-sizing: border-box; 
  
  /* 👉 TWEAK THIS: Pushes the text up a bit so it doesn't hit the bottom */
  padding: 22px 16px 10px 16px; 
  height: 56px; /* Locks the height for perfect proportions */
  
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  transition: all 0.3s ease;
  margin-bottom: 0; 
}

.input-group label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The Magic: When input is focused OR has text in it */
.input-group input:focus,
.input-group input:not(:placeholder-shown) {
  border-color: var(--accent, #4ade80); /* Fallback to green if accent isn't defined */
  box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.1); /* Subtle outer glow */
  background: rgba(0, 0, 0, 0.6);
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
  top: 12px;
  font-size: 0.7rem;
  color: var(--accent, #4ade80);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Elevated Primary Button */
.btn-auth {
  width: 100%;
  
  /* 👉 ADD THIS: Keeps the button perfectly centered */
  box-sizing: border-box; 
  
  padding: 14px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.btn-auth-primary {
  background: linear-gradient(135deg, var(--accent, #4ade80) 0%, #22c55e 100%);
  color: #000;
  border: none;
  box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
}

.btn-auth-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(74, 222, 128, 0.4);
}

/* =========================================
   BOTTOM-STACKING PREMIUM TOASTS
   ========================================= */
#toastContainer {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse; /* Stacks new toasts on top of old ones */
  align-items: center;
  gap: 10px;
  pointer-events: none;
  transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1); /* Smooth lift */
}

/* Your custom lifted state */
#toastContainer.lifted {
  bottom: 90px; /* Adjust this value based on your FAB height */
}

.toast-pill {
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  
  /* Bottom-up entrance animation */
  animation: slideUpFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-pill.fade-out {
  animation: fadeOutDown 0.3s ease forwards;
}

@keyframes fadeOutDown {
  to { opacity: 0; transform: translateY(10px) scale(0.95); }
}

/* Wrap your main app content (everything except modals/nav) in a div with id="mainAppContent" */
#mainAppContent {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
  transform-origin: center top;
}

/* We will apply this class via JS when a modal opens */
.app-background-scaled {
  transform: scale(0.96) translateY(10px);
  filter: blur(4px) brightness(0.7);
  border-radius: 20px; /* Gives it that floating screen look */
  overflow: hidden;
}

/* Password Toggle Icon */
.password-toggle-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--muted);
  z-index: 5;
  user-select: none; /* Prevents double-click highlighting */
  transition: opacity 0.2s;
}

.password-toggle-icon:hover {
  opacity: 0.7;
}

/* Auth View Transitions */
.fade-view {
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(10px);
}

.fade-view.active-view {
  opacity: 1;
  transform: translateX(0);
}

/* Keeps the logo and tagline stacked together on the left */
.header-brand-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

/* The Tagline Styling */
.header-tagline {
  font-family: 'DM Mono', monospace; /* Or whichever secondary font you are using */
  font-size: 0.7rem;                 /* Keep it small so it doesn't fight the logo */
  color: #888888;                    /* A muted grey */
  letter-spacing: 0.15em;            /* Spaced out for a modern tech feel */
  text-transform: uppercase;
  margin-top: -2px;                  /* Pulls it up tight against the bottom of CTRLSET */
}