/* ============================================
   Import Theme (Color System)
   ============================================ */
@import url('theme.css');

/* App height: 100dvh in Safari browser; 100vh in iOS standalone via pwa-app-shell.js */
:root {
  --app-height: 100dvh;
  --tab-bar-content-clearance: 5.5rem;
  --tab-bar-scroll-pad: 8rem;
  --tab-bar-inner-height: 3.5rem;
}

/* Global Base Styles */
* {
  box-sizing: border-box;
}

/* FAB: always on top in all views */
#tool-fab {
  z-index: 100 !important;
}

/* Leaflet default: padding: 1px on wrapper shows as a halo on custom-styled popups */
.leaflet-popup-content-wrapper {
  padding: 0 !important;
}

/* Main content containers: top padding + consistent bottom space (above tab bar) */
body > .container,
body > main.container,
body > .container.px-4,
.pois-container {
  padding-top: 0 !important;
  padding-bottom: 8rem;
}

body {
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
  padding-bottom: 10rem !important;
}

html {
  min-height: 100%;
}

@media (max-width: 768px) {
  html {
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    overflow-x: hidden;
    background-color: var(--neutral-surface);
  }

  html.dark {
    background-color: var(--gray-800);
  }

  body {
    margin: 0;
    padding-top: 0;
    padding-bottom: var(--tab-bar-content-clearance) !important;
    overflow-x: hidden;
    min-height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
  }

  body > header {
    margin-top: 0 !important;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px)) !important;
    position: relative;
    z-index: 50;
  }

  body > .container,
  body > main.container {
    flex: 1;
    min-height: 0;
  }

  /* Tool pages — relative layout so nested containers scroll correctly */
  body > .container.px-4,
  body > .famcal-page.container,
  body > main.container,
  body > .pois-container {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow-x: hidden;
    padding-top: 0 !important;
    padding-bottom: var(--tab-bar-scroll-pad) !important;
  }

  body.todo-progress-active {
    padding-bottom: 0 !important;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  body.todo-progress-active > .container.px-4 {
    overflow: hidden !important;
    overflow-y: hidden !important;
    padding-bottom: 0 !important;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  body.todo-progress-active #todo-app,
  body.todo-progress-active #todo-progress-tab,
  body.todo-progress-active .todo-progress-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Dashboard home / settings / activity */
  body > #root-views {
    position: relative !important;
    flex: 1;
    min-height: 0;
    width: 100% !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: var(--tab-bar-content-clearance);
  }

  body > #root-views > .root-view-active {
    flex: 1 1 auto;
    min-height: 0;
  }

  #root-home-view.root-view-active,
  #root-focus-view.root-view-active {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #root-tools-view.root-view-active,
  #root-settings-view.root-view-active {
    overflow: hidden;
  }

  #root-views .container.px-4 {
    position: relative !important;
    top: auto !important;
    min-height: 0 !important;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0 !important;
  }

  body > main,
  .root-view,
  .root-view-active,
  .pois-container {
    padding-bottom: var(--tab-bar-content-clearance);
  }

  body > main {
    background-color: inherit !important;
  }

  /*
   * iOS standalone app shell: CSS grid (row 1=header, 2=scroll, 3=tab bar).
   * Grid rows ignore DOM order — #mobile-footer is included before <header> in PHP.
   */
  html.pwa-app-shell {
    height: 100vh;
    overflow: hidden;
    background-color: var(--neutral-surface);
  }

  html.pwa-app-shell.dark {
    background-color: var(--gray-800);
  }

  html.pwa-app-shell body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    padding-bottom: 0 !important;
    overflow: hidden;
    overscroll-behavior: none;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 100%;
  }

  html.pwa-app-shell body > header {
    grid-row: 1;
    grid-column: 1;
    flex-shrink: 0;
  }

  html.pwa-app-shell body > .container.px-4,
  html.pwa-app-shell body > .famcal-page.container,
  html.pwa-app-shell body > main.container,
  html.pwa-app-shell body > .pois-container {
    grid-row: 2;
    grid-column: 1;
    min-height: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1.5rem !important;
  }

  html.pwa-app-shell body.todo-progress-active > .container.px-4 {
    overflow: hidden !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: auto;
    padding-bottom: 0 !important;
    display: flex;
    flex-direction: column;
  }

  html.pwa-app-shell body > #root-views {
    grid-row: 2;
    grid-column: 1;
    min-height: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0 !important;
  }

  html.pwa-app-shell body > main,
  html.pwa-app-shell .root-view,
  html.pwa-app-shell .root-view-active {
    padding-bottom: 0;
  }

  html.pwa-app-shell body > #mobile-footer {
    grid-row: 3;
    grid-column: 1;
    position: static !important;
    flex-shrink: 0;
    width: 100%;
    margin-top: 0 !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    z-index: 100;
  }

  html.pwa-app-shell #mobile-footer-items {
    min-height: var(--tab-bar-inner-height);
    padding-top: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Main: never use own background (override any min-width rule); inherit from html/body in all viewports */
