:root {
      /* -- EXPLICIT DEFINITIONS (To guarantee sizing works) -- */
      /* Typography Scale */
      --scale-000: 0.75rem;  /* 12px */
      --scale-00:  0.875rem; /* 14px */
      --scale-0:   1rem;     /* 16px */
      --scale-1:   1.125rem; /* 18px */
      --scale-2:   1.25rem;  /* 20px */
      --scale-3:   1.5rem;   /* 24px */
      --scale-4:   1.875rem; /* 30px */
      --scale-5:   2.25rem;  /* 36px */
      --scale-6:   3rem;     /* 48px */
      --scale-7:   3.75rem;  /* 60px */

      /* Spacing Scale */
      --size-1: 0.25rem;
      --size-2: 0.5rem;
      --size-3: 0.75rem;
      --size-4: 1rem;
      --size-5: 1.25rem;
      --size-6: 1.5rem;
      --size-8: 2rem;
      --size-10: 2.5rem;
      --size-12: 3rem;
      --size-16: 4rem;
      --size-20: 5rem;
      --size-24: 6rem;
      --size-32: 8rem;

      /* -- TYPOGRAPHY FONT -- */
      --font-sans: 'Outfit', sans-serif;

      /* -- BRAND COLORS -- */
      --brand-blue: #7BAAC9;
      --brand-blue-dark: #6290ad;
      --brand-green: #93B595;
      --brand-green-dark: #7a9c7c;
      --brand-red: #e05263; /* Added for Errors */

      /* -- UI COLORS -- */
      --bg-gradient: linear-gradient(135deg, #f3f6f8 0%, #eef5f3 100%);
      --surface: #ffffff;
      --text-main: var(--color-grey-900);
      --text-muted: var(--color-grey-500);

      /* -- SHAPES & SHADOWS -- */
      --radius-card: 24px;
      --radius-btn: 14px;
      --shadow-card: 0 10px 40px -10px rgba(0, 0, 0, 0.06);
      --shadow-float: 0 24px 48px -12px rgba(0, 0, 0, 0.12);

      /* -- SHOELACE OVERRIDES -- */
      /* This is the correct way to resize Shoelace components */
      --sl-input-height-medium: 48px;
      --sl-input-height-small: 32px;
      --sl-font-sans: var(--font-sans);
      --sl-button-font-size-medium: var(--scale-0);
      --sl-input-border-radius-medium: var(--radius-btn);

      /* Fallback colors if Pollen fails */
      --color-grey-50: #f9fafb;
      --color-grey-100: #f3f4f6;
      --color-grey-200: #e5e7eb;
      --color-grey-300: #d1d5db;
      --color-grey-500: #6b7280;
      --color-grey-800: #1f2937;
      --color-grey-900: #111827;
    }

    body {
      font-family: var(--font-sans);
      background: var(--bg-gradient);
      color: var(--text-main);
      margin: 0;
      padding: 0;
      min-height: 100vh;
      -webkit-font-smoothing: antialiased;
    }

    h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--text-main); line-height: 1.2; }
    p { margin: 0; color: var(--text-muted); line-height: 1.6; }

    /* --- Core Components --- */

    .card {
      background: var(--surface);
      border-radius: var(--radius-card);
      padding: var(--size-8);
      box-shadow: var(--shadow-card);
      border: 1px solid rgba(255,255,255,0.6);
    }

    /* HEADER COMPONENT (UPDATED) */
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      /* Compact Padding */
      padding: var(--size-2) var(--size-4);
      width: 100%;
      /* Brand Blue Background */
      background: var(--brand-blue);
      /* Floating Pill Style */
      border-radius: var(--radius-btn);
      box-shadow: 0 4px 20px rgba(123, 170, 201, 0.4);
      box-sizing: border-box;
    }

    .header-left {
      display: flex;
      align-items: center;
      gap: var(--size-6);
    }

    .brand {
      display: flex;
      align-items: center;
      gap: var(--size-3);
      font-size: var(--scale-2); /* Smaller Font for Header */
      font-weight: 700;
      color: white; /* White Text */
      text-decoration: none;
      letter-spacing: -0.5px;
    }

    .brand-icon {
      width: 32px; /* Smaller Icon */
      height: 32px;
      border-radius: 8px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
      object-fit: contain;
      background: white;
      padding: 4px;
    }

    /* Desktop Navigation Links */
    .header-nav {
      display: none; /* Hidden on mobile */
      gap: var(--size-4);
    }
    @media (min-width: 768px) {
      .header-nav { display: flex; }
    }

    .nav-link {
      color: rgba(255,255,255,0.9);
      text-decoration: none;
      font-weight: 500;
      font-size: var(--scale-00);
      transition: all 0.2s;
      padding: var(--size-1) var(--size-2);
      border-radius: 6px;
    }
    .nav-link:hover, .nav-link.active {
      color: white;
      background: rgba(255,255,255,0.2);
    }

    .user-controls {
      display: flex;
      align-items: center;
      gap: var(--size-3);
    }

    .avatar {
      width: 36px; /* Smaller Avatar */
      height: 36px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid rgba(255,255,255,0.9);
      box-shadow: 0 2px 8px rgba(0,0,0,0.15);
      cursor: pointer;
      transition: transform 0.2s ease;
    }
    .avatar:hover {
      transform: scale(1.05);
    }

    .initials-avatar {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background-color: var(--brand-blue-dark);
      color: white;
      font-weight: 600;
      font-size: var(--scale-00);
      border: 2px solid rgba(255,255,255,0.9);
      box-shadow: 0 2px 8px rgba(0,0,0,0.15);
      cursor: pointer;
      transition: transform 0.2s ease;
      text-transform: uppercase;
    }
    .initials-avatar:hover {
      transform: scale(1.05);
    }

    /* Responsive Utilities */
    .mobile-only { display: block; }
    @media (min-width: 768px) { .mobile-only { display: none; } }

    /* Dropdown Styles to match System */
    sl-menu-item { display: block; }
    sl-menu-item::part(base) {
      font-family: var(--font-sans);
      color: var(--text-main);
      padding: var(--size-2) var(--size-3);
      transition: background-color 0.1s ease, color 0.1s ease;
    }
    sl-menu-item::part(base):hover,
    sl-menu-item:focus-visible::part(base) {
      background-color: var(--color-grey-50);
      color: var(--brand-blue);
    }
    sl-menu-item::part(label) {
      font-size: var(--scale-00);
      font-weight: 500;
    }
    sl-menu-item i[slot="prefix"] {
      color: var(--text-muted);
      width: 16px;
      height: 16px;
      margin-right: var(--size-2);
      transition: color 0.1s ease;
    }
    sl-menu-item:hover i[slot="prefix"],
    sl-menu-item:focus-visible i[slot="prefix"] {
      color: var(--brand-blue);
    }

    /* Hero Buttons */
    .hero-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: var(--size-3);
      width: 100%;
      padding: var(--size-4) var(--size-6); /* Compact padding for mobile */
      border: none;
      border-radius: var(--radius-btn);
      color: white;
      font-size: var(--scale-0); /* Smaller font for mobile */
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
      text-transform: uppercase;
      letter-spacing: 1px;
      text-decoration: none;
      font-family: var(--font-sans);
      box-sizing: border-box;
    }
    @media (min-width: 768px) {
      .hero-btn { 
        padding: var(--size-6) var(--size-8);
        font-size: var(--scale-1);
        gap: var(--size-4);
      }
    }
    .hero-btn i { width: 24px; height: 24px; }
    @media (min-width: 768px) {
      .hero-btn i { width: 28px; height: 28px; }
    }
    .hero-btn.blue { background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark)); }
    .hero-btn.green { background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark)); }
    .hero-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(0,0,0,0.12); }
    .hero-btn:active { transform: translateY(-1px); }

    /* Calendar Grid */
    .calendar-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: var(--size-2); /* Smaller gap for mobile */
      text-align: center;
      width: 100%;
      box-sizing: border-box;
    }
    @media (min-width: 768px) {
      .calendar-grid { gap: var(--size-3); }
    }
    
    .calendar-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: var(--size-4);
      padding: 0 var(--size-1);
    }
    .calendar-header h3 {
      font-size: var(--scale-1); /* Slightly smaller header for mobile */
      margin: 0;
      font-weight: 600;
    }
    @media (min-width: 768px) {
      .calendar-header h3 { font-size: var(--scale-2); }
    }

    .day-label {
      font-size: var(--scale-000); /* Smaller labels */
      font-weight: 600;
      color: var(--text-muted);
      margin-bottom: var(--size-2);
    }
    @media (min-width: 768px) {
      .day-label { font-size: var(--scale-00); margin-bottom: var(--size-3); }
    }

    .day {
      aspect-ratio: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 8px; /* Slightly smaller radius */
      font-size: var(--scale-00); /* Smaller font */
      background: var(--color-grey-50);
      color: var(--text-main);
      transition: 0.2s;
      min-width: 0; /* Allow shrinking */
    }
    @media (min-width: 768px) {
      .day { border-radius: 10px; font-size: var(--scale-0); }
    }
    .day.empty {
      background: transparent;
      color: transparent;
    }
    .day.active-blue {
      background: var(--brand-blue);
      color: white;
      font-weight: 600;
      box-shadow: 0 4px 12px rgba(123, 170, 201, 0.3);
    }
    .day.active-green {
      background: var(--brand-green);
      color: white;
      font-weight: 600;
      box-shadow: 0 4px 12px rgba(147, 181, 149, 0.3);
    }
    .day.is-today {
      outline: 2px solid var(--brand-blue);
      outline-offset: -2px;
      font-weight: 700;
    }

    /* Session List */
    .session-item {
      background: var(--color-grey-50);
      border-radius: var(--radius-btn);
      padding: var(--size-6);
    }
    .set-row {
      display: grid;
      grid-template-columns: 1fr 2fr 1fr;
      padding: var(--size-3) 0;
      border-bottom: 1px solid var(--color-grey-200);
      font-size: var(--scale-0);
      align-items: center;
    }
    .set-row:last-child { border-bottom: none; }
    .set-label { color: var(--brand-blue); font-weight: 600; }
    .set-detail { color: var(--text-main); }

    /* Shoelace Overrides */
    sl-dialog::part(panel) { border-radius: var(--radius-card); box-shadow: var(--shadow-float); }
    sl-button[variant="primary"]::part(base) { background: var(--brand-blue); border-color: var(--brand-blue); color: white; }
    sl-button[variant="success"]::part(base) { background: var(--brand-green); border-color: var(--brand-green); color: white; }
    sl-button[variant="danger"]::part(base) { background: var(--brand-red); border-color: var(--brand-red); color: white; }
    sl-input::part(base) { background: var(--color-grey-50); border-color: transparent; }
    sl-input:focus-within::part(base) { background: white; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(123, 170, 201, 0.2); }
    
    /* --- Tom Select Overrides (Premium Aesthetic) --- */
    body .ts-wrapper .ts-control {
      border: 1px solid var(--color-grey-300) !important; /* Visible Border */
      background-color: white !important; /* distinct background */
      border-radius: var(--radius-btn) !important;
      padding: 10px 16px !important;
      font-family: var(--font-sans) !important;
      font-size: var(--scale-0) !important;
      color: var(--text-main) !important;
      min-height: 48px;
      display: flex !important;
      align-items: center !important;
      transition: all 0.2s ease !important;
      box-shadow: 0 2px 6px rgba(0,0,0,0.02) !important;
    }

    body .ts-wrapper.focus .ts-control {
      background-color: white !important;
      box-shadow: 0 0 0 3px rgba(123, 170, 201, 0.2) !important;
      border: 1px solid var(--brand-blue) !important;
    }

    body .ts-dropdown {
      border-radius: var(--radius-card) !important;
      box-shadow: var(--shadow-float) !important;
      border: 1px solid var(--color-grey-100) !important;
      margin-top: 10px !important;
      padding: 8px !important;
      background: white !important;
      font-family: var(--font-sans) !important;
    }

    body .ts-dropdown .option {
      padding: 10px 14px !important;
      border-radius: 12px !important;
      font-size: var(--scale-00) !important;
      transition: all 0.1s ease !important;
    }

    body .ts-dropdown .option.active, 
    body .ts-dropdown .option:hover {
      background-color: var(--color-grey-50) !important;
      color: var(--brand-blue) !important;
    }

    /* Tom Select Tags (Multi-select) */
    body .ts-control .item {
      background: var(--brand-blue) !important;
      color: white !important;
      border-radius: 8px !important;
      padding: 2px 10px !important;
      font-size: var(--scale-00) !important;
      font-weight: 600 !important;
      margin: 2px !important;
      border: none !important;
      display: inline-flex !important;
      align-items: center !important;
    }
    body .ts-control .item .remove {
      color: white !important;
      margin-left: 6px !important;
      opacity: 0.7 !important;
      text-decoration: none !important;
    }
    body .ts-control .item .remove:hover {
      opacity: 1 !important;
    }

    

    /* Button Base Style */
    sl-button::part(base) {
      font-family: var(--font-sans);
      font-weight: 500;
    }
    sl-button[size="small"]::part(base) { height: 32px; }

    /* Validation Errors */
    .input-validation-error {
      border: 1px solid var(--brand-red) !important;
      background-color: #fff5f5 !important;
    }
    .field-validation-error {
      color: var(--brand-red);
      font-size: var(--scale-000);
      margin-top: 4px;
      display: block;
      font-weight: 500;
    }
    
