/* ========================================
   Studio-App - Iron Forge Aesthetic
   Industrial-luxe fitness tracking
   ======================================== */

/* System fonts - no external dependencies */

/* CSS Custom Properties */
:root {
  --bg-primary: #0d0d10;
  --bg-secondary: #131316;
  --bg-card: #1a1a1f;
  --bg-input: #222228;
  --bg-hover: #2a2a32;
  --bg-elevated: #1e1e24;
  --text-primary: #f0f0f3;
  --text-secondary: #b8b8c8;
  --text-muted: #858599;
  --accent: #ff6b2c;
  --accent-hover: #ff7f45;
  --accent-muted: rgba(255, 107, 44, 0.12);
  --accent-glow: rgba(255, 107, 44, 0.25);
  --accent-secondary: #ff9a3d;
  --accent-rgb: 255, 107, 44;
  --accent-secondary-rgb: 255, 154, 61;
  --on-accent: #ffffff;
  /* --primary war nie definiert, wurde aber an 7 Stellen als Akzent benutzt (u. a. aktiver
     Wochen/Monate-Umschalter: weiß auf weiß im hellen Design). */
  --primary: var(--accent);
  /* Diese fünf waren nie definiert, wurden aber benutzt (Hinweiskästen ohne Hintergrund,
     Hover ohne Fläche u. a.) — Verweise auf vorhandene Werte, keine neuen Farben (06.11.2026). */
  --background: var(--bg-input);
  --bg-tertiary: var(--bg-hover);
  --muted: var(--text-muted);
  --radius-lg: var(--radius);
  --shadow-xl: var(--shadow-lg);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #3dd68c;
  --success-muted: rgba(61, 214, 140, 0.12);
  --warning: #f59e0b;
  --info: #5ba4f5;
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.11);
  --border-accent: rgba(255, 107, 44, 0.3);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 4px 20px rgba(255, 107, 44, 0.2);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --nav-height: 60px;
  --bottom-nav-height: 72px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

[data-theme="light"] {
  --bg-primary: #f5f0eb;
  --bg-secondary: #faf7f3;
  --bg-card: #ffffff;
  --bg-input: #f0ece6;
  --bg-hover: #e8e3dc;
  --bg-elevated: #ffffff;
  --text-primary: #1a1a20;
  --text-secondary: #52525e;
  --text-muted: #7a7a8c;
  --accent: #ff6b2c;
  --accent-hover: #ff7f45;
  --accent-muted: rgba(255, 107, 44, 0.10);
  --accent-glow: rgba(255, 107, 44, 0.18);
  --accent-secondary: #ff9a3d;
  --accent-rgb: 255, 107, 44;
  --accent-secondary-rgb: 255, 154, 61;
  --on-accent: #ffffff;
  --success: #1a9e5c;
  --success-muted: rgba(26, 158, 92, 0.12);
  --info: #2b7de9;
  --warning: #d97706;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(255, 107, 44, 0.25);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.10);
  --shadow-accent: 0 4px 20px rgba(255, 107, 44, 0.15);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Verhindert, dass der Gummiband-/Bounce-Effekt beim Überscrollen die fixe
     Bottom-Nav mit nach oben reißt (iOS Safari + In-App-Browser). */
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-display);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh; /* dynamische Viewport-Höhe: stabil trotz mobiler Browser-Leiste */
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* Subtle noise texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  background-repeat: repeat;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* Page load animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ========== Top Navigation ========== */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* iOS-Standalone (black-translucent): Leiste reicht unter die Statusleiste,
     darum Höhe + Padding um die Safe-Area oben erweitern. env=0 auf Desktop. */
  height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
  background: rgba(13, 13, 16, 0.88);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  z-index: 100;
}

[data-theme="light"] .top-nav {
  background: rgba(250, 247, 243, 0.85);
}

.top-nav .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

/* Einwortiger Markenname kann nicht umbrechen; unter 360 px nur das Logo zeigen
   (gemessen 06.11.2026: ein 8-Buchstaben-Name schob bei 320 px den Abmelde-Knopf 16 px aus dem Bild). */
@media (max-width: 359px) {
  .top-nav .logo .logo-text-einwort { display: none; }
}

.top-nav .logo .logo-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 0 8px var(--accent-glow));
  transition: filter var(--transition), transform var(--transition);
}

.top-nav .logo:hover .logo-img {
  filter: drop-shadow(0 0 12px var(--accent-glow));
  transform: scale(1.08);
}

.top-nav .nav-links {
  display: none;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
  /* „safe“: passt das Menü nicht, beginnt es links statt beidseitig überzustehen — „center“
     allein schnitt den ersten Eintrag ab (gemessen 06.11.2026: „Ernährung“ bei 1024 px um
     231 px, bei 1280 px um 103 px). */
  justify-content: safe center;
}

.top-nav .nav-links::-webkit-scrollbar {
  display: none;
}

.top-nav .nav-link {
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all var(--transition);
  position: relative;
}

.top-nav .nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.top-nav .nav-link.active {
  color: var(--accent);
}

.top-nav .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--accent-glow);
}

.top-nav .nav-link svg {
  width: 18px;
  height: 18px;
}

.top-nav .user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-nav .username {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: none;
  letter-spacing: 0.02em;
}

.top-nav .btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.top-nav .btn-icon:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--border-accent);
}

.top-nav .btn-icon svg {
  width: 18px;
  height: 18px;
}

/* ========== Theme Toggle ========== */
.theme-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle-track {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a24 0%, #0d0d12 100%);
  border-radius: 20px;
  border: 1px solid var(--border-light);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.03);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.theme-toggle-track::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.05) 0%,
    transparent 50%
  );
  border-radius: inherit;
  pointer-events: none;
}

/* Stars in dark mode */
.theme-toggle-track::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 8px;
  width: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  box-shadow:
    6px 4px 0 0 rgba(255, 255, 255, 0.4),
    12px 2px 0 0 rgba(255, 255, 255, 0.3),
    4px 12px 0 0 rgba(255, 255, 255, 0.25);
  transition: opacity 0.3s ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #3a3a4a 0%, #252530 100%);
  border-radius: 50%;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-icon {
  width: 14px;
  height: 14px;
  position: absolute;
  transition: all 0.3s ease;
}