body > main {
  background-color: inherit !important;
}

/* ============================================
   Infocard — global card style for tools
   ============================================
   Use class="infocard" for content cards. No border; spacing via gap on parent.
   Light: white bg, subtle shadow. Dark: gray-800 bg, stronger shadow.
*/
.infocard {
  border-radius: 0.5rem;
  padding: 0.75rem;
  background-color: var(--neutral-surface);
  color: var(--text-main);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

html.dark .infocard,
.dark .infocard {
  background-color: var(--gray-800);
  color: var(--text-main);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Header Styles
   ============================================ */

header {
  z-index: 3;
}

/* Optimize font rendering */
html, body { 
  height: 100%; 
  font-family: 'Inter', sans-serif;
}

@media (max-width: 768px) {
  html, body {
    padding-bottom: 0;
  }
}

/* ============================================
   Standardized CTA (Call To Action) Classes
   ============================================ */

/* Primary CTA - Pill style, theme color (picked) bg, neutral-primary text/icon */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px; /* Full pill */
  background-color: var(--orange) !important;
  color: var(--neutral-primary) !important;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

.btn-primary:hover {
  background-color: var(--orange-dark) !important;
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary.btn-primary--full {
  width: 100%;
}

.btn-primary.btn-primary--swoosh {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn-primary.btn-primary--swoosh::before {
  content: '';
  position: absolute;
  top: -10%;
  left: 0;
  width: 45%;
  height: 120%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.12) 30%,
    rgba(255, 255, 255, 0.42) 50%,
    rgba(255, 255, 255, 0.12) 70%,
    transparent 100%
  );
  transform: translateX(-160%) skewX(-18deg);
  animation: btn-primary-swoosh 2.4s ease-in-out infinite;
  pointer-events: none;
}

.btn-primary.btn-primary--swoosh > * {
  position: relative;
  z-index: 1;
}

@keyframes btn-primary-swoosh {
  0% { transform: translateX(-160%) skewX(-18deg); }
  100% { transform: translateX(380%) skewX(-18deg); }
}

.btn-primary svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--neutral-primary) !important;
  stroke: var(--neutral-primary) !important;
}

/* Secondary CTA - No bg, no pill, same font style and icon, dark gray text */
.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  background-color: transparent !important;
  color: var(--text-dim) !important; /* Dark gray text */
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

.btn-secondary:hover {
  opacity: 0.8;
}

.btn-secondary svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--text-dim) !important; /* Dark gray icon */
}

/* Secondary danger — red enforced on secondary CTA (delete, clear, etc.) */
.btn-secondary.btn-danger,
.btn-secondary.btn-danger span {
  color: var(--status-red) !important;
}

.btn-secondary.btn-danger svg {
  color: var(--status-red) !important;
  stroke: var(--status-red) !important;
}

/* Icon CTA - Icon only, no text */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; /* 24px icon + 8px padding on each side */
  height: 40px;
  padding: 8px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.25rem;
  color: var(--text-main);
}

.btn-icon:hover {
  background-color: var(--orange-light);
}

a.btn-icon {
  text-decoration: none;
}

.btn-icon svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.btn-icon.btn-icon-flip svg {
  transform: scaleX(-1);
}

.btn-icon img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Icon CTA with circle background */
.btn-icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-circle svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Icon circle variants */
.btn-icon-circle-orange {
  background-color: var(--orange) !important;
  color: var(--neutral-primary) !important;
}

.btn-icon-circle-orange svg {
  color: var(--neutral-primary) !important;
  stroke: var(--neutral-primary) !important;
}