/* --- UTILITIES --- */
.flex-header {
  display: flex;
  flex-direction: column;
  gap: var(--size-4);
  margin-bottom: var(--size-6);
}
@media (min-width: 768px) {
  .flex-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.grid-3-col {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: var(--size-2);
  align-items: center;
}
@media (min-width: 768px) {
  .grid-3-col {
    grid-template-columns: 40px 1fr auto;
    gap: var(--size-4);
  }
}

/* --- APP SHELL LAYOUT --- */
.app-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--size-4);
  /* Single Column */
  display: grid;
  gap: var(--size-8);
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .app-container {
    padding: var(--size-8);
  }
}

/* --- WORKOUT PILLS (Exercise Plans) --- */
.workout-tag-native {
    display: inline-flex;
    align-items: center;
    background-color: var(--color-grey-100);
    color: var(--text-main);
    padding: 10px 24px;
    border-radius: 100px;
    font-size: var(--scale-0);
    font-weight: 500;
    cursor: grab;
    user-select: none;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin: 4px 0;
}
.workout-tag-native:hover {
    background-color: var(--color-grey-200);
}
.workout-tag-native.selected {
    border-color: var(--brand-blue);
    background-color: white;
    box-shadow: 0 0 0 2px rgba(123, 170, 201, 0.2);
}
.delete-workout-btn {
    margin-left: 12px;
}
.sortable-ghost {
    opacity: 0.15 !important;
    background-color: var(--brand-blue) !important;
    border: 2px dashed var(--brand-blue-dark) !important;
}
.sortable-chosen {
    cursor: grabbing;
    background-color: var(--color-grey-200) !important;
    transition: none !important;
}
.sortable-drag {
    opacity: 0.95 !important;
    background-color: white !important;
    box-shadow: var(--shadow-float) !important;
    cursor: grabbing;
    z-index: 9999 !important;
    transition: none !important;
    pointer-events: none;
}

/* --- ROTATION EDITING --- */
@media (min-width: 768px) {
    .edit-rotation-btn {
        opacity: 0;
        transition: opacity 0.2s;
    }
    .rotation-view-mode:hover .edit-rotation-btn {
        opacity: 1;
    }
}

/* --- ANIMATIONS --- */
@keyframes success-highlight {
    0% { background-color: rgba(147, 181, 149, 0); }
    20% { background-color: rgba(147, 181, 149, 0.3); }
    100% { background-color: rgba(147, 181, 149, 0); }
}

.animate-success {
    animation: success-highlight 1.5s ease-out;
    border-radius: 8px;
}