.theme-icon.sun {
  color: var(--accent);
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.theme-icon.moon {
  color: #8892b0;
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Light theme state */
[data-theme="light"] .theme-toggle-track {
  background: linear-gradient(135deg, #87CEEB 0%, #E0F4FF 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 0 2px 8px rgba(135, 206, 235, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .theme-toggle-track::after {
  opacity: 0;
}

[data-theme="light"] .theme-toggle-thumb {
  left: calc(100% - 27px);
  background: linear-gradient(135deg, #FFD93D 0%, #FF9A3D 100%);
  box-shadow:
    0 2px 12px rgba(255, 154, 61, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 0 20px rgba(255, 154, 61, 0.3);
}

[data-theme="light"] .theme-icon.sun {
  color: #fff;
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-icon.moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

/* Hover effects */
.theme-toggle:hover .theme-toggle-track {
  border-color: var(--accent);
}

.theme-toggle:hover .theme-toggle-thumb {
  transform: scale(1.05);
}

[data-theme="light"] .theme-toggle:hover .theme-toggle-thumb {
  box-shadow:
    0 2px 16px rgba(255, 154, 61, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 0 30px rgba(255, 154, 61, 0.4);
}

/* Focus state for accessibility */
.theme-toggle:focus-visible .theme-toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .theme-toggle {
    width: 48px;
    height: 26px;
  }

  .theme-toggle-thumb {
    width: 20px;
    height: 20px;
  }

  [data-theme="light"] .theme-toggle-thumb {
    left: calc(100% - 23px);
  }

  .theme-icon {
    width: 12px;
    height: 12px;
  }
}

/* ========== Bottom Navigation (Mobile) ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(13, 13, 16, 0.95);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
}

[data-theme="light"] .bottom-nav {
  background: rgba(250, 247, 243, 0.96);
  border-top-color: rgba(0, 0, 0, 0.08);
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: all var(--transition);
  min-height: 48px;
  flex: 1;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.bottom-nav .nav-item span {
  line-height: 1;
}

.bottom-nav .nav-item svg {
  width: 22px;
  height: 22px;
  transition: all var(--transition);
}

.bottom-nav .nav-item.active {
  color: var(--accent);
}

.bottom-nav .nav-item.active::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.bottom-nav .nav-item:hover {
  color: var(--text-primary);
}

/* ========== More Menu Drawer ========== */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.more-menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.more-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
}

.more-menu.open {
  transform: translateY(0);
}

.more-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.more-menu-header .close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.more-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 12px 20px;
}

.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.more-menu-item svg {
  width: 24px;
  height: 24px;
}

.more-menu-item:hover,
.more-menu-item:active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.more-menu-item.active {
  color: var(--accent);
  background: var(--bg-hover);
}

/* ========== Main Content ========== */
.main-content {
  /* + Safe-Area oben, damit der Inhalt nicht unter die iOS-Statusleiste rutscht. */
  padding-top: calc(var(--nav-height) + 20px + env(safe-area-inset-top, 0px));
  /* Abstand zum (im Fluss sitzenden) Footer; hält zugleich die letzte
     Inhaltszeile frei vom schwebenden FAB unten rechts. */
  padding-bottom: 56px;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
  animation: fadeIn 0.3s ease;
}

/* ========== App Footer ========== */
.app-footer {
  /* Mobile: im normalen Fluss am Seitenende statt als zweiter fixer Balken über
     der Tab-Leiste. margin-bottom hält ihn über der fixen .bottom-nav frei. */
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 769px) {
  /* Desktop: keine Bottom-Nav, Footer bleibt fix am unteren Rand. */
  .app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    margin-bottom: 0;
  }
}

/* ========== Auth Pages ========== */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(var(--accent-rgb), 0.08) 0%, transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: 20px;
  padding: 44px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: fadeInUp 0.4s ease;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary), var(--accent));
  background-size: 200% 100%;
  animation: shimmer 3s ease infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.auth-card .logo-section {
  text-align: center;
  margin-bottom: 36px;
}

.auth-card .logo-section .auth-logo-img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 16px var(--accent-glow));
  animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {
  0%, 100% { filter: drop-shadow(0 0 16px var(--accent-glow)); }
  50% { filter: drop-shadow(0 0 28px var(--accent-glow)) drop-shadow(0 0 6px var(--accent)); }
}

/* Kopf wie auf der Studio-Webseite (brand.json: telefon, login_logo) — nur bei gesetzten Feldern */
.auth-kopf {
  margin: -44px -32px 28px;
}
.auth-kontakt {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 20px;
  padding: 12px 16px 10px;
  background: #4f5559; /* Kopfleiste einer Studio-Webseite; design_css kann es ändern */
  font-size: 0.85rem;
  font-weight: 600;
}
.auth-kontakt a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  text-decoration: none;
}
.auth-kontakt svg {
  /* Die Leiste ist in beiden Designs dunkel: Grün des dunklen Farbsatzes (/brand.css).
     --accent des hellen Designs ist für Weiß gedacht — auf #4f5559 nur 1,47:1 (06.11.2026). */
  color: var(--accent-auf-dunkel, var(--accent));
  flex-shrink: 0;
}
.auth-kopf-logo {
  background: #ffffff;
  padding: 20px 32px;
  text-align: center;
}
.auth-kopf-logo img {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto;
}

.auth-card .logo-section h1 {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.auth-card .logo-section p {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 4px;
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all var(--transition);
  animation: fadeInUp 0.35s ease backwards;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Kopf mit Untertitel: untereinander statt nebeneinander — sonst quetscht
   space-between die Überschrift auf dem Handy in eine schmale Spalte. */
.card-header:has(> .subtitle) {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.card-header h2 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.card-body {
  padding: 20px;
}

/* ========== Dashboard Widgets ========== */
.dashboard-widgets {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dashboard-widget {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease,
              opacity 0.2s ease;
}

.dashboard-widget > .card,
.dashboard-widget > .stat-grid {
  margin-bottom: 0;
}

/* Drag handle - hidden by default */
.widget-drag-handle {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 10;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.widget-drag-handle:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.widget-drag-handle:active {
  cursor: grabbing;
}

/* Edit mode */
.dashboard-widgets.edit-mode .widget-drag-handle {
  display: flex;
}

.dashboard-widgets.edit-mode .dashboard-widget {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--bg-secondary);
}

.dashboard-widgets.edit-mode .dashboard-widget:hover {
  border-color: var(--accent);
}

/* Dragging state */
.dashboard-widget.dragging {
  opacity: 0.7;
  transform: scale(1.02) rotate(1deg);
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--accent);
  z-index: 100;
}

.dashboard-widget.drag-over {
  transform: translateY(8px);
}

.dashboard-widget.drag-over::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
}

/* Edit mode bar */
.edit-mode-bar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: var(--on-accent);
  padding: 12px 20px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg), 0 0 30px rgba(var(--accent-rgb), 0.3);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.9rem;
  font-weight: 500;
}

.edit-mode-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.edit-mode-bar .btn {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 25px;
}

.edit-mode-bar .btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

@media (min-width: 768px) {
  .edit-mode-bar {
    bottom: 24px;
  }
}

/* Training Reminder Widget */
.training-reminder {
  background: linear-gradient(135deg, var(--accent), #5a32a3);
  color: var(--on-accent);
  padding: 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.reminder-icon {
  background: rgba(255, 255, 255, 0.2);
  padding: 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reminder-content {
  flex: 1;
  min-width: 150px;
}

.reminder-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.reminder-subtitle {
  opacity: 0.9;
  font-size: 0.9rem;
}

.reminder-btn {
  background: #fff !important;
  color: var(--accent) !important;
  font-weight: 600 !important;
}

.reminder-btn:hover {
  background: rgba(255, 255, 255, 0.9) !important;
}

/* Stat grid variants */
.stat-grid-2 {
  grid-template-columns: 1fr 1fr !important;
}

/* ========== Stat Cards ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.35s ease backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

.stat-card .stat-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.stat-card .stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-card .stat-icon.green { background: rgba(61, 214, 140, 0.12); color: #3dd68c; }
.stat-card .stat-icon.blue { background: rgba(91, 164, 245, 0.12); color: #5ba4f5; }
.stat-card .stat-icon.orange { background: rgba(255, 154, 61, 0.12); color: #ff9a3d; }
.stat-card .stat-icon.red { background: rgba(var(--accent-rgb), 0.12); color: var(--accent); }

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-control {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-display);
  font-weight: 500;
  transition: all var(--transition);
  min-height: 44px;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  border-width: 2px;
  padding: 12px 15px;
  box-shadow: 0 0 0 3px var(--accent-muted), 0 0 16px var(--accent-muted);
}

.form-control::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5c70' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-inline {
  display: flex;
  gap: 10px;
  align-items: end;
  /* Umbrechen statt überstehen: „Grunddaten“ (Körperdaten) war bei 360/320 px 351 px breit in
     246 px Platz — „Speichern“ abgeschnitten (gemessen 06.11.2026, Konto ohne Messdaten). */
  flex-wrap: wrap;
}

.form-inline .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  text-transform: uppercase;
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.25);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  filter: brightness(1.08);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  filter: brightness(1.08);
  color: #fff;
}