.btn-icon-circle.btn-icon-circle--active {
  background-color: var(--action-blue) !important;
  color: var(--neutral-primary) !important;
}

.btn-icon-circle img {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.btn-icon-circle.btn-icon-circle--active img {
  filter: brightness(0) invert(1);
  opacity: 1;
}

.btn-icon-circle-white {
  background-color: var(--bg) !important;
  color: var(--text-main) !important;
}

.btn-icon-circle-shadow {
  box-shadow: var(--shadow-sm);
}

/* Allow btn-icon to work with absolute positioning */
.btn-icon.absolute {
  position: absolute;
}

/* Tool name styling */
.tool-name {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  font-size: var(--fs-xs); /* 14px */
  color: var(--header-text);
}

/* Theme toggle button */
#theme-toggle {
  color: var(--header-text);
}

#theme-toggle:hover {
  background-color: var(--border);
  opacity: 0.8;
}

/* Break header out of body padding constraints - full width, top-left aligned */
header {
  width: 100vw;
  position: relative;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  margin-top: -3.5em;
  margin-bottom: 0;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* On pages without body padding, reset the negative top margin */
body:not([style*="padding"]) header,
body[style*="padding: 0"] header {
  margin-top: 0;
}

/* Mobile + viewport-fit=cover: header below island (padding-top set above) */
@media (max-width: 768px) {
  header {
    margin-top: 0 !important;
  }
}

/* Prevent horizontal scroll */
html {
  overflow-x: hidden;
}

/* Hide vertical scrollbar while keeping scroll functionality - applies to all elements */
* {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

*::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Specific rules for html and body */
html {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

html::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

body {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

body::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Hide scrollbars in overlays and scrollable containers */
.overlay,
.overlay-content,
.overlay-backdrop,
[class*="overflow"],
[class*="scroll"] {
  scrollbar-width: none !important; /* Firefox */
  -ms-overflow-style: none !important; /* IE and Edge */
}

.overlay::-webkit-scrollbar,
.overlay-content::-webkit-scrollbar,
.overlay-backdrop::-webkit-scrollbar,
[class*="overflow"]::-webkit-scrollbar,
[class*="scroll"]::-webkit-scrollbar {
  display: none !important; /* Chrome, Safari, Opera */
}

/* ============================================
   Reusable Overlay System
   ============================================ */

/* Overlay backdrop - 40% black overlay */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-backdrop, rgba(0, 0, 0, 0.4));
  z-index: 1;
}

/* Overlay content container - base styles */
.overlay-content {
  position: fixed;
  z-index: 2;
  background-color: var(--bg);
  color: var(--text-main);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

/* Desktop: centered overlay */
.overlay-content {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
}

/* Light mode overlay content */
[data-theme="light"] .overlay-content {
  background-color: var(--overlay-bg);
}

/* Dark mode overlay content */
.dark .overlay-content {
  background-color: var(--overlay-bg);
}

/* Mobile: bottom drawer */
@media (max-width: 768px) {
  .overlay-content {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 1rem 1rem 0 0;
  }
  
  /* Make the Add Checklist overlay scrollable if its content exceeds the viewport */
  #checklist-edit-overlay .overlay-content {
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* Animation for opening */
  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
  
  /* Animation for closing */
  @keyframes slideDown {
    from {
      transform: translateY(0);
    }
    to {
      transform: translateY(100%);
    }
  }
  
  /* Apply animation when overlay is open */
  .overlay:not(.hidden) .overlay-content {
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
  
  /* Apply animation when closing */
  .overlay.closing .overlay-content {
    animation: slideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
}

/* Overlay container */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
}

.overlay.hidden {
  display: none;
}

/* ============================================
   Common Utilities
   ============================================ */

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* ============================================
   Toolbelt tab video + home grid cards
   ============================================ */

/* Toolbelt video icon - single circle, no double layer with placeholder; bg image at 50% opacity */
.toolbelt-tab-video-wrap {
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.toolbelt-tab-video-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url('/toolbelt.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}

/* Tab bar center slot: one clean circle, avoid video + placeholder stacking or overflow */
#mobile-footer .toolbelt-tab-video-wrap {
  width: 56px !important;
  height: 56px !important;
  min-width: 56px;
  min-height: 56px;
  max-width: 56px;
  max-height: 56px;
  overflow: hidden !important;
  border-radius: 50%;
  isolation: isolate;
  contain: layout style paint;
}

#mobile-footer .toolbelt-tab-video-wrap video {
  position: absolute !important;
  inset: -1% !important;
  width: 102% !important;
  height: 102% !important;
  object-fit: cover !important;
  border-radius: 50%;
}

/* When video is present and loaded, hide placeholder so we don’t see two layers */
#mobile-footer .toolbelt-tab-video-wrap:has(video) {
  background-color: black;
}

/* Logo centered in the middle of the toolbelt video icon */
#mobile-footer .toolbelt-tab-video-wrap .toolbelt-tab-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  object-fit: contain;
  pointer-events: none;
  filter: none !important;
}

/* Center slot: single aligned circle */
#mobile-footer .mobile-footer-item:has(.toolbelt-tab-video-wrap) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

/* Home / launcher tool cards */
.toolbelt-tool-card {
  position: relative;
  background-color: white;
  border-radius: 0.5rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 85px;
  min-width: 95px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow: visible;
}

/* Dark mode: dark background for toolbelt cards */
.dark .toolbelt-tool-card {
  background-color: var(--card-bg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

.toolbelt-tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dark .toolbelt-tool-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  background-color: var(--card-bg-hover);
}


.toolbelt-tool-card img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  margin-bottom: 0.375rem;
}

/* SVG icon container - ensure proper sizing */
.toolbelt-icon-container {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SVG icons should fill the container */
.toolbelt-icon-container svg,
.toolbelt-icon-container .toolbelt-icon-mask,
#tools-grid .toolbelt-icon-mask {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 2rem;
  max-height: 2rem;
}

#tools-grid .toolbelt-icon-mask {
  max-width: 2.25rem;
  max-height: 2.25rem;
}

.toolbelt-tool-card h3 {
  color: var(--gray-500);
  font-weight: 600; /* font-semibold */
  text-align: center;
  font-size: var(--fs-cap); /* 10px */
  text-transform: uppercase;
  letter-spacing: 0.05em; /* tracking-wide */
}

.dark .toolbelt-tool-card h3 {
  color: var(--gray-400);
}

/* ============================================
   Mobile Footer/Toolbar System
   ============================================ */

/* Tab Bar: mobile = bottom bar, desktop = left sidebar (same #mobile-footer element) */
#mobile-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--neutral-surface);
  border-top: 1px solid var(--gray-200);
  z-index: 100;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

@media (max-width: 767px) {
  /* In-flow tab bar when app shell active — do not use fixed bottom (see grid rows above) */
  html.pwa-app-shell #mobile-footer {
    position: static !important;
    bottom: auto !important;
    top: auto !important;
  }

  #mobile-footer {
    /* bottom safe-area: extend bg via ::after; items row gets touch padding */
    padding-bottom: 0 !important;
  }

  #mobile-footer-items {
    min-height: var(--tab-bar-inner-height);
    padding-top: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-footer-item--placeholder .mobile-footer-item__icon-spacer {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
  }

  .mobile-footer-item--placeholder .mobile-footer-item__label-spacer {
    visibility: hidden;
  }

  #mobile-footer::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-bottom, 0px);
    background-color: inherit;
    pointer-events: none;
  }
}