/* Tastatur-Fokus sichtbar machen (A11y) — gilt für Buttons, Links, Icon-Buttons */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

.btn-fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  box-shadow: var(--shadow-accent), 0 0 24px var(--accent-glow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all var(--transition);
}

.btn-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 8px 32px rgba(var(--accent-rgb), 0.4);
}

.btn-fab svg {
  width: 24px;
  height: 24px;
}

/* ========== Page Header ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
  animation: fadeInUp 0.3s ease;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.page-header .subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ========== Date Navigation ========== */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.date-nav .date-text {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  min-width: 200px;
  letter-spacing: -0.01em;
}

/* Datum antippen = nativer Kalender: der sichtbare Text liegt über einem
   unsichtbaren <input type="date"> (Sprung zu beliebigem Tag, siehe app.js). */
.date-nav .date-jump {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: background var(--transition);
}

.date-nav .date-jump:hover {
  background: var(--bg-hover);
}

.date-nav .date-jump:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.date-nav .date-jump svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.date-nav .date-jump input[type="date"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.date-nav .today-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 6px var(--accent-muted);
}

.date-nav a {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.date-nav a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.date-nav a svg {
  width: 18px;
  height: 18px;
}

/* ========== Workout Summary Bar ========== */
.workout-summary {
  display: flex;
  gap: 20px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.workout-summary .summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.workout-summary .summary-item strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ========== Set List ========== */
.set-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.set-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  cursor: pointer;
}

.set-item:hover {
  border-color: var(--border-light);
  background: var(--bg-elevated);
}

.set-item .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.set-item .set-info {
  flex: 1;
  min-width: 0;
}

.set-item .set-name {
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-item .set-details {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.set-item .set-details span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.set-item .set-details span:first-child {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-weight: 600;
}

.set-item .set-details .last-date {
  color: var(--text-muted);
  font-size: 0.72rem;
  opacity: 0.7;
  margin-left: auto;
}

.set-item .delete-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.set-item .delete-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--danger);
}

.set-item .delete-btn svg {
  width: 15px;
  height: 15px;
}

/* Inline Edit */
.set-item .inline-edit-form {
  display: none;
  width: 100%;
}

.set-item.editing {
  flex-wrap: wrap;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.set-item.editing .set-info,
.set-item.editing .delete-btn,
.set-item.editing > form:first-of-type {
  display: none;
}

.set-item.editing .inline-edit-form {
  display: block;
  margin-top: 8px;
}

.inline-edit-fields {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.inline-edit-field {
  flex: 1;
}

.inline-edit-field label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 600;
}

.inline-edit-field input {
  width: 100%;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 6px;
  font-family: var(--font-mono);
}

.inline-edit-save,
.inline-edit-cancel {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Exercise Cards ========== */
.exercise-group {
  margin-bottom: 28px;
  animation: fadeInUp 0.35s ease backwards;
}

.exercise-group:nth-child(1) { animation-delay: 0.05s; }
.exercise-group:nth-child(2) { animation-delay: 0.1s; }
.exercise-group:nth-child(3) { animation-delay: 0.15s; }
.exercise-group:nth-child(4) { animation-delay: 0.2s; }

.exercise-group h3 {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.exercise-group h3::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.exercise-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.exercise-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.exercise-card:hover {
  border-color: var(--border-light);
  transform: translateX(4px);
}

.exercise-card .color-bar {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

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

.exercise-card .ex-name {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.exercise-card .ex-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.exercise-card .ex-actions {
  display: flex;
  gap: 2px;
}

.exercise-card .ex-actions a,
.exercise-card .ex-actions button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.exercise-card .ex-actions a:hover { background: var(--bg-hover); color: var(--accent); }
.exercise-card .ex-actions button:hover { background: rgba(255, 107, 44, 0.1); color: var(--danger); }
.exercise-card .ex-actions svg { width: 15px; height: 15px; }

/* ========== Heatmap ========== */
.heatmap-container {
  padding: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heatmap-container h2 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

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

.heatmap-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--bg-input);
  transition: all var(--transition);
  cursor: crosshair;
}

.heatmap-cell:hover {
  transform: scale(1.4);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 2;
  position: relative;
}

.heatmap-cell[data-count="0"] { background: var(--bg-input); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.heatmap-legend .cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
}

.heatmap-months {
  display: flex;
  margin-bottom: 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}

.heatmap-months span {
  flex: 1;
  text-align: center;
}

/* ========== Weight Table ========== */
.weight-table {
  width: 100%;
  border-collapse: collapse;
}

.weight-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.weight-table td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.weight-table td strong {
  font-family: var(--font-mono);
  font-weight: 700;
}

.weight-table tr:last-child td {
  border-bottom: none;
}

.weight-table tr:hover td {
  background: var(--bg-hover);
}

/* ========== Chart Container ========== */
.chart-container {
  padding: 16px;
  height: 300px;
  position: relative;
}
/* Ohne Daten bleibt ein <canvas> auf 300 px Standardbreite und ragte bei 320 px aus der Karte. */
.chart-container canvas { max-width: 100%; }

.chart-select {
  margin-bottom: 16px;
}

/* ========== Alerts ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeInUp 0.3s ease;
}

.alert-error,
.alert-danger {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--danger);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
}

.alert-success {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid rgba(61, 214, 140, 0.2);
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  opacity: 0.3;
  stroke: var(--text-muted);
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 0.82rem;
  font-weight: 400;
}

/* ========== Color Input ========== */
.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-input-wrap input[type="color"] {
  -webkit-appearance: none;
  width: 42px;
  height: 42px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 3px;
  background: var(--bg-input);
  transition: border-color var(--transition);
}

.color-input-wrap input[type="color"]:hover {
  border-color: var(--accent);
}

.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

/* ========== Modal/Overlay ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.modal-overlay.active {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-top: 3px solid var(--accent);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-sheet .modal-header h2 {
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.modal-sheet .close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.modal-sheet .close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.modal-sheet .close-btn svg {
  width: 16px;
  height: 16px;
}

/* ========== Settings ========== */
.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.theme-switcher {
  display: flex;
  gap: 8px;
}

.theme-option {
  flex: 1;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all var(--transition);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.theme-option:hover { border-color: var(--border-light); }
.theme-option.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  box-shadow: 0 0 12px var(--accent-muted);
}

/* ========== Recent Sets on Dashboard ========== */
.recent-sets {
  margin-top: 4px;
}

.recent-sets .set-date-group {
  margin-bottom: 12px;
}

.recent-sets .date-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 0;
}

/* ========== Tooltip ========== */
.tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
}

/* ========== Responsive ========== */
@media (min-width: 768px) {
  .bottom-nav { display: none; }

  .top-nav .nav-links { display: flex; }
  .top-nav .nav-link { padding: 6px 7px; gap: 4px; font-size: 0.72rem; }
  .top-nav .nav-link svg { width: 15px; height: 15px; }
  .top-nav .username { display: block; }

  .main-content {
    padding-bottom: 40px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .exercise-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .btn-fab {
    bottom: 24px;
    right: 24px;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal-sheet {
    border-radius: 20px;
    max-height: 80vh;
    border-top: none;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(var(--accent-rgb), 0.05);
  }

  .modal-sheet::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 20px 20px 0 0;
  }

  .heatmap-cell {
    width: 14px;
    height: 14px;
  }
}

@media (min-width: 1024px) {
  .main-content {
    max-width: 1100px;
    padding-left: 32px;
    padding-right: 32px;
  }

  .exercise-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========== Utility ========== */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection {
  background: var(--accent);
  color: var(--on-accent);
}

/* ========================================
   BMI Card
   ======================================== */
.bmi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.bmi-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}
.bmi-number {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}
.bmi-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 2px;
}
.bmi-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bmi-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  width: fit-content;
}
.bmi-badge.bmi-underweight { background: rgba(33,150,243,0.15); color: #42a5f5; }
.bmi-badge.bmi-normal { background: rgba(76,175,80,0.15); color: #66bb6a; }
.bmi-badge.bmi-overweight { background: rgba(255,167,38,0.15); color: #ffa726; }
.bmi-badge.bmi-obese { background: rgba(239,83,80,0.15); color: #ef5350; }
.bmi-badge.bf-essential { background: rgba(33,150,243,0.15); color: #42a5f5; }
.bmi-badge.bf-athletic { background: rgba(76,175,80,0.15); color: #66bb6a; }
.bmi-badge.bf-fit { background: rgba(61,214,140,0.15); color: #3dd68c; }
.bmi-badge.bf-average { background: rgba(255,167,38,0.15); color: #ffa726; }
.bmi-badge.bf-high { background: rgba(239,83,80,0.15); color: #ef5350; }
.bmi-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.bmi-scale {
  flex: 1;
  min-width: 200px;
}
.bmi-scale-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.bmi-scale-segment {
  height: 100%;
}
.bmi-scale-segment.bmi-underweight { background: #42a5f5; }
.bmi-scale-segment.bmi-normal { background: #66bb6a; }
.bmi-scale-segment.bmi-overweight { background: #ffa726; }
.bmi-scale-segment.bmi-obese { background: #ef5350; }
.bmi-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.bmi-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ========================================
   Measurements
   ======================================== */
.measurements-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.measurements-grid .form-group {
  margin-bottom: 0;
}

.measurements-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.measurements-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.measurements-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.measurements-table td {
  padding: 10px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.measurements-table td:first-child {
  font-family: var(--font-display);
  font-weight: 600;
}

.measurements-table tr:last-child td {
  border-bottom: none;
}

.measurements-table tr:hover td {
  background: var(--bg-hover);
}

@media (min-width: 768px) {
  .measurements-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========================================
   Templates
   ======================================== */
.template-exercise-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.template-exercise-item:last-child {
  border-bottom: none;
}

.template-exercise-name {
  font-weight: 600;
}

.template-exercise-detail {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.template-row {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.template-row:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.template-row-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.template-row-details .form-group {
  margin-bottom: 0;
}

@media (max-width: 400px) {
  .template-row-details {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }
}

.template-load-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* Template Actions */
.template-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-sm {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
}

.btn-icon-sm:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* Favorite Quick Add Modal */
.fav-quick-add-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
}

.fav-quick-add-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}

.fav-quick-add-content h4 {
  margin: 0 0 8px 0;
  font-size: 1rem;
}

.fav-item-row {
  display: flex;
  align-items: center;
}

.fav-item-row .result-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Template Edit Row Header */
.template-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.template-row-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-hover);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.template-row-remove {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  opacity: 0.5;
  transition: all var(--transition);
}

.template-row-remove:hover {
  opacity: 1;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}

/* ========================================
   Personal Records
   ======================================== */
.pr-list {
  display: flex;
  flex-direction: column;
}

.pr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.pr-item:last-child {
  border-bottom: none;
}

.pr-item:hover {
  background: var(--bg-hover);
}

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

.pr-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.pr-details {
  display: flex;
  gap: 16px;
  margin-top: 2px;
}

.pr-weight {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
}

.pr-volume {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ========================================
   Export/Import
   ======================================== */
.export-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

input[type="file"].form-control {
  padding: 8px;
  font-size: 0.85rem;
}

/* ========================================
   Achievements / Badges
   ======================================== */
.badge-counter {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 4px 10px;
  border-radius: 20px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.badge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 14px;
  text-align: center;
  opacity: 0.35;
  transition: all var(--transition);
}

.badge-card.badge-earned {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.badge-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  color: var(--text-muted);
}

.badge-earned .badge-icon {
  color: var(--accent);
}

.badge-icon svg {
  width: 100%;
  height: 100%;
}

.badge-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.badge-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ========================================
   Goals
   ======================================== */
.goal-list {
  display: flex;
  flex-direction: column;
}

.goal-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.goal-item:last-child {
  border-bottom: none;
}

.goal-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.goal-name {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.goal-target {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.goal-progress {
  margin-top: 10px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.goal-achieved {
  opacity: 0.7;
}

.goal-achieved .goal-target {
  color: var(--success);
  font-weight: 600;
}

/* ========================================
   Muscle Balance
   ======================================== */
.balance-summary {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.balance-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.85rem;
}

.balance-name {
  font-weight: 600;
  color: var(--text-primary);
}

.balance-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ========================================
   Supersets
   ======================================== */
.superset-item {
  border-left: 3px solid var(--accent);
  margin-left: 4px;
}

.superset-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--accent-muted);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.superset-toggle {
  margin-top: 4px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.toggle-text {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.form-control-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
  margin-top: 6px;
}

/* ========================================
   Rest Timer
   ======================================== */
.timer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(8px);
}

.timer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.timer-container {
  text-align: center;
  position: relative;
  padding: 32px;
}

.timer-circle {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
}

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

.timer-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.timer-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s linear;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 2px;
}

.timer-label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-weight: 500;
}

.timer-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.timer-close {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  transition: color var(--transition);
}

.timer-close:hover {
  color: var(--text-primary);
}

.timer-close svg {
  width: 24px;
  height: 24px;
}

/* Timer Done Animation */
.timer-circle.timer-done {
  animation: timerPulse 0.8s ease-in-out 3;
}

.timer-circle.timer-done .timer-progress {
  stroke: var(--success);
  filter: drop-shadow(0 0 20px var(--success));
}

.timer-circle.timer-done .timer-display {
  color: var(--success);
  animation: timerGlow 0.8s ease-in-out 3;
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes timerGlow {
  0%, 100% { text-shadow: 0 0 0 transparent; }
  50% { text-shadow: 0 0 20px var(--success), 0 0 40px var(--success); }
}

/* Timer Flash - full screen attention */
.timer-overlay.timer-flash::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, var(--success) 0%, transparent 70%);
  opacity: 0.4;
  animation: timerFlash 0.8s ease-out forwards;
  pointer-events: none;
}

@keyframes timerFlash {
  0% { opacity: 0.5; transform: scale(0.5); }
  50% { opacity: 0.3; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(2); }
}

/* Countdown Warning State (last 3 seconds) */
.timer-circle.timer-countdown .timer-progress {
  stroke: var(--warning);
  filter: drop-shadow(0 0 12px var(--warning));
}

.timer-circle.timer-countdown .timer-display {
  color: var(--warning);
}

/* ========== PR Notification ========== */
.pr-notification {
  background: linear-gradient(135deg, #FF6F00, #FF8F00);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  cursor: pointer;
  transition: opacity 0.4s, transform 0.4s;
  box-shadow: 0 4px 20px rgba(255, 111, 0, 0.3);
  animation: prPulse 0.6s ease-out;
}

.pr-notification-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}

.pr-notification svg {
  color: #FFD54F;
  flex-shrink: 0;
}

@keyframes prPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ========== 1RM Badge ========== */
.pr-1rm {
  color: #FF5722;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ========== Last Set Indicator ========== */
.ex-last {
  color: var(--success) !important;
  font-weight: 600;
}

/* ========== Progress Photos ========== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.photo-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
}

.photo-item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.photo-meta {
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.photo-item .delete-btn-sm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.photo-item:hover .delete-btn-sm {
  opacity: 1;
}

.compare-selectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.compare-view {
  display: flex;
  gap: 0.5rem;
}

.compare-img {
  flex: 1;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.compare-img img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.compare-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ========== Muscle Heatmap ========== */
.muscle-heatmap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.muscle-body-container {
  width: 180px;
  max-width: 100%;
}

.muscle-body-svg {
  width: 100%;
  height: auto;
}

.muscle-part {
  transition: fill 0.3s, stroke 0.3s;
}

.muscle-heatmap-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.heatmap-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.heatmap-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* ========== Nutrition / Macros ========== */
.macro-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.macro-item {
  padding: 0.5rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
}

.macro-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.macro-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.macro-protein .macro-value { color: #5ba4f5; }
.macro-carbs .macro-value { color: #ff9a3d; }
.macro-fat .macro-value { color: #ff6b2c; }

/* ========== Nutrition Overview ========== */
.nutrition-overview {
  display: flex;
  align-items: center;
  gap: 20px;
}

.calorie-ring-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.calorie-ring {
  width: 100%;
  height: 100%;
}

.calorie-ring circle:last-child {
  transition: stroke-dashoffset 0.6s ease;
}

.calorie-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 1.2;
}

.cal-current {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
}

.cal-label {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Restkalorien im Ring-Zentrum (Harald-Wunsch): Restwert groß + kräftig grün,
   bei Überschreitung roter Minus-Wert. Etwas größer als .cal-current. */
.cal-remaining {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--success);
}

.cal-remaining.over {
  color: var(--danger);
}

.macro-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.macro-bar-item .macro-bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.macro-bar-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.macro-bar-value {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ========== Startseite v2: Lifesum-Ring (Verzehrt | Übrig | Verbrannt) ========== */
.lifesum-ring-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
}

.lsr-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.lsr-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.lsr-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.lsr-ring {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
}

.lsr-ring-title {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* Rest-Kalorien im Ring etwas größer im Lifesum-Ring */
.lsr-ring .cal-remaining {
  font-size: 1.7rem;
}

/* ========== Startseite v2: Makro-Boxen (Lifesum-Stil) ========== */
.macro-box-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.macro-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.macro-box-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.macro-box-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Energie-Bilanz-Aufschlüsselung (auch auf der Startseite, global) */
.energy-balance {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.energy-balance .eb-row { display: flex; justify-content: space-between; font-size: 0.95rem; }
.energy-balance .eb-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.energy-balance .eb-plus span:last-child { color: #3fb950; }
.energy-balance .eb-sum { padding-top: 6px; border-top: 1px solid var(--border); }
.energy-balance .eb-remaining { margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 1.05rem; }
.energy-balance .eb-remaining span { font-weight: 700; }
.energy-balance .eb-remaining span:last-child { color: var(--accent); }

/* ========== Startseite v2: Wasser-Tracker mit festen Buttons ========== */
.water-tracker {
  margin-top: 18px;
}

.water-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.water-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.water-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.water-btns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.water-add-btn {
  flex: 1;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.water-add-btn:hover:not(:disabled) {
  border-color: #4aa3f0;
  color: #4aa3f0;
}

.water-add-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ========== Startseite v2: Mahlzeiten-Übersicht ========== */
.meal-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.meal-summary-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  text-decoration: none;
  transition: all var(--transition);
  /* wird als <button> genutzt → Button-Defaults zurücksetzen */
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  color: inherit;
}

.meal-summary-card:hover {
  border-color: var(--accent);
}

.meal-summary-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.meal-summary-cal {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.meal-summary-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== Startseite v2: Kalorien-Verlaufs-Chart ========== */
.trend-range {
  display: flex;
  gap: 6px;
}

.trend-range button.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.trend-chart-wrap {
  position: relative;
  height: 240px;
  margin-top: 8px;
}

/* ========== Dashboard: Ernährungs-Schnelleintrag (1-Tap-Chips) ========== */
.quick-add-label {
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.quick-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-add-chip,
.quick-water-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.quick-add-chip:hover,
.quick-water-chip:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.quick-add-chip:active,
.quick-water-chip:active {
  transform: scale(0.97);
}

.quick-add-chip:disabled,
.quick-water-chip:disabled {
  opacity: 0.55;
  cursor: default;
}

.quick-add-chip .qa-name,
.quick-water-chip .qa-name {
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-add-chip .qa-cal,
.quick-water-chip .qa-cal {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ========== Water Tracker ========== */
.water-total {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: #5ba4f5;
}

.water-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.water-custom-form {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ========== Meal Sections ========== */
.meal-total-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 3px 10px;
  border-radius: 20px;
}

.meal-items {
  border-bottom: 1px solid var(--border);
}

.meal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.meal-item:last-child {
  border-bottom: none;
}

.meal-item:hover {
  background: var(--bg-hover);
}

.meal-item-info {
  flex: 1;
  min-width: 0;
}

.meal-item-name {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-item-detail {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
  margin-top: 1px;
}

.meal-add-btn {
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition);
}

.meal-add-btn:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.meal-action-row {
  display: flex;
  align-items: stretch;
}

.meal-action-row .meal-add-btn {
  flex: 1;
}

.meal-action-btn {
  padding: 10px 14px;
  background: none;
  border: none;
  border-left: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition);
}

.meal-action-btn:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.meal-action-btn-label {
  padding: 10px 12px;
  flex-direction: column;
  gap: 4px;
}

.meal-action-btn-label svg {
  width: 18px;
  height: 18px;
}

.meal-action-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Meal Favorite Items */
.meal-fav-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.meal-fav-item:last-child {
  border-bottom: none;
}

.meal-fav-item:hover {
  background: var(--bg-tertiary);
}

.meal-fav-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meal-fav-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.meal-fav-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========== Food Modal Tabs ========== */
.food-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.food-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.food-tab:hover {
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.food-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.food-tab-content {
  display: none;
}

.food-tab-content.active {
  display: block;
}

/* Modal Tabs */
.modal-tab {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.modal-tab:hover {
  color: var(--text-secondary);
}

.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Single Favorite Checkbox Item */
.fav-checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--transition);
}

.fav-checkbox-item:hover {
  background: var(--bg-hover);
}

.fav-checkbox-item.selected {
  background: var(--accent-muted);
}

.fav-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.fav-checkbox-item.selected .fav-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.fav-checkbox svg {
  display: none;
  width: 14px;
  height: 14px;
  stroke: white;
  stroke-width: 3;
}

.fav-checkbox-item.selected .fav-checkbox svg {
  display: block;
}

.fav-checkbox-info {
  flex: 1;
  min-width: 0;
}

.fav-checkbox-name {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-checkbox-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fav-checkbox-kcal {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.85rem;
}

/* ========== Scanner ========== */
.scanner-container {
  margin-bottom: 8px;
}

#scanner-viewport {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

#scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#scanner-viewport canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ========== Search Input ========== */
.search-input-wrap {
  position: relative;
}

.search-input-wrap .form-control {
  padding-left: 42px;
  padding-right: 40px;
}

.search-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.search-clear-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* ========== Search Results ========== */
.search-results {
  max-height: 350px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.search-result-item:hover,
.search-result-item:active {
  background: var(--bg-hover);
}

.search-result-item:last-child {
  border-bottom: none;
}

.result-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  background: var(--bg-input);
}

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

.result-name {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Verified badge for BLS data */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #22c55e;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

.result-verified {
  border-left: 3px solid #22c55e;
}

.result-favorite {
  border-left: 3px solid var(--accent);
}

.result-bls-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #dcfce7;
  color: #22c55e;
  border-radius: 6px;
}

.result-brand {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.result-macros {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}

.result-cal {
  font-weight: 700;
  color: var(--text-primary);
}

.result-macro-detail {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ========== Product Detail ========== */
.product-header {
  margin-bottom: 16px;
}

.product-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.product-macros-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.pmp-item {
  text-align: center;
  padding: 10px 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
}

.pmp-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
}

.pmp-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.pmp-protein .pmp-val { color: #5ba4f5; }
.pmp-carbs .pmp-val { color: #ff9a3d; }
.pmp-fat .pmp-val { color: #ff6b2c; }

@media (max-width: 400px) {
  .nutrition-overview {
    flex-direction: column;
    align-items: stretch;
  }
  .calorie-ring-wrap {
    margin: 0 auto 8px;
  }
}

/* ========== Recovery Tracking ========== */
/* Spaltenbreite = 5 Knöpfe à 40px + 4 Abstände à 6px = 224px. Fest „1fr 1fr“
   brauchte 460px und schob auf Handys (Inhalt ~294px) 8 von 20 Knöpfen aus der
   Karte. auto-fit bricht auf eine Spalte um, sobald zwei nicht passen; das
   max(…, halbe Breite) begrenzt es auf zwei Spalten (sonst 3+1 auf Desktop). */
.recovery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(224px, calc((100% - 0.75rem) / 2)), 1fr));
  gap: 0.75rem;
}

.recovery-item label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.rating-select {
  display: flex;
  gap: 6px;
}

.rating-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.rating-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rating-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  transform: scale(1.08);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ========== Session Control ========== */
.session-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.session-control-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.session-control-right {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.session-stat {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.session-stat strong {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

/* Vergleichszeile „Letztes Training (16.07.): 5 Sätze · 4650 kg" */
.session-last {
  margin: 6px 2px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.session-last strong {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-secondary);
}

/* === Soll-Ist-Auswertung auf /stats (Harald 07.08.2026) ===
   11 Spalten passen auf kein Handy. Statt Spalten zu opfern scrollt die Tabelle
   in ihrem eigenen Container waagerecht — die Seite selbst tut das nie. Die
   Zeitraum-Spalte bleibt beim Scrollen stehen, sonst weiss man nicht mehr,
   welche Woche man liest. */
.report-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.report-toggle {
  padding: 6px 14px;
  min-height: 36px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.report-toggle.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-accent);
}

.report-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.report-table th,
.report-table td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-light);
}

.report-table th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report-table td {
  font-family: var(--font-mono);
}

/* Zeitraum-Spalte: links ausgerichtet und beim Querscrollen fixiert. */
.report-table th.rt-period,
.report-table td.rt-period {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: var(--bg-card);
  font-family: inherit;
}

.rt-label { display: block; font-weight: 600; }
.rt-sub { display: block; font-size: 0.7rem; color: var(--text-muted); }
.rt-running { font-weight: 400; color: var(--text-muted); }
.report-table tr.rt-partial td { opacity: 0.75; }

/* Schmale Handys: lange Knopftexte („Benachrichtigungen aktivieren“) liefen bei
   320px über den Kartenrand, weil .btn nowrap ist. Umbruch nur, wo nötig. */
@media (max-width: 400px) {
  .btn { max-width: 100%; white-space: normal; text-align: center; }
}

/* Handy: Tabelle → eine Karte je Zeitraum (Kunden-Test 05.11.2026). Die Tabelle ist
   833px breit; bei 360px sah man nur Zeitraum/Erfasst/Soll/Ist — Bilanz und die
   Körperwerte, um deren Vergleich es geht, lagen ohne jeden Hinweis rechts außerhalb.
   Die Beschriftung kommt aus data-label (renderPeriodReport setzt sie aus dem thead). */
@media (max-width: 600px) {
  .report-table-wrap { overflow-x: visible; }
  .report-table, .report-table tbody { display: block; white-space: normal; }
  .report-table thead { display: none; }
  .report-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
    padding: 10px 2px 12px;
    border-bottom: 1px solid var(--border);
  }
  .report-table td {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 0;
    min-width: 0;
  }
  .report-table td::before {
    content: attr(data-label);
    font-family: var(--font-body, inherit);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-right: auto; /* Wert + Pfeil bleiben zusammen rechts */
  }
  .report-table td.rt-period {
    grid-column: 1 / -1;
    position: static;
    display: block;
    padding-bottom: 6px;
  }
  .report-table td.rt-period::before { content: none; }
  .report-table td.rt-period .rt-label,
  .report-table td.rt-period .rt-sub { display: inline; }
  .report-table td.rt-period .rt-sub { margin-left: 8px; }
}

/* Unvollständig erfasster Zeitraum: die Bilanz darunter ist nicht vergleichbar. */
.rt-warn { color: var(--warning); }
.rt-none { color: var(--text-muted); }

.rt-deficit { color: var(--success); font-weight: 600; }
.rt-surplus { color: var(--danger); font-weight: 600; }
.rt-up { color: var(--text-muted); font-size: 0.75rem; }
.rt-down { color: var(--text-muted); font-size: 0.75rem; }

.report-empty,
.report-nobody {
  margin: 12px 2px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.report-nobody { color: var(--warning); }

.report-hint {
  margin: 12px 2px 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Messerinnerung: auffälliger als der Hinweistext darunter, aber kein Fehler —
   deshalb Warnfarbe mit ruhigem Hintergrund statt roter Meldung. */
.report-remind {
  margin: 14px 2px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  background: rgba(240, 160, 32, 0.08);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.report-remind a {
  white-space: nowrap;
  font-weight: 600;
}

/* Kombi-Diagramm unter der Tabelle */
.report-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 2px 8px;
}

.report-chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.report-line-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.report-line-btn {
  padding: 4px 10px;
  min-height: 32px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}

.report-line-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

/* Feste Höhe: Chart.js braucht bei maintainAspectRatio:false einen Container,
   der seine Höhe selbst kennt — sonst wächst das Canvas bei jedem Neuzeichnen. */
.report-chart-wrap {
  position: relative;
  height: 260px;
}

/* Trainingszeit anzeigen + korrigieren (Harald 06.08.2026, vergessener Stopp).
   Eine Zeile, die auch auf 360px nicht umbricht: Label und Einheit schrumpfen,
   das Zahlenfeld bleibt tippbar (min-height 40px = Touch-Ziel). */
.session-duration {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 2px 0;
}

.session-duration-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.session-duration-input {
  width: 5.5rem;
  min-height: 40px;
  font-family: var(--font-mono);
  text-align: right;
}

.session-duration-unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: -4px;
}

.session-duration-warn {
  margin: 6px 2px 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--warning);
}

.session-start-btn {
  white-space: nowrap;
  min-height: 40px;
}

.session-timer-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  animation: pulse 2s ease-in-out infinite;
}

.session-timer-inline svg {
  color: var(--accent);
}

@media (max-width: 480px) {
  .session-control {
    flex-wrap: wrap;
  }
  .session-control-right {
    border-left: none;
    padding-left: 0;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    justify-content: space-around;
  }
}

/* ========== Training Plans ========== */
.plan-week {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-day {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.plan-day:last-child {
  border-bottom: none;
}

.plan-day-name {
  width: 80px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.plan-day-template {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

.plan-day-rest {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.plan-day-active .plan-day-name {
  color: var(--text-primary);
  font-weight: 600;
}

.plan-week-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.plan-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent-muted);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.plan-suggestion-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.plan-suggestion-info strong {
  color: var(--accent);
}

/* ========== Day Notes ========== */
.day-notes-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}

.day-notes-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color var(--transition);
}

.day-notes-header:hover {
  color: var(--text-primary);
}

.day-notes-preview {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  display: inline-block;
  vertical-align: bottom;
}

.day-notes-chevron {
  margin-left: auto;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.day-notes-chevron.open {
  transform: rotate(180deg);
}

.day-notes-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.day-notes-body.open {
  max-height: 1000px; /* Increased for tracking page with many parameters */
  padding: 0 1rem 1rem;
}

.day-notes-textarea {
  min-height: 80px;
  resize: vertical;
  font-size: 0.9rem;
}

.mt-05 {
  margin-top: 0.5rem;
}

/* ========== Supplement List ========== */
.supplement-list {
  display: flex;
  flex-direction: column;
}

.supplement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.supplement-item:last-child {
  border-bottom: none;
}

.supplement-item:hover {
  background: var(--bg-elevated);
}

.supplement-active .supplement-name::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 8px;
  box-shadow: 0 0 6px var(--success);
}

.supplement-stopped .supplement-name {
  color: var(--text-muted);
}

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

.supplement-name {
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
}

.supplement-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.supplement-dosage {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-weight: 600;
}

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

/* ========================================
   Tracking
   ======================================== */

.tracking-category {
  margin-bottom: 20px;
}

.tracking-cat-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.tracking-cat-subtitle {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 12px 0 6px;
}

.tracking-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 500px) {
  .tracking-grid {
    grid-template-columns: 1fr;
  }
}

.tracking-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.tracking-field label small {
  color: var(--text-muted);
  font-weight: 400;
}

.tracking-field input {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.tracking-param-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.tracking-param-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.tracking-param-item:last-child {
  border-bottom: none;
}

.tracking-param-name {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.tracking-param-unit {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-control-color {
  height: 38px;
  padding: 4px;
  cursor: pointer;
}

/* Weekday Selector */
.weekday-selector {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.weekday-cb {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.weekday-cb input {
  display: none;
}

.weekday-cb span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.weekday-cb input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ========================================
   Correlation Dashboard
   ======================================== */

.correlation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.correlation-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.correlation-toggle:hover {
  background: var(--bg-hover);
}

.correlation-toggle.active {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

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

/* ========== Admin Panel ========== */
.admin-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.admin-toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-admin {
  background: rgba(229, 57, 53, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(229, 57, 53, 0.3);
}

.badge-user {
  background: rgba(76, 154, 255, 0.15);
  color: #5ba4f5;
  border: 1px solid rgba(76, 154, 255, 0.3);
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.admin-table th {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
  background: var(--bg-hover);
}

.admin-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Admin modal (centered) */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  max-width: 440px;
  width: 90%;
  border: 1px solid var(--border);
}

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

.modal-content .modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

@media (max-width: 600px) {
  .admin-table th:nth-child(2),
  .admin-table td:nth-child(2) {
    display: none;
  }

  .admin-actions {
    flex-direction: column;
  }
}

/* ========== Toast Notifications ========== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

@media (max-width: 600px) {
  .toast-container {
    top: auto;
    bottom: calc(var(--bottom-nav-height) + 20px);
    right: 16px;
    left: 16px;
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 400px;
}

.toast.toast-hiding {
  animation: toastSlideOut 0.2s ease-in forwards;
}

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

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Toast variants */
.toast-success {
  background: linear-gradient(135deg, rgba(61, 214, 140, 0.15), rgba(61, 214, 140, 0.05));
  border-color: rgba(61, 214, 140, 0.3);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.3);
}

.toast-error .toast-icon {
  color: var(--danger);
}

.toast-warning {
  background: linear-gradient(135deg, rgba(255, 154, 61, 0.15), rgba(255, 154, 61, 0.05));
  border-color: rgba(255, 154, 61, 0.3);
}

.toast-warning .toast-icon {
  color: var(--accent-secondary);
}

.toast-info {
  background: linear-gradient(135deg, rgba(91, 164, 245, 0.15), rgba(91, 164, 245, 0.05));
  border-color: rgba(91, 164, 245, 0.3);
}

.toast-info .toast-icon {
  color: var(--info);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

@media (max-width: 600px) {
  .toast {
    max-width: none;
  }

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

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

/* ========================================
   Swipe Navigation
   ======================================== */
.swipe-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.swipe-indicator.visible {
  opacity: 1;
}

.swipe-indicator-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 28px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  transition: transform 0.1s ease, opacity 0.1s ease, border-color 0.2s ease, background 0.2s ease;
}

.swipe-indicator.ready .swipe-indicator-content {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.swipe-arrow {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  transition: color 0.2s ease;
  display: none;
}

.swipe-indicator.ready .swipe-arrow {
  color: var(--accent);
}

.swipe-indicator.left .swipe-arrow-right,
.swipe-indicator.right .swipe-arrow-left {
  display: block;
}

.swipe-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-height: 1.2em;
}

.swipe-indicator.ready .swipe-text {
  color: var(--accent);
}

/* Page transition animation */
.swipe-transition {
  animation: swipeOut 0.15s ease-out forwards;
}

.swipe-transition.swipe-next {
  animation-name: swipeOutLeft;
}

.swipe-transition.swipe-prev {
  animation-name: swipeOutRight;
}

@keyframes swipeOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

@keyframes swipeOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

/* Edge swipe hint (subtle gradient on edges) */
@media (hover: none) and (pointer: coarse) {
  .swipe-enabled::before,
  .swipe-enabled::after {
    content: '';
    position: fixed;
    top: 60px;
    bottom: 70px;
    width: 4px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .swipe-enabled::before {
    left: 0;
    background: linear-gradient(to right, var(--accent-muted), transparent);
  }

  .swipe-enabled::after {
    right: 0;
    background: linear-gradient(to left, var(--accent-muted), transparent);
  }

  .swipe-enabled:active::before,
  .swipe-enabled:active::after {
    opacity: 0.5;
  }
}

/* Accessibility - Screen Reader Only */
.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========== Premium Portion Slider ========== */
/* ========================================
   Portion Slider - Mobile-First Touch-Friendly
   ======================================== */
.portion-slider-container {
  padding: 16px 0 12px;
}

.portion-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.portion-slider-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.portion-slider-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  background: var(--accent-muted);
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid var(--border-accent);
}

.portion-slider-value input {
  width: 60px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
  text-align: right;
  outline: none;
  font-family: var(--font-mono);
}

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

.portion-slider-value input[type=number] {
  -moz-appearance: textfield;
}

.portion-slider-value .unit {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

.portion-slider-track {
  position: relative;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  touch-action: none;
}

/* Track background */
.portion-slider-track::before {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 12px;
  background: var(--bg-input);
  border-radius: 6px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.portion-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 56px;
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 1;
  touch-action: none;
}

/* WebKit (Chrome, Safari, Edge) Track */
.portion-slider::-webkit-slider-runnable-track {
  height: 12px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
  border-radius: 6px;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* WebKit Thumb - ALWAYS VISIBLE, LARGE FOR TOUCH */
.portion-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 40px;
  background: linear-gradient(145deg, var(--accent-hover) 0%, var(--accent) 100%);
  border-radius: 50%;
  border: 4px solid var(--bg-card);
  cursor: grab;
  margin-top: -14px;
  box-shadow:
    0 4px 12px rgba(var(--accent-rgb), 0.5),
    0 0 0 4px var(--accent-muted),
    inset 0 2px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.portion-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow:
    0 6px 20px rgba(var(--accent-rgb), 0.6),
    0 0 0 5px var(--accent-muted),
    inset 0 2px 0 rgba(255,255,255,0.25);
}

.portion-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.05);
}

/* Firefox Track */
.portion-slider::-moz-range-track {
  height: 12px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
  border-radius: 6px;
  box-shadow: 0 0 12px var(--accent-glow);
  border: none;
}

/* Firefox Thumb - ALWAYS VISIBLE, LARGE FOR TOUCH */
.portion-slider::-moz-range-thumb {
  width: 36px;
  height: 36px;
  background: linear-gradient(145deg, var(--accent-hover) 0%, var(--accent) 100%);
  border-radius: 50%;
  border: 4px solid var(--bg-card);
  cursor: grab;
  box-shadow:
    0 4px 12px rgba(var(--accent-rgb), 0.5),
    0 0 0 4px var(--accent-muted);
}

.portion-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* Preset Buttons */
.portion-slider-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  justify-content: center;
}

.portion-preset {
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 600;
  min-width: 48px;
  text-align: center;
}

.portion-preset:hover {
  background: var(--accent-muted);
  border-color: var(--border-accent);
  color: var(--accent);
}

.portion-preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

/* Serving preset buttons with text labels */
.portion-preset.serving-preset {
  font-size: 0.8rem;
  padding: 8px 12px;
  white-space: nowrap;
}

/* Portion ⇄ Gramm Umschalter (Scan-Produkt): segmentierte Auswahl */
.serving-toggle {
  display: flex;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 4px;
}
.serving-toggle-btn {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.serving-toggle-btn:hover {
  color: var(--accent);
}
.serving-toggle-btn.active {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

/* Mahlzeit-Slot-Auswahl beim Speichern eines Mahlzeit-Favoriten */
.slot-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text-primary);
}
.slot-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}


/* ========== Startseite v3 (Kundenskizze 18.07.2026): Ring + Aufschlüsselung ==========
   Ring links (Rest groß, Tagesbudget klein darunter), rechts die drei Budget-Bausteine.
   Bewusst zweispaltig auch auf dem Handy — die Skizze verlangt eine kompakte Kopfzeile. */
.cal-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

/* Bewusst groß + beschriftet (Harald 18.07.2026: „Kreis etwas größer, Werte
   benennen, Zahlen einen Ticken größer — vor allem den unteren"). */
.cal-hero-ring {
  width: 158px;
  height: 158px;
  flex-shrink: 0;
}

.cal-hero-ring .cal-remaining {
  font-size: 1.95rem;
}

/* Beschriftung der beiden Werte im Ring („Übrig heute" / „Ziel"). */
.cal-ring-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cal-ring-label + .cal-remaining { margin-top: -1px; }
.cal-remaining + .cal-ring-label { margin-top: 4px; }

/* Tagesziel unter der Rest-Zahl im Ring. */
.cal-budget {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.cal-breakdown {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cb-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.cb-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Makro-Boxen kompakt: müssen auch auf schmalen Handys EINZEILIG bleiben
   (Kunde: „kein Umbruch bei den Zahlen"). */
.macro-box-row-compact .macro-box {
  padding: 8px 6px;
  gap: 4px;
}

.macro-box-row-compact .macro-box-name {
  font-size: 0.62rem;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.macro-box-row-compact .macro-box-value {
  font-size: 0.72rem;
  white-space: nowrap;
}

@media (max-width: 380px) {
  .cal-hero { gap: 10px; }
  .cal-hero-ring { width: 132px; height: 132px; }
  .cal-hero-ring .cal-remaining { font-size: 1.6rem; }
  .cal-budget { font-size: 1rem; }
  .cal-ring-label { font-size: 0.55rem; }
  .cb-row { font-size: 0.82rem; }
  .macro-box-row-compact { gap: 6px; }
  .macro-box-row-compact .macro-box-value { font-size: 0.66rem; }
}

/* ========== Startseite v3: 7-/30-Tage-Bilanz (Soll / Ist / +-) ========== */
.period-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.period-table th,
.period-table td {
  padding: 7px 4px;
  text-align: right;
  white-space: nowrap;
}

.period-table thead th {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.period-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
}

.period-table td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.period-table .ps-until {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Seit der Vortags-Spalte (22.07.2026) hat die Tabelle VIER Spalten. Gemessen
   (22.07.2026, Chrome): Mindestbreite 234px bei 321px verfügbarem Platz auf einem
   360px-Handy — es braucht dafür KEINE eigene Mobil-Stufe. */
.period-table .ps-diff-row td { font-weight: 700; }
.period-table .ps-over  { color: var(--danger); }
.period-table .ps-under { color: var(--success); }

/* ---- Install-Hinweis (PWA) — nur im Browser auf dem Handy, siehe app.js ---- */
.install-hint {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  font-size: 0.9rem;
}
.install-hint[hidden], .install-hint [hidden] { display: none !important; } /* display:flex/.btn schlagen sonst das hidden-Attribut */
.install-hint-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; color: var(--text-secondary); }
.install-hint-text strong { color: var(--text-primary); }
.install-hint-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.4rem; line-height: 1;
  padding: 0.25rem 0.4rem; cursor: pointer; border-radius: 8px;
}
.install-hint-close:hover, .install-hint-close:focus-visible { color: var(--text-primary); background: var(--accent-muted); }

/* ---- Sprachschalter (Kopfzeile): beide Sprachen, aktive hervorgehoben ---- */
.lang-switch { display: inline-flex; border: 1px solid var(--border-light); border-radius: 8px; overflow: hidden; font-size: 0.75rem; font-weight: 700; }
.lang-switch .lang-opt { padding: 6px 8px; color: var(--text-muted); text-decoration: none; line-height: 1; }
.lang-switch .lang-opt.active { background: var(--accent); color: var(--on-accent); }
.lang-switch .lang-opt:not(.active):hover, .lang-switch .lang-opt:focus-visible { color: var(--text-primary); background: var(--accent-muted); }