/* Do not set #mobile-footer padding in tool CSS */

/* Mobile footer dark mode - global dark mode */
html.dark #mobile-footer:not(.workout-dark-mode) {
  background-color: var(--gray-800) !important;
  border-top-color: var(--gray-700) !important;
}

/* Mobile footer dark mode when workout tool is in dark mode (overrides global theme) */
#mobile-footer.workout-dark-mode {
  background-color: var(--gray-800) !important;
  border-top-color: var(--gray-700) !important;
}

/* Mobile footer light mode when workout tool is in light mode or not in workout tool */
#mobile-footer:not(.workout-dark-mode) {
  background-color: var(--neutral-surface) !important;
  border-top-color: var(--gray-200) !important;
}

/* Ensure mobile footer text colors match theme */
/* Dark mode (global or workout tool) */
html.dark #mobile-footer:not(.workout-dark-mode) .mobile-footer-label,
#mobile-footer.workout-dark-mode .mobile-footer-label {
  color: var(--gray-400) !important;
}

/* Light mode */
#mobile-footer:not(.workout-dark-mode) .mobile-footer-label {
  color: var(--gray-500) !important;
}

/* Dark mode (global or workout tool) icons – non-active forced to neutral-primary */
html.dark #mobile-footer:not(.workout-dark-mode) .mobile-footer-item:not(.active) svg,
#mobile-footer.workout-dark-mode .mobile-footer-item:not(.active) svg {
  color: var(--neutral-primary) !important;
  fill: var(--neutral-primary) !important;
  stroke: var(--neutral-primary) !important;
}

/* Dark mode: non-active tab bar <img> icons forced to neutral-primary (white) */
html.dark #mobile-footer:not(.workout-dark-mode) .mobile-footer-item:not(.active) img,
#mobile-footer.workout-dark-mode .mobile-footer-item:not(.active) img {
  filter: brightness(0) saturate(100%) invert(1) !important;
}

/* Light mode icons */
#mobile-footer:not(.workout-dark-mode) .mobile-footer-item:not(.active) svg {
  color: var(--gray-500) !important;
}

/* Desktop: same tab bar at top, full width, behind header (z-index 0), 80px height */
@media (min-width: 768px) {
  :root {
    --tab-bar-desktop-height: 80px;
  }
  #mobile-footer {
    display: block !important;
    position: fixed !important;
    bottom: auto;
    left: 50%;
    right: auto;
    top: 0;
    width: auto;
    min-width: fit-content;
    height: var(--tab-bar-desktop-height);
    min-height: var(--tab-bar-desktop-height);
    transform: translateX(-50%);
    border: none;
    padding-bottom: 0;
    padding-top: 0;
    padding-left: 1rem;
    padding-right: 1rem;
    background: transparent !important;
    box-shadow: none !important;
  }
  html.dark #mobile-footer:not(.workout-dark-mode) {
    background: transparent !important;
  }
  #mobile-footer:not(.workout-dark-mode) {
    background: transparent !important;
  }
  #mobile-footer-items {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100%;
    padding: 0 1rem;
    gap: 0.5rem;
  }
  #mobile-footer .mobile-footer-item {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex: none;
    padding: 0.5rem 12px;
    gap: 10px;
    border-radius: 0.5rem;
  }
  #mobile-footer .mobile-footer-item > div:first-child {
    margin-bottom: 0 !important;
    flex-shrink: 0;
  }
  #mobile-footer .mobile-footer-item .toolbelt-tab-video-wrap {
    margin-top: 0 !important;
    width: 40px !important;
    height: 40px !important;
  }
  #mobile-footer .mobile-footer-label {
    margin-top: 0;
    white-space: nowrap;
  }
  /* Desktop: hide Toolbelt tab only (FAB / header for app switcher). id=home is the first tool tab (Progress, Tasks, etc.) */
  #mobile-footer [data-toolbar-id="toolbelt"] {
    display: none !important;
  }
  /* Desktop: show FAB at bottom right */
  #tool-fab {
    display: flex !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
  }
}

.mobile-footer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  color: var(--text-dim);
  transition: color 0.2s;
}

.mobile-footer-item:active {
  opacity: 0.7;
}

/* Global tab bar: active tab icon (SVG/img) uses theme color; label text stays same as other tabs */
#mobile-footer .mobile-footer-item.active svg {
  color: var(--orange) !important;
}

/* Fallback when JS has not applied mask: default orange filter for img */
#mobile-footer .mobile-footer-item.active img {
  filter: brightness(0) saturate(100%) invert(52%) sepia(98%) saturate(1500%) hue-rotate(0deg);
}

/* Active tab label: same color as inactive tabs (not theme color) */
#mobile-footer .mobile-footer-item.active .mobile-footer-label {
  color: var(--gray-500) !important;
}

html.dark #mobile-footer .mobile-footer-item.active svg {
  color: var(--orange) !important;
}

html.dark #mobile-footer .mobile-footer-item.active img {
  filter: brightness(0) saturate(100%) invert(52%) sepia(98%) saturate(1500%) hue-rotate(0deg);
}

html.dark #mobile-footer .mobile-footer-item.active .mobile-footer-label {
  color: var(--gray-400) !important;
}

/* Mobile Footer Tab Bar Text Styling */
:root {
  --tab-bar-text-color: var(--gray-400);
}

.mobile-footer-label {
  color: var(--tab-bar-text-color);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-cap); /* 10px */
  font-style: normal;
  font-weight: 700;
  line-height: normal;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}
