:root {
  --rianell-styles: 1; /* used by index.html to detect if this file loaded (mobile reload fix) */
  --primary-color: #4caf50;
  --primary-gradient: linear-gradient(135deg, #4caf50 0%, #66bb6a 50%, #81c784 100%);
  --primary-glow: 0 0 12px rgba(76, 175, 80, 0.25);
  --background-dark: #0a0a0a;
  --background-gradient: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
  --text-light: #e0f2f1;
  --card-bg: rgba(30, 30, 30, 0.8);
  --card-bg-glass: rgba(255, 255, 255, 0.05);
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --card-hover-shadow: 0 12px 40px rgba(76, 175, 80, 0.2);

  /* Design tokens: radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Design tokens: shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 2px var(--primary-color);

  /* Design tokens: spacing */
  --space-unit: 0.25rem;

  /* Light mode green gradient variables */
  --background-light: linear-gradient(135deg, #a8e6cf 0%, #c8e6c9 25%, #e8f5e8 75%, #f1f8e9 100%);
  --text-dark: #1b5e20;
  --text-secondary: #2e7d32;
  --card-bg-light: rgba(255, 255, 255, 0.95);
  --border-light: #81c784;

  /* Animation timings */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  /* Fluid feel: smooth ease-out for state changes */
  --ease-fluid: cubic-bezier(0.33, 1, 0.68, 1);
  --transition-fluid: 0.35s cubic-bezier(0.33, 1, 0.68, 1);
  --transition-fluid-slow: 0.45s cubic-bezier(0.33, 1, 0.68, 1);

  /* Type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --heading-sm: 1.1rem;
  --heading-md: 1.35rem;
  --heading-lg: 1.6rem;
  /* Section spacing */
  --section-gap: 1.5rem;
  /* Horizontal inset for content inside bordered cards / section bodies (form-section, accordions) */
  --card-content-padding-x: 1.25rem;

  /* Typography */
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --border-subtle: rgba(255, 255, 255, 0.1);
}

/* Skip link for keyboard/screen reader users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 10px;
  padding: 12px 20px;
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 100002;
  transition: top var(--transition-fast);
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
.skip-link:focus {
  top: 10px;
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Consistent focus ring for keyboard users */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[type="button"]:focus-visible,
[type="submit"]:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--background-gradient);
  background-attachment: fixed;
  color: var(--text-light);
  margin: 0;
  padding: 10px;
  line-height: 1.55;
  animation: fadeInPage 1s var(--ease-fluid);
  box-sizing: border-box;
  width: 100%;
  overflow-x: hidden;
  position: relative;
}

h1, h2, .section-heading, .tab-header h2, .ai-section-title, .tab-title, .settings-title {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.02em;
}

h2, .tab-header h2, .tab-title {
  font-weight: 600;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(76, 175, 80, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(76, 175, 80, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: backgroundPulse 8s ease-in-out infinite;
}

@keyframes backgroundPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Light mode styles */
body.light-mode {
  background: var(--background-light);
  color: var(--text-dark);
  --border-subtle: rgba(0, 0, 0, 0.08);
}

body.light-mode .container {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 0 20px rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(129, 199, 132, 0.3);
}

body.light-mode .container:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 0 30px rgba(76, 175, 80, 0.2);
}

body.light-mode input, 
body.light-mode textarea, 
body.light-mode select {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  color: var(--text-dark);
  border: 2px solid rgba(129, 199, 132, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.light-mode select option {
  background: rgba(255, 255, 255, 0.98) !important;
  color: var(--text-dark) !important;
}

body.light-mode .item-select {
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--text-dark) !important;
  border-color: rgba(129, 199, 132, 0.3);
}

body.light-mode .item-select option {
  background: rgba(255, 255, 255, 0.98) !important;
  color: var(--text-dark) !important;
}

body.light-mode input:focus, 
body.light-mode textarea:focus, 
body.light-mode select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2), 0 4px 12px rgba(76, 175, 80, 0.15);
  background: rgba(255, 255, 255, 1);
}

body.light-mode input:hover, 
body.light-mode textarea:hover, 
body.light-mode select:hover {
  border-color: rgba(76, 175, 80, 0.6);
  background: rgba(255, 255, 255, 0.95);
}

body.light-mode button {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

body.light-mode button:hover {
  background: linear-gradient(135deg, #388e3c, #4caf50);
}

body.light-mode .entry {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(129, 199, 132, 0.3);
  color: var(--text-dark);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

body.light-mode .entry:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.15), 0 0 30px rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.5);
}

body.light-mode .chart-container {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(129, 199, 132, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body.light-mode .chart-container:hover {
  box-shadow: 0 12px 40px rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.5);
}

body.light-mode .settings-menu,
body.light-mode .ai-modal,
body.light-mode .modal-content {
  background: var(--card-bg-light);
  border: 1px solid var(--border-light);
  color: var(--text-dark);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 20px rgba(76, 175, 80, 0.15);
}

body.light-mode .toggle-switch {
  background: #c8e6c9;
}

body.light-mode .toggle-switch.active {
  background: var(--primary-color);
}

body.light-mode .slider-label {
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4 {
  color: var(--text-dark);
}

body.light-mode label {
  color: var(--text-dark);
}

body.light-mode .form-section label,
body.light-mode .section-content label {
  color: var(--text-dark);
}

body.light-mode .settings-option label {
  color: var(--text-dark);
}

body.light-mode .ai-content {
  color: var(--text-dark);
}

body.light-mode .ai-modal-title,
body.light-mode .settings-title {
  color: var(--text-secondary);
}

/* Dark mode styles (default) */
body.dark-mode {
  background: var(--background-dark);
  color: var(--text-light);
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes aiModalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes modalFloatIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) translateY(0);
  }
}

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

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.8), 0 0 30px rgba(76, 175, 80, 0.6);
  }
}

.title-container {
  text-align: center;
  margin-bottom: 2.5rem;
  position: relative;
  animation: slideInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  padding-right: 60px; /* Space for settings button */
}

h1, h2 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 1rem;
  text-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
  transition: all var(--transition-normal);
}

h1:hover, h2:hover {
  text-shadow: 0 4px 20px rgba(76, 175, 80, 0.5);
  transform: scale(1.02);
}

/* Exclude dashboard title from general h1 styles */
h1#dashboardTitle {
  margin-bottom: 0.5rem;
  text-shadow: none; /* Remove default shadow, using custom one */
}

h1#dashboardTitle:hover {
  text-shadow: none; /* Use custom shadow from #dashboardTitle:hover */
}

#dashboardTitle {
  margin-bottom: 0.5rem;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  position: relative;
  display: inline-block;
  max-width: min(100%, 36rem);
  line-height: 1.25;
  hyphens: auto;
  overflow-wrap: break-word;
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 25%, #81c784 50%, #a5d6a7 75%, #c8e6c9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 100% 100%;
  text-shadow: 
    0 0 20px rgba(76, 175, 80, 0.5),
    0 0 40px rgba(76, 175, 80, 0.3),
    0 0 60px rgba(76, 175, 80, 0.2);
  filter: drop-shadow(0 0 10px rgba(76, 175, 80, 0.4));
  transition: transform 0.2s ease, filter 0.2s ease;
}

#dashboardTitle::before {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  background: linear-gradient(135deg, #4caf50 0%, #66bb6a 50%, #81c784 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: blur(15px);
  opacity: 0.6;
}

#dashboardTitle:hover {
  transform: scale(1.05);
  text-shadow: 
    0 0 30px rgba(76, 175, 80, 0.8),
    0 0 60px rgba(76, 175, 80, 0.5),
    0 0 90px rgba(76, 175, 80, 0.3);
  filter: drop-shadow(0 0 20px rgba(76, 175, 80, 0.6));
}

@media (max-width: 600px) {
  #dashboardTitle {
    font-size: 1.65rem;
    letter-spacing: 0.4px;
    max-width: 100%;
    padding: 0 0.25rem;
  }
}

.heartbeat-line {
  height: 60px;
  margin: 0 auto 1.5rem;
  width: 80%;
  max-width: 400px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heartbeat-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.heartbeat-path {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: heartbeatDraw 1.5s ease-in-out infinite;
}

@keyframes heartbeatDraw {
  0% { 
    stroke-dashoffset: 1200;
    opacity: 0.2;
  }
  10% {
    opacity: 0.8;
  }
  20% { 
    stroke-dashoffset: 900;
    opacity: 1;
  }
  30% {
    stroke-dashoffset: 700;
    opacity: 1;
  }
  40% {
    stroke-dashoffset: 500;
    opacity: 1;
  }
  50% {
    stroke-dashoffset: 300;
    opacity: 1;
  }
  60% {
    stroke-dashoffset: 100;
    opacity: 1;
  }
  70% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  75% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.7;
  }
  85% {
    opacity: 0.5;
  }
  90% {
    opacity: 0.3;
  }
  95% {
    opacity: 0.1;
  }
  100% { 
    stroke-dashoffset: 1200;
    opacity: 0;
  }
}

@keyframes ecgSpike {
  0%, 90%, 100% {
    opacity: 0;
    transform: translateX(0);
  }
  45% {
    opacity: 1;
    transform: translateX(0);
  }
  50% {
    opacity: 0.8;
    transform: translateX(2px);
  }
  55% {
    opacity: 0;
    transform: translateX(4px);
  }
}

.container {
  background: var(--card-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 25px 25px 10px 25px;
  border-radius: var(--radius-xl);
  max-width: 1000px;
  margin: auto;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-subtle);
  box-sizing: border-box;
  width: 100%;
  position: relative;
  z-index: 1;
  animation: slideInUp 0.6s var(--ease-fluid);
  transition: transform var(--transition-fluid), box-shadow var(--transition-fluid);
  overflow: visible; /* Ensure settings button is not clipped */
}

.container:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
}

/* App shell: full-height layout + bottom nav (mobile) */
.app-shell {
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

.app-main-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Bottom safe-area lives on .app-mobile-bottom-chrome (flex footer), not here */
  padding-bottom: 12px;
}

/* Bottom bar: mobile/tablet only — default hidden so desktop never stacks with top tabs */
.app-bottom-nav {
  display: none;
}

/* Sibling of .container inside .app-shell: desktop uses contents (FAB fixed); mobile = flex footer (not fixed) */
.app-mobile-bottom-chrome {
  display: contents;
}

@media (max-width: 768px) {
  .tab-navigation.tab-navigation--top {
    display: none !important;
  }

  /* One scroll region (.app-main-scroll) for every tab; shell + footer fill viewport.
     Do not subtract safe-area-inset-bottom from height — the bottom nav already pads for the home indicator;
     subtracting it left a dead band below the nav (empty strip matching the inset). */
  /* Match body content height (body has padding-top for safe area); 100dvh alone ignored that padding and caused gap + header overlap */
  .app-shell {
    height: calc(100dvh - 5px - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 5px - env(safe-area-inset-top, 0px));
    min-height: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
  }

  .app-mobile-bottom-chrome {
    display: block;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    /* Safe area is on .app-bottom-nav padding — avoid doubling inset below the tab bar */
    background: transparent;
  }

  /* FAB overlays .container; sits above tab bar (tab bar ~52px + padding + safe area) */
  .app-log-fab {
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    z-index: 1002;
  }

  .app-bottom-nav {
    display: flex;
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 2;
    isolation: isolate;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    /* Safe area only in padding-bottom — min-height must not add inset again (was double-counting, huge bar) */
    min-height: 52px;
    padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    padding-left: max(6px, env(safe-area-inset-left, 0px));
    padding-right: max(6px, env(safe-area-inset-right, 0px));
    background: rgba(14, 16, 20, 0.86);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
    -webkit-tap-highlight-color: transparent;
    border-radius: 0;
  }

  .app-bottom-nav-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    margin: 0; /* override "Enhanced mobile" `button { margin: 15px 0 }` — that was stretching the tab bar */
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    border: none;
    background: transparent;
    color: rgba(224, 242, 241, 0.55);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    border-radius: 14px;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition-fast), background var(--transition-fast), transform 0.15s ease;
  }

  /* Override global button:focus-visible green ring (var(--shadow-focus)) */
  .app-bottom-nav-btn:focus {
    outline: none;
  }

  .app-bottom-nav-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
  }

  .app-bottom-nav-btn:active {
    transform: scale(0.96);
  }

  .app-bottom-nav-btn[aria-current="page"],
  .app-bottom-nav-btn.active {
    color: #fff;
    background: rgba(76, 175, 80, 0.28);
    box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.35);
  }

  .app-bottom-nav-btn[aria-current="page"]:focus-visible,
  .app-bottom-nav-btn.active:focus-visible {
    box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.35), 0 0 0 2px rgba(255, 255, 255, 0.45);
  }

  .app-bottom-nav-icon {
    font-size: 1.45rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
  }

  .app-bottom-nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.15;
  }

  body.light-mode .app-bottom-nav {
    background: rgba(255, 255, 255, 0.92);
    border-top-color: rgba(129, 199, 132, 0.35);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.08);
  }

  body.light-mode .app-bottom-nav-btn {
    color: rgba(30, 60, 30, 0.72);
  }

  body.light-mode .app-bottom-nav-btn[aria-current="page"],
  body.light-mode .app-bottom-nav-btn.active {
    color: var(--text-dark);
    background: rgba(76, 175, 80, 0.22);
    box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.3);
  }

  body.light-mode .app-bottom-nav-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(30, 60, 30, 0.45);
  }

  body.light-mode .app-bottom-nav-btn[aria-current="page"]:focus-visible,
  body.light-mode .app-bottom-nav-btn.active:focus-visible {
    box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.3), 0 0 0 2px rgba(30, 60, 30, 0.45);
  }
}

/* Floating + : opens log wizard from any main tab (fixed; mobile bottom set in max-width 768px block) */
.app-log-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 1002;
  width: 56px;
  height: 56px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  color: #fff;
  background: var(--primary-gradient);
  box-shadow: var(--shadow-lg), 0 6px 24px rgba(76, 175, 80, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.app-log-fab:hover {
  filter: brightness(1.06);
}

.app-log-fab:active {
  transform: scale(0.94);
}

.app-log-fab.app-log-fab--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.88);
}

@media (min-width: 769px) {
  .app-log-fab {
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
}

body.light-mode .app-log-fab {
  box-shadow: 0 6px 22px rgba(46, 125, 50, 0.35);
}

/* Home / Today */
.home-today-header {
  margin-bottom: 1rem;
}

.home-today-sub {
  margin: 0.35rem 0 0 0;
  font-size: var(--text-sm);
  opacity: 0.85;
}

.home-today-status {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
  font-size: var(--text-base);
}

.home-today-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.home-primary-btn {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  color: #fff;
  background: var(--primary-gradient);
  box-shadow: var(--shadow-md), var(--primary-glow);
  transition: transform var(--transition-fluid), box-shadow var(--transition-fluid);
}

.home-primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 16px rgba(76, 175, 80, 0.35);
}

/* Log wizard */
#logTab.log-wizard-mode > .tab-header {
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}

#logTab.log-wizard-mode #logForm {
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}

@media (max-width: 768px) {
  #logTab.log-wizard-mode > .tab-header,
  #logTab.log-wizard-mode #logForm {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  /* Space for fixed wizard actions (see .log-wizard-sticky-actions below) */
  #logTab.log-wizard-mode #logForm {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }
}

/* Wizard: keep section titles visible so each card (Energy, Stress, Symptoms, etc.) is scannable */
#logTab.log-wizard-mode .section-header {
  display: flex;
  padding: 14px 16px;
  font-size: var(--text-base);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#logTab.log-wizard-mode .form-section {
  margin-bottom: 1rem;
}

#logTab.log-wizard-mode .log-wizard-step > .form-section:last-child {
  margin-bottom: 0;
}

body.light-mode #logTab.log-wizard-mode .section-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

#logTab.log-wizard-mode .section-content {
  max-height: none !important;
  opacity: 1 !important;
  padding: 0.5rem var(--card-content-padding-x) 1rem var(--card-content-padding-x);
  /* Allow <details> slot and tile grids to paint; overflow:hidden on .section-content can clip nested open details */
  overflow: visible !important;
}

#logTab.log-wizard-mode .section-content.open > * {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

.log-wizard-chrome {
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.log-wizard-step-indicator {
  margin: 0 0 10px 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: rgba(224, 242, 241, 0.9);
}

.log-wizard-progress-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.log-wizard-progress-fill {
  height: 100%;
  width: 12.5%;
  border-radius: 4px;
  background: var(--primary-gradient);
  transition: width var(--transition-fluid);
}

.log-wizard-steps {
  position: relative;
}

.log-wizard-step {
  display: none;
  animation: fadeInTab 0.35s var(--ease-fluid) forwards;
}

.log-wizard-step.log-wizard-step--active {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .log-wizard-step {
    animation: none;
  }
}

.log-review-summary {
  font-size: var(--text-base);
  line-height: 1.6;
  padding-left: var(--card-content-padding-x);
  padding-right: var(--card-content-padding-x);
  box-sizing: border-box;
}

.log-review-summary .log-review-line {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.log-review-summary .log-review-heading {
  font-weight: 700;
  margin-top: 12px;
  margin-bottom: 6px;
  color: rgba(76, 175, 80, 0.95);
}

/* Flat bar — no dark panel/shadow behind the row (content shows through) */
.log-wizard-sticky-actions {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 1.5rem;
  padding: 12px 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 768px) {
  /*
   * Sticky breaks inside .container.app-main-scroll (backdrop-filter creates a containing block).
   * Pin actions to the viewport above the bottom tab bar; #logForm padding-bottom reserves scroll space.
   */
  .log-wizard-sticky-actions {
    position: fixed;
    left: calc(18px + max(16px, env(safe-area-inset-left, 0px)));
    right: calc(18px + max(16px, env(safe-area-inset-right, 0px)));
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    width: auto;
    margin-top: 0;
    margin-bottom: 0;
    z-index: 1001;
    background: rgba(12, 14, 18, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.4);
    padding-top: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  body.light-mode .log-wizard-sticky-actions {
    background: rgba(248, 250, 252, 0.96);
    border-top-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.08);
  }
}

.log-wizard-back-btn,
.log-wizard-next-btn,
.log-wizard-skip-btn {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 12px 10px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-light);
  background: rgba(32, 36, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 0.12s ease;
}

.log-wizard-back-btn:hover,
.log-wizard-skip-btn:hover,
.log-wizard-next-btn:hover {
  box-shadow: none;
}

.log-wizard-back-btn:active,
.log-wizard-skip-btn:active,
.log-wizard-next-btn:active {
  transform: scale(0.98);
  box-shadow: none;
}

.log-wizard-back-btn:focus-visible,
.log-wizard-skip-btn:focus-visible,
.log-wizard-next-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.45);
}

.log-wizard-next-btn {
  background: rgba(76, 175, 80, 0.22);
  border-color: rgba(76, 175, 80, 0.5);
  color: #fff;
  box-shadow: none;
}

.log-wizard-next-btn:hover {
  box-shadow: none;
}

.log-wizard-skip-btn {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.22);
  opacity: 1;
}

.log-wizard-save-btn {
  width: 100%;
  flex: 1 1 100%;
  order: 10;
  padding: 14px 20px;
  font-size: 1rem;
  margin-top: 0;
}

.log-wizard-sticky-actions .log-wizard-save-btn:not([style*="display: none"]) {
  flex-basis: 100%;
}

/* Flat save button in wizard row — no drop shadow (global .save-entry-btn uses heavy glow) */
.log-wizard-sticky-actions .log-wizard-save-btn.save-entry-btn {
  margin-top: 4px !important;
  box-shadow: none !important;
}

.log-wizard-sticky-actions .log-wizard-save-btn.save-entry-btn:hover {
  box-shadow: none !important;
  transform: none !important;
}

.log-wizard-sticky-actions .log-wizard-save-btn.save-entry-btn:active {
  box-shadow: none !important;
  transform: none !important;
}

.log-wizard-sticky-actions .log-wizard-save-btn.save-entry-btn:focus,
.log-wizard-sticky-actions .log-wizard-save-btn.save-entry-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.45) !important;
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  position: relative;
  gap: calc(var(--space-unit) * 2);
  margin: 2rem 0;
  padding: calc(var(--space-unit) * 2);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-nav-indicator {
  position: absolute;
  bottom: calc(var(--space-unit) * 2);
  left: calc(var(--space-unit) * 2);
  height: 3px;
  border-radius: 2px;
  background: var(--primary-color);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
  transition: transform var(--transition-fluid), width var(--transition-fluid);
  pointer-events: none;
}

.tab-navigation::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  min-width: 100px;
  min-height: 48px;
  padding: 14px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: rgba(224, 242, 241, 0.6);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fluid), color var(--transition-fluid), transform var(--transition-fluid), border-color var(--transition-fluid), box-shadow var(--transition-fluid);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.tab-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  outline-offset: 2px;
}

.tab-btn::before {
  display: none; /* Remove the green line indicator */
}

.tab-btn:hover:not(.active) {
  background: rgba(76, 175, 80, 0.15);
  color: #ffffff;
  transform: translateY(-2px);
}

.tab-btn.active {
  background: rgba(76, 175, 80, 0.2);
  color: #ffffff;
  border: 2px solid rgba(76, 175, 80, 0.5);
  box-shadow: var(--shadow-sm), 0 0 8px rgba(76, 175, 80, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.tab-btn.active:hover {
  background: rgba(76, 175, 80, 0.15) !important;
  color: #ffffff !important;
  border-color: rgba(76, 175, 80, 0.8) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
  transform: translateY(-2px);
  box-shadow: 0 0 12px rgba(76, 175, 80, 0.35), inset 0 0 8px rgba(76, 175, 80, 0.08) !important;
}

.tab-btn.active::before {
  display: none; /* Remove the green line indicator */
}

.tab-icon {
  font-size: 1.5rem;
  transition: transform var(--transition-fluid);
}

.tab-btn:hover:not(.active) .tab-icon {
  transform: scale(1.1);
}

.tab-btn.active .tab-icon {
  transform: scale(1.1);
}

.tab-text {
  font-size: 0.85rem;
  transition: color var(--transition-fluid);
}

.tab-btn.active .tab-text {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tab-btn.active:hover .tab-text {
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Tab Content */
.tab-content {
  display: none;
  padding-bottom: 10px;
  margin-bottom: 0;
}

.tab-content.tab-content--leave {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.18s var(--ease-fluid), transform 0.18s var(--ease-fluid);
}

.tab-content.active {
  display: block !important;
  visibility: visible !important;
  padding-bottom: 10px;
  margin-bottom: 0;
  animation: fadeInTab 0.4s var(--ease-fluid) forwards;
}

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

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}


.tab-header h2 {
  margin: 0;
  font-size: 1.8rem;
}

.tab-description {
  color: rgba(224, 242, 241, 0.85);
  margin: 0.5rem 0 0 0;
  font-size: var(--text-lg);
  line-height: 1.65;
}

.tab-title {
  font-size: var(--heading-md);
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-light);
}

.section-heading {
  font-size: var(--heading-sm);
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--text-light);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tab-filters {
  margin-bottom: 0;
}

.tab-filters + .tab-content-section {
  margin-top: var(--section-gap);
  padding-top: var(--section-gap);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tab-content-section {
  margin-top: 0;
}

.tab-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  padding: 10px 18px;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: var(--radius-md);
  color: var(--primary-color);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fluid), border-color var(--transition-fluid), color var(--transition-fluid), transform var(--transition-fluid), box-shadow var(--transition-fluid);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: auto;
  width: auto;
  margin: 0;
}

.action-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.action-btn:hover {
  background: rgba(76, 175, 80, 0.2);
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.action-btn.ai-action-btn {
  background: rgba(233, 30, 99, 0.1);
  border-color: rgba(233, 30, 99, 0.3);
  color: rgba(233, 30, 99, 0.9);
  /* Red pulsing glow on idle */
  animation: aiSummaryRedPulse 2s ease-in-out infinite;
}

.action-btn.ai-action-btn:hover:not(.disabled):not(:disabled) {
  background: rgba(233, 30, 99, 0.2);
  border-color: rgba(233, 30, 99, 0.5);
  color: #e91e63;
  box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
  /* Stop pulsing on hover */
  animation: none;
}

.action-btn.ai-action-btn.disabled,
.action-btn.ai-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: none;
  background: rgba(233, 30, 99, 0.05);
  border-color: rgba(233, 30, 99, 0.1);
  color: rgba(233, 30, 99, 0.4);
}

.chart-view-toggle {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.view-toggle-btn {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(224, 242, 241, 0.6);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: auto;
  width: auto;
  margin: 0;
}

.view-toggle-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.view-toggle-btn:hover {
  background: rgba(76, 175, 80, 0.1);
  color: var(--text-light);
}

.view-toggle-btn.active {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* Date Range Filter */
.chart-date-range-filter {
  margin: 15px 0;
  padding: 0;
  background: transparent;
}

.filter-row {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: var(--text-xs);
  color: rgba(224, 242, 241, 0.8);
  font-weight: 500;
  white-space: nowrap;
}

/* Mobile-only labels - hidden on desktop */
.filter-label-mobile {
  display: none;
}

.date-range-buttons,
.prediction-range-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
}

.date-range-btn,
.prediction-range-btn {
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 3);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: rgba(224, 242, 241, 0.7);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fluid), border-color var(--transition-fluid), color var(--transition-fluid), box-shadow var(--transition-fluid);
  white-space: nowrap;
  min-width: auto;
}

.date-range-btn:focus-visible,
.prediction-range-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Make Tomorrow button wider to fit text */
#predRange1Day {
  min-width: 70px;
  padding: 4px 10px;
}

/* Style Off button with red shades - override default prediction button styles */
#predictionToggle {
  background: rgba(244, 67, 54, 0.1) !important;
  border-color: rgba(244, 67, 54, 0.3) !important;
  color: rgba(255, 183, 77, 0.9) !important;
}

#predictionToggle:hover {
  background: rgba(244, 67, 54, 0.2) !important;
  border-color: rgba(244, 67, 54, 0.5) !important;
  color: rgba(255, 183, 77, 1) !important;
}

#predictionToggle.active {
  background: #f44336 !important; /* Solid red fill */
  color: white !important;
  border-color: rgba(244, 67, 54, 0.8) !important;
  box-shadow: 0 0 15px rgba(244, 67, 54, 0.6), 0 0 25px rgba(244, 67, 54, 0.4), 0 2px 8px rgba(244, 67, 54, 0.3) !important; /* Red glow effect */
  font-weight: 700;
}

.date-range-btn:hover {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
  color: var(--text-light);
}

.date-range-btn.active {
  background: #4caf50; /* Solid green fill */
  color: white;
  border-color: rgba(76, 175, 80, 0.8);
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.6), 0 0 25px rgba(76, 175, 80, 0.4), 0 2px 8px rgba(76, 175, 80, 0.3); /* Green glow effect */
}

.log-view-range-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 0;
  width: 100%;
}

.log-date-range-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
}

.log-date-range-btn {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: rgba(224, 242, 241, 0.7);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fluid), border-color var(--transition-fluid), color var(--transition-fluid), transform var(--transition-fluid);
  white-space: nowrap;
  min-width: auto;
  margin: 0;
  box-shadow: none;
}

.log-date-range-btn:hover {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
  color: var(--text-light);
  box-shadow: none;
}

.log-date-range-btn.active {
  background: #4caf50; /* Solid green fill */
  color: white;
  border-color: rgba(76, 175, 80, 0.8);
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.6), 0 0 25px rgba(76, 175, 80, 0.4), 0 2px 8px rgba(76, 175, 80, 0.3); /* Green glow effect */
}

.log-date-range-btn.active:hover {
  background: #4caf50; /* Solid green fill */
  color: white;
  border-color: rgba(76, 175, 80, 0.9);
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.7), 0 0 30px rgba(76, 175, 80, 0.5), 0 2px 8px rgba(76, 175, 80, 0.3); /* Stronger glow on hover */
}

.log-date-range-btn:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(76, 175, 80, 0.2);
}

.log-date-range-btn.active:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(76, 175, 80, 0.4);
}

.prediction-range-btn {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
  color: rgba(255, 235, 59, 0.8);
}

.prediction-range-btn:hover {
  background: rgba(255, 193, 7, 0.2);
  border-color: rgba(255, 193, 7, 0.5);
  color: #ffeb3b;
}

.prediction-range-btn.active {
  background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
  color: #1a1a1a;
  border-color: rgba(255, 193, 7, 0.8);
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
  font-weight: 700;
}

.custom-date-range {
  margin-top: 12px;
  padding: 12px;
  background: rgba(28, 28, 28, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.custom-date-range label {
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.9rem;
}

.custom-date-range input[type="date"] {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--text-light);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.custom-date-range input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.custom-date-range input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.custom-date-range.hidden {
  display: none;
}

/* Summary Tab Styles */
.summary-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.summary-card {
  background: var(--card-bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: var(--card-shadow);
  transition: all var(--transition-normal);
  animation: scaleIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.summary-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-hover-shadow);
  border-color: rgba(76, 175, 80, 0.3);
}

.summary-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

.summary-card h3 {
  color: var(--primary-color);
  margin: 1rem 0;
  font-size: 1.5rem;
}

.summary-card p {
  color: rgba(224, 242, 241, 0.8);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.summary-btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: auto;
  width: auto;
  margin: 0;
}

.summary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4), var(--primary-glow);
}

.summary-info {
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  color: rgba(224, 242, 241, 0.9);
  line-height: 1.6;
}

.summary-description {
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  color: rgba(224, 242, 241, 0.9);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.summary-generate-btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: auto;
  width: auto;
  margin: 0;
}

.summary-generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4), var(--primary-glow);
}

/* ============================================
   AI SUMMARY - REBUILT STYLES
   ============================================ */

.ai-tip-box {
  background: rgba(233, 30, 99, 0.1);
  border: 1px solid rgba(233, 30, 99, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  color: rgba(224, 242, 241, 0.9);
  line-height: 1.6;
}

.ai-generate-button {
  background: linear-gradient(135deg, #e91e63, #f06292);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 1.5rem 0;
}

.ai-generate-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4), 0 0 20px rgba(233, 30, 99, 0.3);
  background: linear-gradient(135deg, #c2185b, #e91e63);
}

.ai-results-container {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
  display: none;
  position: relative;
  z-index: 1;
  /* Glassmorphism - ensure it doesn't block content */
  background: var(--card-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 20px;
  border: 2px solid rgba(233, 30, 99, 0.3);
  box-shadow: 0 8px 24px rgba(233, 30, 99, 0.2), 0 0 20px rgba(233, 30, 99, 0.1);
  transition: opacity 0.3s ease;
  animation: fadeInUp 0.5s ease-out;
  /* Force visibility when shown - override any glassmorphism issues */
  opacity: 1;
  visibility: visible;
  /* Ensure content is not clipped */
  overflow: visible;
}

/* Show when JavaScript sets display: block */
.ai-results-container[style*="display: block"] {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(20px)) {
  .ai-results-container {
    background: rgba(30, 30, 30, 0.95);
  }
}

/* Loading State */
.ai-loading-state {
  text-align: center;
  padding: 3rem;
  color: rgba(224, 242, 241, 0.7);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ai-loading-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: aiLoadingPulse 1.8s ease-in-out infinite;
}

@keyframes aiLoadingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.ai-loading-text {
  font-size: 1.1rem;
  margin: 0;
  color: rgba(224, 242, 241, 0.9);
}

.ai-loading-subtext {
  font-size: 0.9rem;
  margin: 0.5rem 0 0 0;
  opacity: 0.7;
}

.ai-results-heading {
  font-size: var(--heading-md);
  font-weight: 600;
  color: var(--text-light);
  margin: 0 0 1.25rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(233, 30, 99, 0.25);
}

.ai-empty-title {
  font-size: var(--heading-sm);
  font-weight: 600;
  color: rgba(224, 242, 241, 0.95);
  margin: 0 0 0.5rem 0;
}

.ai-empty-desc {
  font-size: var(--text-base);
  line-height: 1.6;
  color: rgba(224, 242, 241, 0.8);
  margin: 0;
}

/* AI button loading state (spinner + "Analyzing…") */
.action-btn.ai-action-btn.ai-button-loading {
  cursor: wait;
  opacity: 0.9;
}

.ai-button-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aiButtonSpin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 0.35em;
}

@keyframes aiButtonSpin {
  to { transform: rotate(360deg); }
}

.ai-loading-note {
  font-size: 0.85rem;
  margin: 1rem 0 0 0;
  opacity: 0.6;
  font-style: italic;
}

.ai-progress-container {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 4px;
  margin: 1rem auto;
  overflow: hidden;
  position: relative;
}

.ai-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #66bb6a);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.ai-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* Summary Header */
.ai-summary-header {
  background: rgba(233, 30, 99, 0.1);
  border: 1px solid rgba(233, 30, 99, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.ai-summary-header h3 {
  color: #e91e63;
  margin: 0;
  font-size: 1.2rem;
}

.ai-summary-header p {
  color: rgba(224, 242, 241, 0.8);
  margin: 0.5rem 0 0 0;
}

#aiResultsContent {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: fit-content;
}

/* Summary Sections */
.ai-summary-section {
  background: rgba(233, 30, 99, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: var(--section-gap);
  border: 1px solid rgba(233, 30, 99, 0.2);
  box-shadow: var(--shadow-sm);
  /* Animation will be applied via .ai-animate-in class */
  line-height: 1.7;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ai-summary-section:hover {
  border-color: rgba(233, 30, 99, 0.28);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(233, 30, 99, 0.1);
}

.ai-summary-section.ai-section-warning {
  background: rgba(40, 40, 40, 0.7);
  border: 1px solid rgba(255, 152, 0, 0.5);
  border-left-width: 4px;
}

.ai-summary-section.ai-section-info {
  background: rgba(233, 30, 99, 0.1);
  border: 1px solid rgba(233, 30, 99, 0.3);
}

.ai-section-title {
  color: #e91e63;
  margin: 0 0 1.5rem 0;
  font-size: var(--heading-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid rgba(233, 30, 99, 0.3);
}

.ai-section-title.ai-section-blue {
  color: #2196f3;
}

.ai-section-title.ai-section-orange {
  color: #ffb74d;
}

.ai-section-title.ai-section-pink {
  color: #e91e63;
}

.ai-section-title.ai-section-green {
  color: #4caf50;
}

/* Stat pills: visual "what you logged" grid */
.ai-stat-pills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.ai-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-sm);
}

.ai-stat-pill-icon {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.ai-stat-pill-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-light);
}

.ai-stat-pill-label {
  font-size: 0.7rem;
  color: rgba(224, 242, 241, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Trend cards: compact value layout */
.ai-trend-values {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.ai-trend-value {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ai-trend-value-label {
  font-size: 0.7rem;
  color: rgba(224, 242, 241, 0.6);
  text-transform: uppercase;
}

.ai-trend-badge {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Flare-up: visual level + dots */
.ai-flare-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.ai-flare-level {
  font-size: 1.1rem;
  text-transform: capitalize;
}

.ai-flare-dots {
  display: flex;
  gap: 0.35rem;
}

.ai-flare-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s;
}

.ai-flare-dot.active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.ai-flare-hint {
  font-size: 0.8rem;
  color: rgba(224, 242, 241, 0.7);
  margin: 0;
}

/* Pain body legend: color dots */
.ai-pain-body-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.ai-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.2rem;
  vertical-align: middle;
}

.ai-legend-dot.green { background: rgba(76, 175, 80, 0.7); }
.ai-legend-dot.yellow { background: rgba(255, 193, 7, 0.8); }
.ai-legend-dot.red { background: rgba(244, 67, 54, 0.7); }

/* Nutrition: big numbers */
.ai-nutrition-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  align-items: baseline;
  margin-top: 0.25rem;
}

.ai-nutrition-main {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.ai-nutrition-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-light);
}

.ai-nutrition-unit {
  font-size: 0.9rem;
  color: rgba(224, 242, 241, 0.7);
}

.ai-nutrition-extra {
  font-size: 0.8rem;
  color: rgba(224, 242, 241, 0.6);
  margin: 0.5rem 0 0 0;
}

/* Exercise: prominent value */
.ai-exercise-visual {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-top: 0.25rem;
}

.ai-exercise-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-light);
}

.ai-exercise-unit {
  font-size: 0.95rem;
  color: rgba(224, 242, 241, 0.8);
}

.ai-exercise-days {
  font-size: 0.85rem;
  color: rgba(224, 242, 241, 0.6);
  margin-left: 0.25rem;
}

/* Pain by body part: figure with labels on human body */
.ai-pain-body-figure-wrap {
  margin-bottom: 1.25rem;
}

.ai-pain-body-figure {
  display: inline-block;
  max-width: 200px;
  margin: 0 auto 0.5rem 0;
}

.ai-pain-body-svg {
  width: 100%;
  height: auto;
  display: block;
  color: rgba(255, 255, 255, 0.12);
}

.ai-pain-region-low {
  color: rgba(76, 175, 80, 0.35);
  stroke: rgba(76, 175, 80, 0.85);
  stroke-width: 2.5px;
  filter: url(#ai-pain-body-shadow) drop-shadow(0 0 6px rgba(76, 175, 80, 0.5));
}

.ai-pain-region-medium {
  color: rgba(255, 193, 7, 0.55);
  stroke: rgba(255, 152, 0, 0.85);
  stroke-width: 2.5px;
  filter: url(#ai-pain-body-shadow) drop-shadow(0 0 6px rgba(255, 152, 0, 0.5));
}

.ai-pain-region-high {
  color: rgba(244, 67, 54, 0.5);
  stroke: rgba(244, 67, 54, 0.9);
  stroke-width: 2.5px;
  filter: url(#ai-pain-body-shadow) drop-shadow(0 0 6px rgba(244, 67, 54, 0.5));
}

.ai-pain-body-label {
  fill: rgba(224, 242, 241, 0.95);
  font-family: inherit;
  font-weight: 600;
  pointer-events: none;
}

.ai-pain-body-legend {
  color: rgba(224, 242, 241, 0.8);
  font-size: var(--text-sm);
  margin: 0 0 0 0;
}

body.light-mode .ai-pain-body-svg {
  color: rgba(0, 0, 0, 0.08);
}

body.light-mode .ai-pain-region-low {
  color: rgba(76, 175, 80, 0.4);
}

body.light-mode .ai-pain-region-medium {
  color: rgba(255, 193, 7, 0.6);
}

body.light-mode .ai-pain-region-high {
  color: rgba(244, 67, 54, 0.5);
}

body.light-mode .ai-pain-body-label {
  fill: var(--text-dark);
}

body.light-mode .ai-pain-body-legend {
  color: var(--text-dark);
}

/* Pain by body part table and severity badges */
.ai-pain-table-wrap {
  margin-top: 0.5rem;
}

.ai-pain-table th {
  color: rgba(224, 242, 241, 0.9);
  font-weight: 600;
}

.ai-pain-table td {
  color: rgba(224, 242, 241, 0.85);
}

.ai-pain-severity-high {
  background: rgba(244, 67, 54, 0.25);
  color: #ff8a80;
  border: 2.5px solid rgba(244, 67, 54, 0.65);
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.5), 0 0 14px rgba(244, 67, 54, 0.35);
}

.ai-pain-severity-medium {
  background: rgba(255, 152, 0, 0.2);
  color: #ffb74d;
  border: 2.5px solid rgba(255, 152, 0, 0.65);
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.5), 0 0 14px rgba(255, 152, 0, 0.35);
}

.ai-pain-severity-low {
  background: rgba(76, 175, 80, 0.2);
  color: #81c784;
  border: 2.5px solid rgba(76, 175, 80, 0.65);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.5), 0 0 14px rgba(76, 175, 80, 0.35);
}

/* Trends Grid */
.ai-trends-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: start; /* Align items to start so they don't stretch */
}

.ai-trend-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 1.25rem;
  border-radius: 12px;
  border-left: 4px solid #e91e63;
  transition: all 0.3s;
  margin-bottom: 0.75rem;
  cursor: pointer;
  align-self: start; /* Prevent card from stretching when content expands */
  min-height: fit-content; /* Allow card to grow with content */
}

.ai-trend-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(4px);
}

.metric-radar-chart-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    max-height: 1000px;
    transform: translateY(0);
  }
}

.ai-trend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ai-trend-header strong {
  color: var(--text-light);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.ai-trend-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  color: rgba(224, 242, 241, 0.9);
  font-size: 0.95rem;
  margin-top: 0.75rem;
}

.ai-trend-stats span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: fit-content;
}

.ai-trend-stats strong {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Lists */
.ai-list {
  margin: 0;
  padding-left: 1.5rem;
  color: rgba(224, 242, 241, 0.95);
  line-height: 2;
  font-size: 1rem;
}

.ai-list li {
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.ai-list-warning {
  color: rgba(224, 242, 241, 0.95);
  margin-top: 0.5rem;
}

.ai-list-warning li {
  margin-bottom: 1rem;
  line-height: 1.6;
}

.ai-list-warning .ai-warning-metric {
  font-weight: 600;
  color: #ffb74d;
}

.ai-list-warning .ai-warning-note {
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.65);
  font-style: italic;
}

/* Advice Cards */
.ai-advice-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-advice-card {
  background: rgba(233, 30, 99, 0.1);
  padding: 1rem;
  border-radius: 8px;
  border-left: 3px solid #e91e63;
  transition: all 0.3s;
}

.ai-advice-card:hover {
  background: rgba(233, 30, 99, 0.15);
  transform: translateX(4px);
}

.ai-advice-card p {
  margin: 0;
  color: rgba(224, 242, 241, 0.9);
  line-height: 1.6;
}

/* Disclaimer */
.ai-disclaimer {
  margin: 0;
  color: rgba(224, 242, 241, 0.95);
  line-height: 1.7;
  font-size: var(--text-base);
}

/* AI LLM Synopsis/Insights Text */
.ai-llm-synopsis {
  color: rgba(224, 242, 241, 0.95);
  line-height: 1.7;
  font-size: var(--text-base);
}

.ai-llm-synopsis p {
  margin: 0 0 1rem 0;
  padding: 0.5rem 0;
  line-height: 1.65;
}

.ai-llm-synopsis p:last-child {
  margin-bottom: 0;
}

.ai-llm-synopsis strong {
  color: #81c784;
  font-weight: 600;
  font-size: 1.05rem;
}

.ai-llm-synopsis .ai-brackets-highlight {
  color: #81c784;
  font-weight: 600;
  background: rgba(76, 175, 80, 0.15);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Same value highlight in all AI summary sections (Stress, Symptoms, Pain, Top foods, etc.) */
#aiResultsContent .ai-brackets-highlight {
  color: #e91e63;
  font-weight: 600;
  background: rgba(233, 30, 99, 0.15);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

body.light-mode #aiResultsContent .ai-brackets-highlight {
  color: #2e7d32;
  background: rgba(76, 175, 80, 0.2);
}

.ai-generated-note {
  margin: 0 0 0.75rem 0;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  line-height: 1.6;
  font-size: var(--text-base);
}

.ai-copy-note-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.5);
  background: rgba(76, 175, 80, 0.2);
  color: #81c784;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.ai-copy-note-btn:hover {
  background: rgba(76, 175, 80, 0.35);
  border-color: #4caf50;
}

.suggest-note-btn {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid rgba(33, 150, 243, 0.5);
  background: rgba(33, 150, 243, 0.15);
  color: #64b5f6;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.suggest-note-btn:hover {
  background: rgba(33, 150, 243, 0.3);
  border-color: #2196f3;
}

.ai-bullet-point {
  margin-left: 1rem !important;
  padding-left: 0.5rem;
  border-left: 2px solid rgba(76, 175, 80, 0.3);
}

.ai-subsection-title {
  color: #66bb6a;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(76, 175, 80, 0.2);
}

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

/* AI Summary Animation Classes */
/* When device is low-power or user prefers reduced motion, show content immediately */
.reduce-motion .ai-animate-in,
.reduce-motion .ai-trend-card.ai-animate-in,
.reduce-motion .ai-list li.ai-animate-in,
.reduce-motion .ai-advice-card.ai-animate-in,
.reduce-motion .ai-summary-header.ai-animate-in {
  opacity: 1;
  animation: none;
  transform: none;
}

.ai-animate-in {
  opacity: 0;
  animation: aiSlideInFade 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes aiSlideInFade {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered animation for trend cards */
.ai-trend-card.ai-animate-in {
  animation: aiCardPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes aiCardPopIn {
  0% {
    opacity: 0;
    transform: translateX(-20px) scale(0.9);
  }
  50% {
    transform: translateX(5px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Staggered animation for list items */
.ai-list li.ai-animate-in {
  animation: aiListItemSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Staggered animation for advice cards */
.ai-advice-card.ai-animate-in {
  animation: aiAdviceCardSlide 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes aiAdviceCardSlide {
  from {
    opacity: 0;
    transform: translateY(20px) rotateX(-10deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* Header animation with bounce */
.ai-summary-header.ai-animate-in {
  animation: aiHeaderBounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes aiHeaderBounce {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
  }
  50% {
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Light Mode */
body.light-mode .ai-tip-box {
  background: rgba(233, 30, 99, 0.15);
  border-color: rgba(233, 30, 99, 0.3);
  color: var(--text-dark);
}

body.light-mode .ai-summary-section {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(233, 30, 99, 0.3);
}

body.light-mode .ai-summary-section.ai-section-warning {
  background: rgba(255, 248, 225, 0.95);
  border-color: rgba(255, 152, 0, 0.5);
}

body.light-mode .ai-list-warning {
  color: var(--text-dark);
}

body.light-mode .ai-list-warning .ai-warning-metric {
  color: #e65100;
}

body.light-mode .ai-list-warning .ai-warning-note {
  color: rgba(0, 0, 0, 0.55);
}

body.light-mode .ai-stat-pill {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .ai-trend-card {
  background: rgba(0, 0, 0, 0.05);
}

body.light-mode .ai-advice-card {
  background: rgba(233, 30, 99, 0.15);
}

body.light-mode .ai-list {
  color: var(--text-dark);
}

body.light-mode .ai-disclaimer {
  color: var(--text-dark);
}


.ai-results-textbox {
  width: 100%;
  min-height: 400px;
  max-height: 50vh;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: var(--text-light);
  font-size: 0.95rem;
  font-family: 'Courier New', monospace;
  line-height: 1.8;
  resize: vertical;
  transition: all var(--transition-normal);
  box-sizing: border-box;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  overflow-y: auto;
}

.ai-results-textbox:focus {
  outline: none;
  border-color: #e91e63;
  box-shadow: 0 0 0 4px rgba(233, 30, 99, 0.2), 0 0 20px rgba(233, 30, 99, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.ai-results-textbox::placeholder {
  color: rgba(224, 242, 241, 0.4);
  font-style: italic;
}

body.light-mode .ai-results-textbox {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(129, 199, 132, 0.3);
  color: var(--text-dark);
}

body.light-mode .ai-results-textbox:focus {
  border-color: #e91e63;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 4px rgba(233, 30, 99, 0.2), 0 0 20px rgba(233, 30, 99, 0.3);
}

body.light-mode .ai-results-textbox::placeholder {
  color: rgba(27, 94, 32, 0.4);
}

body.light-mode .ai-modal-description {
  background: rgba(233, 30, 99, 0.15);
  border-color: rgba(233, 30, 99, 0.3);
  color: var(--text-dark);
}

body.light-mode .ai-modal-content {
  background: var(--card-bg-light);
  border-color: var(--border-light);
}

body.light-mode .ai-modal-title {
  color: #e91e63;
  -webkit-text-fill-color: #e91e63;
}

body.light-mode .ai-modal-close {
  color: var(--text-dark);
}

body.light-mode .ai-modal-close:hover {
  color: #e91e63;
}

body.light-mode .tab-btn.ai-tab-btn:hover:not(.active) {
  background: rgba(233, 30, 99, 0.2);
  border-color: rgba(233, 30, 99, 0.4);
}

body.light-mode .tab-btn.ai-tab-btn.active {
  background: rgba(233, 30, 99, 0.15);
  border-color: rgba(233, 30, 99, 0.5);
}

.save-entry-btn {
  margin-top: 1.5rem;
  margin-bottom: 0;
  background: rgba(55, 71, 79, 0.8) !important; /* Dark gray background */
  color: var(--primary-color) !important; /* Green text */
  border: 1px solid rgba(76, 175, 80, 0.3) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

.save-entry-btn:hover {
  background: rgba(55, 71, 79, 0.95) !important;
  color: #66bb6a !important; /* Lighter green on hover */
  border-color: rgba(76, 175, 80, 0.5) !important;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.2), 0 0 15px rgba(76, 175, 80, 0.1) !important;
  transform: translateY(-2px);
}

.save-entry-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.save-entry-btn:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.3), 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

.save-entry-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.save-entry-btn::before {
  background: rgba(76, 175, 80, 0.1) !important; /* Subtle green ripple */
}

/* Light mode styles for save entry button */
body.light-mode .save-entry-btn {
  background: rgba(224, 224, 224, 0.9) !important; /* Light gray background */
  color: #2e7d32 !important; /* Darker green text for better contrast */
  border-color: rgba(76, 175, 80, 0.4) !important;
}

body.light-mode .save-entry-btn:hover {
  background: rgba(200, 200, 200, 0.95) !important;
  color: #388e3c !important;
  border-color: rgba(76, 175, 80, 0.6) !important;
}

/* Collapsible Form Sections */
.form-section {
  margin-bottom: var(--section-gap);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--transition-normal);
}

/* Remove bottom spacing from last elements in tabs (but keep tab-content padding) */
.tab-content .form-section:last-child,
.tab-content .entry:last-child,
.tab-content .chart-container:last-child,
.tab-content .save-entry-btn:last-child,
#output > *:last-child,
#individualChartsContainer > *:last-child,
#combinedChartContainer:last-child {
  margin-bottom: 0 !important;
}

/* Tab content containers have 10px bottom padding to prevent content cutoff */
#output,
#individualChartsContainer,
#combinedChartContainer {
  margin-bottom: 0 !important;
}

.form-section:hover {
  border-color: rgba(76, 175, 80, 0.2);
  background: rgba(255, 255, 255, 0.03);
}

/* AI Analysis section specific styling - pink/magenta theme */
.form-section.ai-analysis-section {
  border-color: rgba(233, 30, 99, 0.2);
  background: rgba(233, 30, 99, 0.03);
}

.form-section.ai-analysis-section:hover {
  border-color: rgba(233, 30, 99, 0.3);
  background: rgba(233, 30, 99, 0.05);
}

.form-section.ai-analysis-section .section-header {
  color: rgba(233, 30, 99, 0.9);
}

.form-section.ai-analysis-section .section-header:hover {
  background: rgba(233, 30, 99, 0.1);
  color: #e91e63;
}

.section-header {
  width: 100%;
  padding: 18px 20px;
  background: rgba(76, 175, 80, 0.05);
  border: none;
  border-radius: 0;
  color: var(--text-light);
  font-size: var(--heading-sm);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color var(--transition-fluid), color var(--transition-fluid);
  text-align: left;
  min-height: auto;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.section-header:hover {
  background: rgba(76, 175, 80, 0.1);
  color: var(--primary-color);
}

.section-header:active {
  background: rgba(76, 175, 80, 0.15);
  transition-duration: 0.15s;
}

.section-icon {
  font-size: 1.3rem;
  transition: transform var(--transition-fluid);
  will-change: transform;
}

.section-header:hover .section-icon {
  transform: scale(1.1);
}

.section-header:active .section-icon {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* Disable hover animations on touch devices */
@media (hover: none) and (pointer: coarse) {
  .section-header:hover {
    background: rgba(76, 175, 80, 0.05);
    color: var(--text-light);
  }
  
  .section-header:hover .section-icon {
    transform: scale(1);
  }
  
  body.light-mode .section-header:hover {
    background: rgba(76, 175, 80, 0.05);
    color: var(--text-light);
  }
}

.section-title {
  flex: 1;
}

.optional-hint {
  font-size: var(--text-sm);
  font-weight: 400;
  color: rgba(224, 242, 241, 0.75);
  font-style: italic;
  margin-left: 4px;
}

.field-hint {
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.75);
  margin: 0.25rem 0 0.5rem 0;
  line-height: 1.4;
}

.tab-filters .field-hint,
.filter-row .field-hint {
  width: 100%;
  flex-basis: 100%;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.section-arrow {
  font-size: 0.9rem;
  transition: transform var(--transition-fluid-slow);
  color: rgba(224, 242, 241, 0.6);
  will-change: transform;
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-fluid-slow), padding var(--transition-fluid-slow);
  padding: 0 var(--card-content-padding-x);
  will-change: max-height, padding;
}

.section-content.open {
  max-height: 5000px;
  padding: var(--card-content-padding-x);
}

/* Hide AI section by default - only show when content is generated */
#aiSummarySection:not(.open) {
  max-height: 0 !important;
  padding: 0 var(--card-content-padding-x) !important;
  overflow: hidden !important;
}

/* Hide the entire AI Analysis form-section by default */
#aiAnalysisFormSection {
  display: none !important;
}

/* Remove will-change after animation completes to prevent stuck animations */
.section-content:not(.open) {
  will-change: auto;
}

.section-content.open:not(:hover) {
  will-change: auto;
}

/* AI Summary Section Styling */
#aiSummarySection .ai-summary-header,
#aiSummarySection .ai-summary-section {
  margin-bottom: 1rem;
}

#aiSummarySection .ai-summary-section:last-child {
  margin-bottom: 0;
}

.section-content.open > * {
  animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-fill-mode: both;
}

.section-content.open > *:nth-child(1) { animation-delay: 0.02s; }
.section-content.open > *:nth-child(2) { animation-delay: 0.04s; }
.section-content.open > *:nth-child(3) { animation-delay: 0.06s; }
.section-content.open > *:nth-child(4) { animation-delay: 0.08s; }
.section-content.open > *:nth-child(5) { animation-delay: 0.1s; }
.section-content.open > *:nth-child(6) { animation-delay: 0.12s; }
.section-content.open > *:nth-child(7) { animation-delay: 0.14s; }
.section-content.open > *:nth-child(8) { animation-delay: 0.16s; }
.section-content.open > *:nth-child(9) { animation-delay: 0.18s; }
.section-content.open > *:nth-child(10) { animation-delay: 0.2s; }

/* Optimize for mobile - reduce animation delays */
@media (max-width: 768px) {
  .section-content {
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .section-content.open > * {
    animation: slideInUp 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
  
  .section-content.open > *:nth-child(n) {
    animation-delay: 0.02s;
  }
  
  /* Disable hover effects on mobile */
  .section-header:hover {
    background: rgba(76, 175, 80, 0.05);
    color: var(--text-light);
  }
  
  .section-header:hover .section-icon {
    transform: scale(1);
  }
  
  /* AI Summary Section - Mobile Responsive */
  #aiSummarySection {
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 1rem !important;
  }
  
  #aiSummarySection.open {
    max-height: calc(100vh - 200px) !important;
    min-height: 200px;
  }
  
  #aiResultsContent {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: fit-content;
  }
  
  .ai-summary-section {
    padding: 1.25rem !important;
    margin-bottom: 1rem !important;
    font-size: 0.9rem;
  }
  
  .ai-summary-header {
    padding: 1.25rem !important;
    margin-bottom: 1rem !important;
  }
  
  .ai-summary-header h3 {
    font-size: 1.2rem !important;
  }
  
  .ai-section-title {
    font-size: 1.1rem !important;
    margin-bottom: 1rem !important;
    padding-bottom: 0.5rem !important;
  }
  
  /* Ensure content is scrollable */
  #aiAnalysisFormSection {
    max-height: calc(100vh - 150px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  
  #aiAnalysisFormSection .section-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .section-header,
  .section-icon,
  .section-arrow,
  .section-content {
    transition: none;
    animation: none;
  }
  
  .section-content.open > * {
    animation: none;
  }

  .ai-summary-section {
    transition: none;
  }

  .container:hover,
  .tab-btn:hover,
  .action-btn:hover,
  .filter-btn:hover,
  .sort-btn:hover,
  .cloud-btn:hover,
  .view-toggle-btn:hover,
  .date-range-btn:hover {
    transform: none;
  }

  .ai-trend-card:hover {
    transform: none;
  }
}

body.light-mode .form-section {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(129, 199, 132, 0.2);
}

body.light-mode .form-section:hover {
  border-color: rgba(76, 175, 80, 0.4);
  background: rgba(255, 255, 255, 0.4);
}

body.light-mode .section-header {
  background: rgba(76, 175, 80, 0.1);
  color: var(--text-dark);
}

body.light-mode .section-header:hover {
  background: rgba(76, 175, 80, 0.2);
  color: var(--text-dark);
}

/* Light mode tab styles */
body.light-mode .tab-navigation {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(129, 199, 132, 0.3);
}

body.light-mode .tab-btn {
  color: rgba(27, 94, 32, 0.7);
}

body.light-mode .tab-btn:hover:not(.active) {
  background: rgba(76, 175, 80, 0.2);
  color: #1b5e20;
}

body.light-mode .tab-btn.active {
  background: rgba(76, 175, 80, 0.15);
  color: #1b5e20;
  border: 2px solid rgba(76, 175, 80, 0.4);
}

body.light-mode .tab-btn.active:hover {
  background: rgba(76, 175, 80, 0.15) !important;
  color: #1b5e20 !important;
  border-color: rgba(76, 175, 80, 0.7) !important;
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.3) !important;
}

body.light-mode .action-btn {
  background: rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.4);
  color: var(--text-dark);
}

body.light-mode .action-btn:hover {
  background: rgba(76, 175, 80, 0.25);
}

body.light-mode .summary-card {
  background: var(--card-bg-light);
  border-color: var(--border-light);
}

body.light-mode .summary-info {
  background: rgba(76, 175, 80, 0.15);
  border-color: var(--border-light);
  color: var(--text-dark);
}

input, textarea, select {
  display: block;
  margin: 15px 0;
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  color: var(--text-light);
  box-sizing: border-box;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  transition: all var(--transition-normal);
  position: relative;
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2), var(--primary-glow);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

input:hover, textarea:hover, select:hover {
  border-color: rgba(76, 175, 80, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

.form-section label,
.section-content label {
  font-weight: 600;
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.95);
}

input::placeholder, textarea::placeholder {
  color: rgba(224, 242, 241, 0.5);
  transition: color var(--transition-fast);
}

input:focus::placeholder, textarea:focus::placeholder {
  color: rgba(224, 242, 241, 0.3);
}

/* Validation styles */
.weight-label-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.weight-label-container label {
  margin-bottom: 0;
  flex: 1;
}

.unit-toggle-btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
  min-height: auto;
  width: auto;
  margin: 0;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.unit-toggle-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.unit-toggle-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
  background: linear-gradient(135deg, #388e3c 0%, #4caf50 50%, #66bb6a 100%);
}

.unit-toggle-btn:hover::before {
  width: 200px;
  height: 200px;
}

.unit-toggle-btn:active {
  transform: translateY(0) scale(1);
}

body.light-mode .unit-toggle-btn {
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.input-container {
  position: relative;
  margin: 15px 0;
}

.input-container input,
.input-container textarea,
.input-container select {
  margin: 0;
}

input.valid, textarea.valid, select.valid {
  border-color: #4caf50;
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2), 0 0 15px rgba(76, 175, 80, 0.3);
  animation: validPulse 0.5s ease-out;
}

@keyframes validPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

input.invalid, textarea.invalid, select.invalid {
  border-color: #f44336;
  box-shadow: 0 0 0 4px rgba(244, 67, 54, 0.2), 0 0 15px rgba(244, 67, 54, 0.3);
  animation: shake 0.5s ease-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

body.light-mode input.valid, 
body.light-mode textarea.valid, 
body.light-mode select.valid {
  border-color: #388e3c;
  box-shadow: 0 0 0 2px rgba(56, 142, 60, 0.2);
}

body.light-mode input.invalid, 
body.light-mode textarea.invalid, 
body.light-mode select.invalid {
  border-color: #d32f2f;
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.2);
}

.validation-message {
  position: absolute;
  bottom: -20px;
  left: 0;
  font-size: 0.8rem;
  color: #f44336;
  background: rgba(244, 67, 54, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  display: none;
  z-index: 10;
}

body.light-mode .validation-message {
  color: #d32f2f;
  background: rgba(211, 47, 47, 0.1);
}

.validation-message.show {
  display: block;
  animation: validationSlideIn 0.3s ease-out;
}

@keyframes validationSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-validation-summary {
  background: rgba(244, 67, 54, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid #f44336;
  border-radius: 12px;
  padding: 18px;
  margin: 15px 0;
  color: #f44336;
  display: none;
  box-shadow: 0 4px 15px rgba(244, 67, 54, 0.2);
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode .form-validation-summary {
  background: rgba(211, 47, 47, 0.1);
  border-color: #d32f2f;
  color: #d32f2f;
}

.form-validation-summary.show {
  display: block;
  animation: validationSlideIn 0.3s ease-out;
}

.form-validation-summary h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: inherit;
}

.form-validation-summary ul {
  margin: 0;
  padding-left: 20px;
}

.form-validation-summary li {
  margin-bottom: 5px;
}

.log-date-block {
  margin-bottom: 1.25rem;
  padding: 0 var(--card-content-padding-x);
  box-sizing: border-box;
}

.log-date-block label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-light);
}

.log-required-block {
  margin-bottom: 1.25rem;
  padding: 0 var(--card-content-padding-x);
  box-sizing: border-box;
}

.log-required-block label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-light);
}

.character-counter {
  font-size: 0.8rem;
  color: #888;
  font-weight: normal;
  margin-left: 10px;
}

body.light-mode .character-counter {
  color: #666;
}

.slider-container {
  position: relative;
  margin: 25px 0;
  width: 100%;
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  padding: 10px 0;
}

.slider-container:nth-child(1) { animation-delay: 0.1s; }
.slider-container:nth-child(2) { animation-delay: 0.15s; }
.slider-container:nth-child(3) { animation-delay: 0.2s; }
.slider-container:nth-child(4) { animation-delay: 0.25s; }
.slider-container:nth-child(5) { animation-delay: 0.3s; }
.slider-container:nth-child(6) { animation-delay: 0.35s; }
.slider-container:nth-child(7) { animation-delay: 0.4s; }
.slider-container:nth-child(8) { animation-delay: 0.45s; }
.slider-container:nth-child(9) { animation-delay: 0.5s; }
.slider-container:nth-child(10) { animation-delay: 0.55s; }

input[type="range"] {
  padding: 0;
  height: 48px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
  border-radius: 24px;
  margin: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

input[type="range"]:hover {
  border-color: rgba(76, 175, 80, 0.5);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(76, 175, 80, 0.2);
}

input[type="range"]:active {
  transform: scale(1.02);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.slider-label {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: white;
  font-weight: bold;
  font-size: 14px;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  margin: 0;
  display: block;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 40px;
  width: 10px;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  border: none;
  box-shadow: none;
  position: relative;
  z-index: 3;
}

input[type="range"]::-moz-range-thumb {
  height: 40px;
  width: 10px;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  border: none;
  box-shadow: none;
  position: relative;
  z-index: 3;
}

/* Good/Bad labels under slider: centred under each end, more visible */
.slider-good-bad {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 6px;
  padding: 0 4px;
  box-sizing: border-box;
  pointer-events: none;
}

.slider-hint-good,
.slider-hint-bad {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.slider-hint-good {
  color: rgba(76, 175, 80, 0.95);
  text-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

.slider-hint-bad {
  color: rgba(244, 67, 54, 0.9);
  text-shadow: 0 0 8px rgba(244, 67, 54, 0.3);
}

body.light-mode .slider-hint-good {
  color: #2e7d32;
  text-shadow: none;
}

body.light-mode .slider-hint-bad {
  color: #c62828;
  text-shadow: none;
}

button {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  min-height: 50px;
  font-size: 1.2rem;
  border-radius: 12px;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
  display: block;
  margin: 15px 0;
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4), var(--primary-glow);
  background: linear-gradient(135deg, #388e3c 0%, #4caf50 50%, #66bb6a 100%);
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.4), 0 6px 20px rgba(76, 175, 80, 0.4);
}

.entry {
  background: rgba(38, 50, 56, 0.6);
  backdrop-filter: blur(10px);
  padding: 20px;
  margin-top: 15px;
  margin-bottom: 0;
  border-radius: 16px;
  animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.entry::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.1), transparent);
  transition: left 0.5s;
}

.entry:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.2), 0 0 30px rgba(76, 175, 80, 0.1);
  background: rgba(38, 50, 56, 0.8);
  border-color: rgba(76, 175, 80, 0.3);
}

.entry:hover::before {
  left: 100%;
}

/* Log Entry Header - Collapsible */
.log-entry-header-collapsible {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  margin: 0 -20px 0 -20px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.2s ease;
  border-radius: 0;
  position: relative;
}

.log-entry-header-collapsible:hover {
  background: rgba(76, 175, 80, 0.1);
}

.log-entry-header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  padding-right: 20px;
  min-width: 0;
}

.log-entry-arrow {
  display: none; /* Hidden - arrow removed per user request */
}

/* Log Entry Content - Hidden by default */
.log-entry-content {
  display: none;
  padding-top: 20px;
  animation: fadeIn 0.3s ease;
}

.entry.expanded .log-entry-content {
  display: block;
}

/* Log Entry Actions - Edit and Delete buttons */
.log-entry-actions {
  display: none; /* Completely hidden when collapsed */
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  padding: 0;
  margin: 0;
  border-radius: 16px 16px 0 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.2);
  height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  /* Smooth strip animation - buttons appear instantly with the strip */
  transition: display 0s 0.2s, height 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, padding 0.2s ease, margin 0.2s ease, visibility 0s 0.2s;
}

.entry.expanded .log-entry-actions {
  display: flex; /* Show when expanded */
  height: auto;
  min-height: 52px;
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  padding: 10px 20px;
  margin: -20px -20px 10px -20px;
  /* Strip appears smoothly, buttons are already visible */
  transition: display 0s, height 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, padding 0.2s ease, margin 0.2s ease, visibility 0s;
}


/* Log Entry Header - Legacy support */
.log-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  padding-right: 90px; /* Make room for delete and edit buttons */
  border-bottom: 2px solid rgba(76, 175, 80, 0.3);
}

.header-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  margin-left: auto; /* Push badges to the right */
}

.inline-edit-date {
  width: auto !important;
  max-width: 200px !important;
  margin-right: 20px !important;
  flex-shrink: 0;
}

.header-icon-btn {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 50%;
  padding: 0;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  line-height: 1;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: visible;
}

.header-icon-btn * {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.header-icon-btn:hover {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.header-icon-btn:active {
  transform: translateY(0);
}

.header-icon-btn.food-btn {
  background: rgba(255, 152, 0, 0.15);
  border-color: rgba(255, 152, 0, 0.3);
}

.header-icon-btn.food-btn:hover {
  background: rgba(255, 152, 0, 0.25);
  border-color: rgba(255, 152, 0, 0.5);
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.header-icon-btn.exercise-btn {
  background: rgba(0, 188, 212, 0.15);
  border-color: rgba(0, 188, 212, 0.3);
}

.header-icon-btn.exercise-btn:hover {
  background: rgba(0, 188, 212, 0.25);
  border-color: rgba(0, 188, 212, 0.5);
  box-shadow: 0 2px 8px rgba(0, 188, 212, 0.3);
}

.badge-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #f44336, #e53935);
  color: white;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 6px;
  min-width: 20px;
  text-align: center;
  line-height: 1.3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

.log-date {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: #e0f2f1;
  letter-spacing: 0.5px;
}

.flare-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
  flex-shrink: 0;
  white-space: nowrap;
}

.flare-yes {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.3), rgba(229, 57, 53, 0.3));
  color: #ffcdd2;
  border: 1px solid rgba(244, 67, 54, 0.5);
}

.flare-no {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.3), rgba(56, 142, 60, 0.3));
  color: #c8e6c9;
  border: 1px solid rgba(76, 175, 80, 0.5);
}

/* Log Metrics Grid */
.log-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.metric-group {
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-group-title {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #81c784;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(129, 199, 132, 0.3);
}

.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.metric-label {
  font-size: 0.95rem;
  color: #b0bec5;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-value {
  font-size: 1rem;
  font-weight: 600;
  color: #e0f2f1;
  min-width: 60px;
  text-align: right;
}

.metric-value-muted {
  font-weight: 500;
  color: rgba(224, 242, 241, 0.55);
}

.metric-value-list {
  flex-wrap: wrap;
  word-break: break-word;
  max-width: 100%;
}

.metric-detail {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(224, 242, 241, 0.75);
}

/* Inline edit inputs - optimized layout */
.metric-item input[type="text"],
.metric-item input[type="number"] {
  flex-shrink: 0;
}

.metric-item .inline-edit-energyClarity,
.metric-item .inline-edit-painLocation {
  min-width: 150px;
  max-width: 250px;
}

.metric-item .inline-edit-steps {
  min-width: 100px;
  max-width: 120px;
}

.metric-item .inline-edit-hydration {
  min-width: 80px;
  max-width: 100px;
}

/* Log Notes */
.log-notes {
  margin-top: 20px;
  padding: 15px;
  background: rgba(76, 175, 80, 0.1);
  border-left: 3px solid rgba(76, 175, 80, 0.5);
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #e0f2f1;
}

.log-notes strong {
  color: #81c784;
  margin-right: 8px;
}

.delete-btn {
  position: relative;
  background: linear-gradient(135deg, #f44336, #e53935);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  z-index: 10;
  padding: 0;
  margin: 0;
  min-height: auto;
  box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
  /* Removed scaleIn animation - buttons appear instantly with the strip */
}

.delete-btn:hover {
  background: linear-gradient(135deg, #d32f2f, #c62828);
  transform: scale(1.15) rotate(90deg);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.5);
}

.delete-btn:active {
  transform: scale(0.95) rotate(90deg);
}

/* Edit Button */
.edit-btn {
  position: relative;
  background: linear-gradient(135deg, #2196f3, #1976d2);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  z-index: 10;
  padding: 0;
  margin: 0;
  min-height: auto;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
  /* Removed scaleIn animation - buttons appear instantly with the strip */
}

.edit-btn:hover {
  background: linear-gradient(135deg, #1976d2, #1565c0);
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.5);
}

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

/* Save Button (when editing inline) */
.save-btn {
  background: linear-gradient(135deg, #4caf50, #388e3c) !important;
}

.save-btn:hover {
  background: linear-gradient(135deg, #388e3c, #2e7d32) !important;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

/* Entry in editing mode */
.entry.editing {
  border: 2px solid rgba(76, 175, 80, 0.6);
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
}

/* In edit mode, stack labels above inputs */
.entry.editing .metric-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 0;
}

.entry.editing .metric-label {
  margin-bottom: 4px;
  width: 100%;
}

.entry.editing .metric-item input[type="text"],
.entry.editing .metric-item input[type="number"],
.entry.editing .metric-item select {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-top: 4px;
  box-sizing: border-box;
}

/* Override inline styles for input wrapper spans */
.entry.editing .metric-item > span[style*="margin-left: auto"],
.entry.editing .metric-item > span[style*="display: flex"] {
  width: 100% !important;
  margin-left: 0 !important;
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.entry.editing .metric-item > span[style*="margin-left: auto"] input,
.entry.editing .metric-item > span[style*="display: flex"] input {
  flex: 1;
  width: auto !important;
  margin: 0 !important;
}

/* Pain location: selectable body diagram — green (none) → yellow (mild) → red (pain) */
.pain-body-container label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: rgba(224, 242, 241, 0.9);
}

.pain-body-wrapper {
  max-width: 240px;
  margin: 0 auto;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid rgba(76, 175, 80, 0.25);
}

.pain-body-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
}

.pain-region {
  cursor: pointer;
  transition: fill 0.2s ease, filter 0.2s ease;
  stroke: currentColor;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.pain-region:hover {
  filter: brightness(1.15);
}

.pain-region.pain-state-0 {
  fill: rgba(76, 175, 80, 0.5);
  color: rgba(76, 175, 80, 0.5);
}

.pain-region.pain-state-1 {
  fill: rgba(255, 193, 7, 0.65);
  color: rgba(255, 193, 7, 0.65);
}

.pain-region.pain-state-2 {
  fill: rgba(244, 67, 54, 0.7);
  color: rgba(244, 67, 54, 0.7);
}

body.light-mode .pain-body-wrapper {
  background: rgba(76, 175, 80, 0.06);
  border-color: rgba(76, 175, 80, 0.3);
}

body.light-mode .pain-region.pain-state-0 { fill: rgba(76, 175, 80, 0.35); color: rgba(76, 175, 80, 0.35); }
body.light-mode .pain-region.pain-state-1 { fill: rgba(255, 193, 7, 0.5); color: rgba(255, 193, 7, 0.5); }
body.light-mode .pain-region.pain-state-2 { fill: rgba(244, 67, 54, 0.55); color: rgba(244, 67, 54, 0.55); }

/* For direct inputs (like painLocation) */
.entry.editing .metric-item > input[type="text"],
.entry.editing .metric-item > input[type="number"] {
  margin-left: 0 !important;
  margin-top: 4px;
}


/* Modal Overlay - Transparent parent that disables background interaction */
.modal-overlay {
  display: none;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  pointer-events: all;
  overflow: hidden !important;
  overflow-x: hidden !important;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0;
  transition: opacity var(--transition-normal) var(--ease-fluid);
}

.modal-overlay.modal-overlay--open {
  opacity: 1;
}

/* Alert Modal Overlay - Higher z-index than settings */
#alertModalOverlay {
  z-index: 100001 !important; /* Higher than settings modal (100000) */
}

.modal-overlay[style*="block"] {
  display: block !important;
  opacity: 1 !important;
}

.modal-content {
  transition: transform 0.3s var(--ease-fluid), opacity 0.3s var(--ease-fluid);
}

/* Disable body scroll and interaction when modal is open */
body.modal-active {
  overflow: hidden;
  pointer-events: none;
  position: relative;
}

body.modal-active .modal-overlay,
body.modal-active .settings-overlay,
body.modal-active .ai-modal-overlay {
  pointer-events: all;
}

body.modal-active .modal-content,
body.modal-active .settings-menu,
body.modal-active .ai-modal-content {
  pointer-events: all;
}

/* Prevent interaction with page content when settings is open */
body.modal-active .container,
body.modal-active .tab-content {
  pointer-events: none;
}

/* Header buttons (targets + settings) should always be clickable */
.header-buttons-wrap,
.settings-button-top,
.targets-button-top {
  pointer-events: all !important;
  z-index: 100001 !important;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  opacity: 1;
  transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(76, 175, 80, 0.2);
  border-top: 4px solid #4caf50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: rgba(224, 242, 241, 0.9);
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.5px;
}

.loading-progress-wrap {
  width: min(280px, 85vw);
  display: none;
}
.loading-progress-wrap.visible {
  display: block;
}
.loading-progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(76, 175, 80, 0.25);
}
.loading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(76, 175, 80, 0.5), #4caf50);
  border-radius: 999px;
  transition: width 0.2s ease-out;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Cookie consent banner - fixed bottom bar */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 9998;
  background: linear-gradient(135deg, #263238, #37474f);
  border-top: 2px solid rgba(76, 175, 80, 0.5);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  padding: 14px 16px;
  box-sizing: border-box;
}
.cookie-banner.hidden {
  display: none;
}
.cookie-banner-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  justify-content: space-between;
}
.cookie-banner-text {
  flex: 1 1 280px;
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-light);
}
.cookie-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}
.cookie-banner-accept {
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: var(--text-sm);
}
.cookie-banner-accept:hover {
  background: #66bb6a;
}
.cookie-banner-policy {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-light);
  border: 1px solid rgba(76, 175, 80, 0.4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
}
.cookie-banner-policy:hover {
  background: rgba(255, 255, 255, 0.18);
}
body.light-mode .cookie-banner {
  background: var(--card-bg-light);
  border-top-color: var(--border-light);
  color: var(--text-dark);
}
body.light-mode .cookie-banner-text {
  color: var(--text-dark);
}
body.light-mode .cookie-banner-policy {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-dark);
  border-color: var(--border-light);
}
body.light-mode .cookie-banner-policy:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Cookie policy modal - reuses modal-content; scrollable body */
.cookie-policy-modal {
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.cookie-policy-body {
  overflow-y: auto;
  flex: 1 1 auto;
}
.cookie-policy-body section {
  margin-bottom: 1.25rem;
}
.cookie-policy-body section:last-child {
  margin-bottom: 0;
}
.cookie-policy-body h4 {
  margin: 0 0 0.5rem 0;
  font-size: var(--heading-sm);
  color: var(--text-light);
}
body.light-mode .cookie-policy-body h4 {
  color: var(--text-dark);
}
.cookie-policy-body p,
.cookie-policy-body ul {
  margin: 0 0 0.75rem 0;
  font-size: var(--text-sm);
  line-height: 1.55;
}
.cookie-policy-body ul {
  padding-left: 1.25rem;
}
.cookie-policy-body li {
  margin-bottom: 0.35rem;
}
.cookie-policy-body code {
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
body.light-mode .cookie-policy-body code {
  background: rgba(0, 0, 0, 0.08);
}

/* Donate modal — above settings (z-index 99999 / menu 100000) */
.donate-modal-overlay {
  z-index: 100010 !important;
}
.donate-modal-content {
  max-width: min(520px, 96vw);
  width: min(520px, 96vw);
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}
.donate-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.donate-modal-header {
  flex-shrink: 0;
}
.donate-iframe-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: min(480px, 55vh);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #fff;
}
.donate-iframe-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(38, 50, 56, 0.92);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.donate-iframe-close:hover {
  background: rgba(76, 175, 80, 0.95);
  transform: scale(1.05);
}
body.light-mode .donate-iframe-close {
  background: rgba(255, 255, 255, 0.95);
  color: #263238;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
body.light-mode .donate-iframe-close:hover {
  background: rgba(76, 175, 80, 0.95);
  color: #fff;
}
.donate-paypal-iframe {
  width: 100%;
  height: 100%;
  min-height: min(480px, 55vh);
  display: block;
  border: none;
  border-radius: 0;
  background: #fff;
}
.donate-modal-fallback {
  margin: 0;
  font-size: var(--text-sm);
  text-align: center;
  color: rgba(224, 242, 241, 0.85);
}
.donate-modal-fallback a {
  color: rgba(129, 199, 132, 0.95);
  text-decoration: underline;
}
body.light-mode .donate-modal-fallback {
  color: var(--text-secondary);
}
body.light-mode .donate-modal-fallback a {
  color: var(--primary-dark, #2e7d32);
}
.donate-settings-btn {
  width: 100%;
  justify-content: center;
}

/* Install modal (post-tutorial; also in God mode) */
.install-modal-hint {
  margin: 0 0 1rem 0;
  color: rgba(224, 242, 241, 0.85);
  font-size: var(--text-sm);
}
.install-modal-buttons .settings-option {
  margin-bottom: 0.75rem;
}
.install-modal-buttons .settings-option:last-child {
  margin-bottom: 0;
}
body.light-mode .install-modal-hint {
  color: var(--text-secondary);
}

/* God mode overlay (` key) – test all UI */
.god-mode-content {
  width: min(920px, 96vw);
  max-width: 96vw;
  max-height: 92vh;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
}
.god-mode-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.god-mode-hint {
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.8);
  margin: 0 0 1rem 0;
}
.god-mode-hint kbd {
  font-family: inherit;
  padding: 0.15em 0.4em;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  font-size: 0.9em;
}
.god-mode-section {
  margin-bottom: 1.25rem;
}
.god-mode-section:last-child {
  margin-bottom: 0;
}
.god-mode-section-title {
  font-size: var(--heading-sm);
  margin: 0 0 0.5rem 0;
  color: rgba(76, 175, 80, 0.95);
  font-weight: 600;
}
.god-mode-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.god-mode-section-hint {
  margin: 0.5rem 0 0 0;
  font-size: 0.85rem;
  color: rgba(224, 242, 241, 0.7);
  line-height: 1.35;
}
.god-mode-btn {
  padding: 8px 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(76, 175, 80, 0.35);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition-fluid), border-color var(--transition-fluid);
}
.god-mode-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(76, 175, 80, 0.5);
}
body.light-mode .god-mode-hint {
  color: var(--text-secondary);
}
body.light-mode .god-mode-hint kbd {
  background: rgba(0, 0, 0, 0.08);
}
body.light-mode .god-mode-section-title {
  color: var(--primary-color);
}
body.light-mode .god-mode-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: var(--border-light);
  color: var(--text-dark);
}
body.light-mode .god-mode-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Settings footer (Cookie policy link) */
.settings-footer {
  padding: 12px 0 8px 0;
  border-top: 1px solid rgba(76, 175, 80, 0.2);
  margin-top: 8px;
}
.settings-footer-link {
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.8);
  text-decoration: none;
}
.settings-footer-link:hover {
  color: var(--primary-color);
  text-decoration: underline;
}
body.light-mode .settings-footer {
  border-top-color: var(--border-light);
}
body.light-mode .settings-footer-link {
  color: var(--text-secondary);
}
body.light-mode .settings-footer-link:hover {
  color: var(--primary-color);
}

/* Prevent interaction when loading */
body.loading {
  overflow: hidden;
  pointer-events: none;
}

body.loading .loading-overlay {
  pointer-events: all;
}

.modal-content {
  background: linear-gradient(135deg, #263238, #37474f);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(76, 175, 80, 0.3);
  border: 2px solid rgba(76, 175, 80, 0.5);
  animation: modalFloatIn 0.4s var(--ease-fluid);
  overflow: hidden;
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 10001 !important;
  pointer-events: all;
  margin: 0 !important;
  padding: 0 !important;
  /* Ensure modal is always centered relative to viewport, not document */
  box-sizing: border-box;
}

.edit-entry-modal {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 10001 !important;
  max-width: 700px;
}

/* Alert Modal Styles */
.alert-modal-overlay {
  z-index: 100001 !important; /* Higher than settings modal (100000) */
}

.alert-modal-content {
  max-width: 500px;
  width: 90vw;
  z-index: 100002 !important; /* Higher than alert overlay */
}

.alert-modal-body {
  padding: 24px 30px;
  text-align: center;
  color: var(--text-light);
  font-size: 1rem;
  line-height: 1.6;
}

.alert-modal-footer {
  display: flex;
  justify-content: center;
}

/* Performance benchmark modal */
.perf-benchmark-content {
  max-width: 860px;
  width: min(860px, 94vw);
}
.perf-benchmark-body {
  padding: 18px 18px 8px 18px;
  color: var(--text-light);
}
.perf-benchmark-summary {
  margin: 0 0 14px 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: rgba(224, 242, 241, 0.88);
}
.perf-benchmark-ai-line {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  color: rgba(224, 242, 241, 0.85);
}
.perf-benchmark-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.perf-benchmark-panel {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(76, 175, 80, 0.28);
  border-radius: var(--radius-md);
  padding: 12px 12px 10px 12px;
}
.perf-benchmark-panel-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: rgba(76, 175, 80, 0.95);
  margin: 0 0 10px 0;
}
.perf-benchmark-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perf-benchmark-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 62px;
  gap: 10px;
  align-items: center;
}
@media (max-width: 460px) {
  .perf-benchmark-bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
.perf-benchmark-bar-label {
  font-size: 0.86rem;
  color: rgba(224, 242, 241, 0.92);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.perf-benchmark-bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  overflow: hidden;
}
.perf-benchmark-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(76, 175, 80, 0.35), rgba(76, 175, 80, 0.95));
  border-radius: 999px;
}
.perf-benchmark-bar-value {
  font-size: 0.82rem;
  color: rgba(224, 242, 241, 0.75);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.perf-benchmark-kv {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 0.85rem;
  color: rgba(224, 242, 241, 0.8);
}
.perf-benchmark-kv div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
/* Detailed benchmark (test bars, sparklines, profile): desktop-width viewports only — hidden on mobile web / PWA / narrow screens */
@media (max-width: 1023px) {
  #perfBenchmarkDetailsBlock {
    display: none !important;
  }
  .god-mode-btn--desktop-only {
    display: none !important;
  }
}
.perf-benchmark-details {
  margin-top: 12px;
  border-top: 1px solid rgba(76, 175, 80, 0.22);
  padding-top: 10px;
}
.perf-benchmark-details summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: rgba(224, 242, 241, 0.9);
}
.perf-benchmark-details-inner {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(76, 175, 80, 0.15);
}
.perf-benchmark-details-inner summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: rgba(224, 242, 241, 0.85);
}
.perf-benchmark-profile {
  margin: 10px 0 0 0;
  max-height: 220px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(76, 175, 80, 0.22);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: rgba(224, 242, 241, 0.92);
  font-size: 0.82rem;
  line-height: 1.35;
}
.perf-benchmark-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
}
body.light-mode .perf-benchmark-panel {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--border-light);
}
body.light-mode .perf-benchmark-summary,
body.light-mode .perf-benchmark-ai-line,
body.light-mode .perf-benchmark-bar-label,
body.light-mode .perf-benchmark-bar-value,
body.light-mode .perf-benchmark-details summary,
body.light-mode .perf-benchmark-details-inner summary {
  color: var(--text-dark);
}
body.light-mode .perf-benchmark-profile {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--border-light);
  color: var(--text-dark);
}

/* Share Modal */
.share-modal-content {
  max-width: 520px;
  width: 92%;
}

.share-modal-body {
  padding: 20px 24px;
  color: var(--text-light);
  font-size: 0.95rem;
  line-height: 1.5;
  max-height: 50vh;
  overflow-y: auto;
}

.share-modal-body .share-preview-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  color: rgba(224, 242, 241, 0.9);
}

.share-modal-body .share-chart-preview {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(76, 175, 80, 0.3);
  margin-bottom: 1rem;
}

.share-modal-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.share-modal-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.share-modal-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(76, 175, 80, 0.4);
  transform: scale(1.03);
}

.share-modal-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.share-modal-btn-primary {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.5);
  color: #e0f2f1;
}

.share-modal-btn-primary:hover {
  background: rgba(76, 175, 80, 0.4);
  border-color: rgba(76, 175, 80, 0.7);
}

.share-modal-btn-icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.95;
}

.share-modal-btn-icon i {
  font-size: 1rem;
}

.share-modal-btn-label {
  line-height: 1.2;
}

@media (max-width: 360px) {
  .share-modal-actions {
    flex-wrap: wrap;
  }
}

/* Share button (log entry bar and chart containers) – circular with share icon */
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #43a047, #2e7d32);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

.share-btn i {
  font-size: 0.95rem;
}

.share-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

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

.share-btn:focus {
  outline: 2px solid rgba(76, 175, 80, 0.8);
  outline-offset: 2px;
}

/* Log entry actions: left group + share on right */
.log-entry-actions-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.log-entry-actions .share-btn {
  margin-left: auto;
}

/* Chart share button — in flow above the plot (not over the graph) */
.chart-container:has(> .chart-share-btn) {
  display: flex;
  flex-direction: column;
}

.chart-container:has(> .chart-share-btn) > #combinedChart,
.chart-container:has(> .chart-share-btn) > #balanceChart {
  min-height: 0;
  width: 100%;
}

.chart-share-btn {
  position: static;
  align-self: flex-end;
  flex-shrink: 0;
  margin: 0 0 10px 0;
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.9);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.chart-share-btn:hover {
  background: rgba(76, 175, 80, 1);
  transform: scale(1.1);
}

.chart-share-btn:focus {
  outline: 2px solid rgba(76, 175, 80, 0.8);
  outline-offset: 2px;
}

.chart-share-btn i {
  font-size: 0.95rem;
}

/* Tutorial Modal - new user onboarding */
.tutorial-modal-overlay {
  z-index: 100003 !important;
  background: rgba(0, 0, 0, 0.6) !important;
}

.tutorial-modal-content {
  max-width: 520px;
  width: 92%;
  z-index: 100004 !important;
}

.tutorial-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(76, 175, 80, 0.3);
}

.tutorial-slides-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.tutorial-arrow {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: rgba(224, 242, 241, 0.85);
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  padding: 0;
}

.tutorial-arrow:hover {
  color: rgba(76, 175, 80, 0.95);
}

.tutorial-arrow:active {
  transform: scale(0.95);
}

.tutorial-modal-body {
  flex: 1;
  min-width: 0;
  padding: 24px 20px;
  min-height: 100px;
  max-height: 50vh;
  overflow-y: auto;
  position: relative;
  touch-action: pan-y;
}

.tutorial-slide {
  display: none;
  animation: tutorialSlideIn 0.25s ease-out;
}

.tutorial-slide.tutorial-slide-active {
  display: block;
}

.tutorial-text {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(224, 242, 241, 0.95);
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 0;
}

.tutorial-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.35);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.tutorial-dot:hover {
  background: rgba(76, 175, 80, 0.6);
}

.tutorial-dot.tutorial-dot-active {
  background: rgba(76, 175, 80, 0.95);
  transform: scale(1.2);
}

.tutorial-modal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid rgba(76, 175, 80, 0.2);
  gap: 12px;
  flex-wrap: wrap;
}

.tutorial-footer-right {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.tutorial-footer-right .tutorial-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  text-align: center;
}

.tutorial-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid rgba(76, 175, 80, 0.5);
  background: rgba(76, 175, 80, 0.2);
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.tutorial-btn:hover {
  background: rgba(76, 175, 80, 0.35);
  border-color: rgba(76, 175, 80, 0.7);
}

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

.tutorial-btn.tutorial-finish {
  background: rgba(76, 175, 80, 0.35);
}

.tutorial-btn.tutorial-demo {
  background: rgba(33, 150, 243, 0.3);
  border-color: rgba(33, 150, 243, 0.5);
}

.tutorial-btn.tutorial-demo:hover {
  background: rgba(33, 150, 243, 0.45);
  border-color: rgba(33, 150, 243, 0.7);
}

.tutorial-btn.tutorial-signup {
  background: rgba(156, 39, 176, 0.3);
  border-color: rgba(156, 39, 176, 0.5);
}

.tutorial-btn.tutorial-signup:hover {
  background: rgba(156, 39, 176, 0.45);
  border-color: rgba(156, 39, 176, 0.7);
}

.tutorial-ai-choice-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.tutorial-ai-choice-buttons .tutorial-btn {
  flex: 1 1 0;
  min-width: 120px;
}

.tutorial-ai-choice-buttons .tutorial-ai-enable {
  background: rgba(76, 175, 80, 0.35);
  border-color: rgba(76, 175, 80, 0.6);
}

.tutorial-ai-choice-buttons .tutorial-ai-skip {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
}

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

/* Sign up / Sign in standalone modal */
.signup-signin-modal-overlay {
  z-index: 100005 !important;
  background: rgba(0, 0, 0, 0.6) !important;
}

.signup-signin-modal-content {
  max-width: 440px;
  z-index: 100006 !important;
}

.signup-signin-modal-content .cloud-auth-section {
  margin-top: 0;
}

.tutorial-condition-display-wrap .settings-data-btn {
  font-size: 0.95rem;
  padding: 10px 12px;
}

.tutorial-condition-selector .item-input,
.tutorial-condition-selector .add-item-btn {
  font-size: 0.9rem;
}

.tutorial-toggle-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-toggle-label {
  font-size: 0.95rem;
  color: rgba(224, 242, 241, 0.95);
  flex: 1;
}

.tutorial-toggle-option .toggle-switch {
  flex-shrink: 0;
}

.tutorial-toggle-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: rgba(224, 242, 241, 0.65);
  line-height: 1.4;
}

/* GDPR Agreement Modal Styles */
/* GDPR Agreement Modal Overlay - Higher than settings modal */
#gdprAgreementModalOverlay {
  z-index: 100010 !important; /* Higher than settings modal (100000) */
}

.gdpr-agreement-modal {
  max-width: 800px;
  width: 90vw;
  max-height: 75vh !important; /* Ensure modal fits in viewport */
  z-index: 100011 !important; /* Higher than overlay */
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: relative !important;
}

.gdpr-agreement-body {
  padding: 24px 30px;
  color: var(--text-light);
  font-size: 0.95rem;
  line-height: 1.7;
  text-align: left;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0; /* Allow flex shrinking */
  max-height: calc(75vh - 180px); /* Leave room for header and footer */
}

.gdpr-agreement-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gdpr-section {
  margin-bottom: 16px;
}

.gdpr-section h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  margin-top: 20px;
}

.gdpr-section p {
  margin-bottom: 12px;
  color: rgba(224, 242, 241, 0.9);
}

.gdpr-section ul,
.gdpr-section ol {
  margin: 12px 0;
  padding-left: 24px;
  color: rgba(224, 242, 241, 0.85);
}

.gdpr-section li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.gdpr-section strong {
  color: #4caf50;
  font-weight: 600;
}

.gdpr-agreement-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0 !important; /* Prevent footer from shrinking */
  flex-grow: 0 !important; /* Don't allow footer to grow */
  background: inherit; /* Ensure footer is visible */
  position: relative !important; /* Ensure footer stays in place */
  z-index: 10; /* Ensure footer is above content */
}

.gdpr-agreement-footer button {
  flex: 1;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.gdpr-agreement-footer button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
  .gdpr-agreement-modal {
    max-width: 95%;
    width: 95vw;
}

  .gdpr-agreement-body {
    padding: 16px 20px;
    font-size: 0.9rem;
}

  .gdpr-agreement-footer {
    flex-direction: column;
}

  .gdpr-agreement-footer button {
    width: 100%;
}
}
  padding: 20px 30px 30px 30px;
  gap: 12px;
}

.alert-modal-footer .modal-save-btn {
  min-width: 120px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 2px solid rgba(76, 175, 80, 0.3);
  background: rgba(76, 175, 80, 0.1);
}

.modal-header h3 {
  margin: 0;
  color: #e0f2f1;
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: #b0bec5;
  font-size: 28px;
  cursor: pointer;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-normal);
  padding: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(244, 67, 54, 0.2);
  color: #ffcdd2;
  transform: rotate(90deg);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-body form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body label {
  color: #b0bec5;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body select,
.modal-body textarea {
  background: rgba(38, 50, 56, 0.8);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: #e0f2f1;
  font-size: 1rem;
  transition: all var(--transition-normal);
}

.modal-body input:focus-visible,
.modal-body select:focus-visible,
.modal-body textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.modal-body input[type="range"] {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.modal-body input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #4caf50;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.4);
}

.modal-body input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #4caf50;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.4);
}

.modal-footer {
  padding: 20px 24px;
  border-top: 2px solid rgba(76, 175, 80, 0.3);
  background: rgba(76, 175, 80, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-save-btn {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.modal-save-btn:hover {
  background: linear-gradient(135deg, #66bb6a, #81c784);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.modal-save-btn:active {
  transform: translateY(0);
}

/* Items List (Food/Exercise) */
.items-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 8px;
}

.items-list::-webkit-scrollbar {
  width: 6px;
}

.items-list::-webkit-scrollbar-track {
  background: rgba(38, 50, 56, 0.5);
  border-radius: 3px;
}

.items-list::-webkit-scrollbar-thumb {
  background: rgba(76, 175, 80, 0.5);
  border-radius: 3px;
}

.items-list::-webkit-scrollbar-thumb:hover {
  background: rgba(76, 175, 80, 0.7);
}

/* Medication / Supplements section */
.medication-add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.medication-add-form .input-container { margin-bottom: 0; }
.field-hint-inline {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted, rgba(224, 242, 241, 0.6));
  margin-top: 4px;
}
.medication-taken-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.medication-taken-label {
  font-weight: 500;
  color: var(--text-light);
  margin-right: 8px;
}
.medication-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.medication-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.medication-checkbox-custom {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: rgba(76, 175, 80, 0.25);
  border: 2px solid rgba(76, 175, 80, 0.5);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.medication-checkbox-custom::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.9);
  transition: transform 0.2s;
}
.medication-checkbox:checked + .medication-checkbox-custom {
  background: rgba(76, 175, 80, 0.35);
  border-color: #4caf50;
}
.medication-checkbox:checked + .medication-checkbox-custom::after {
  transform: translateX(20px);
}
.medication-checkbox:focus-visible + .medication-checkbox-custom {
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}
.medication-checkbox-text {
  font-size: 0.95rem;
  color: var(--text-light);
}
.add-medication-btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(76, 175, 80, 0.5);
  background: rgba(76, 175, 80, 0.15);
  color: var(--text-light);
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  align-self: flex-start;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.add-medication-btn:hover {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.7);
}
.medication-items-list {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.medication-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.25);
}
.medication-card-info {
  flex: 1;
  min-width: 0;
}
.medication-card-name {
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 2px;
}
.medication-card-times {
  font-size: 0.85rem;
  color: var(--text-muted, rgba(224, 242, 241, 0.7));
}
.medication-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.medication-card .medication-taken-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.35);
  background: rgba(76, 175, 80, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.medication-card .medication-taken-toggle:hover {
  background: rgba(76, 175, 80, 0.2);
  color: var(--text-light);
}
.medication-card .medication-taken-toggle.taken {
  color: #81c784;
  border-color: rgba(76, 175, 80, 0.5);
  background: rgba(76, 175, 80, 0.2);
}
.medication-card .remove-item-btn {
  flex-shrink: 0;
}
.medication-items-list .empty-items {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted, rgba(224, 242, 241, 0.6));
  font-size: 0.95rem;
  border: 1px dashed rgba(76, 175, 80, 0.3);
  border-radius: var(--radius-md);
  background: rgba(76, 175, 80, 0.05);
}

/* Frequently used options (medications, stressors, symptoms, exercise, food) */
.frequent-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 0;
}
.frequent-chips-wrap:empty { display: none; }
.frequent-label {
  font-size: 0.9rem;
  color: var(--text-muted, rgba(224, 242, 241, 0.7));
  margin-right: 4px;
  flex-shrink: 0;
}
.frequent-chip {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.12);
  color: var(--text-light);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.frequent-chip:hover {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.6);
}
.frequent-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

/* Sticky selected summary on mobile so users see what's selected while scrolling card grids */
@media (max-width: 768px) {
  .selection-summary-sticky {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--background-dark);
    padding-bottom: 8px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  .selection-summary-sticky .items-list {
    margin-bottom: 0;
  }
  body.light-mode .selection-summary-sticky {
    background: #e8f5e9;
    border-bottom-color: rgba(76, 175, 80, 0.25);
  }
}

.empty-items {
  text-align: center;
  color: #78909c;
  padding: 40px 20px;
  font-style: italic;
}

.item-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: rgba(38, 50, 56, 0.6);
  border-radius: 10px;
  border: 1px solid rgba(76, 175, 80, 0.2);
  transition: all var(--transition-normal);
}

.item-entry:hover {
  background: rgba(38, 50, 56, 0.8);
  border-color: rgba(76, 175, 80, 0.4);
  transform: translateX(4px);
}

.item-text {
  color: #e0f2f1;
  font-size: 0.95rem;
  flex: 1;
  word-break: break-word;
}

.remove-item-btn {
  background: rgba(244, 67, 54, 0.3);
  border: 2px solid rgba(244, 67, 54, 0.6);
  color: #ffffff;
  border-radius: 50% !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  padding: 0 !important;
  margin: 0 0 0 12px !important;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.3);
}

.remove-item-btn:hover {
  background: rgba(244, 67, 54, 0.5);
  border-color: rgba(244, 67, 54, 0.8);
  color: #ffffff;
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(244, 67, 54, 0.5);
}

.remove-item-btn:active {
  transform: scale(0.95);
  background: rgba(244, 67, 54, 0.6);
}

/* Add Item Section */
.add-item-section {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  align-items: flex-start;
}

/* Full-screen tile picker (<dialog> + teleported .tile-picker-anchor)
   Closed <dialog> must stay display:none — do not set display:flex on the base selector
   or it overrides the UA and the sheet stays visible at the bottom of the viewport. */
dialog.tile-picker-sheet:not([open]) {
  display: none !important;
}

.tile-picker-sheet[open] {
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
}

.tile-picker-sheet[open]::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.tile-picker-sheet__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  background: linear-gradient(180deg, rgba(14, 18, 20, 0.98) 0%, rgba(8, 12, 14, 0.99) 100%);
  border: 1px solid rgba(76, 175, 80, 0.28);
  border-radius: 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
  animation: tilePickerSheetIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile-picker-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid rgba(76, 175, 80, 0.2);
  flex-shrink: 0;
}

.tile-picker-sheet__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: rgba(224, 242, 241, 0.95);
  line-height: 1.25;
}

.tile-picker-sheet__close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  line-height: 1;
  color: rgba(224, 242, 241, 0.9);
  background: rgba(76, 175, 80, 0.12);
  border: 1px solid rgba(76, 175, 80, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tile-picker-sheet__close:hover {
  background: rgba(76, 175, 80, 0.22);
  border-color: rgba(129, 199, 132, 0.55);
}

.tile-picker-sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

#tilePickerSheetBody .tile-picker-anchor {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

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

@media (min-width: 768px) {
  .tile-picker-sheet[open] {
    justify-content: center;
    align-items: center;
  }

  .tile-picker-sheet__panel {
    width: min(100%, 36rem);
    height: min(92vh, 900px);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: tilePickerSheetInDesktop 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes tilePickerSheetInDesktop {
    from {
      opacity: 0;
      transform: scale(0.98);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-picker-sheet[open]::backdrop {
    backdrop-filter: none;
  }

  .tile-picker-sheet__panel {
    animation: none;
  }
}

body.light-mode .tile-picker-sheet__panel {
  background: linear-gradient(180deg, rgba(250, 252, 250, 0.99) 0%, rgba(236, 245, 236, 0.99) 100%);
  border-color: rgba(76, 175, 80, 0.35);
}

body.light-mode .tile-picker-sheet__title {
  color: var(--text-dark);
}

body.light-mode .tile-picker-sheet__close {
  color: var(--text-dark);
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.35);
}

/* Trigger buttons (replaced <summary>) */
button.food-category-summary,
button.exercise-category-summary,
button.energy-clarity-summary,
button.stressor-tiles-summary,
button.symptom-tiles-summary {
  width: 100%;
  font: inherit;
  text-align: inherit;
  border: none;
  border-radius: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

/* Anchor is moved into the dialog while open; hide the slot so no empty ghost box remains */
.tile-picker-slot:not(:has(.tile-picker-anchor)) {
  display: none;
  height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}

/* While docked in the form (or food/exercise modal lists), hide chip grids — only trigger buttons show.
   When the sheet opens, the anchor is moved under #tilePickerSheetBody and becomes visible there. */
.tile-picker-slot > .tile-picker-anchor {
  display: none !important;
}

#tilePickerSheetBody > .tile-picker-anchor {
  display: block !important;
}

/* Food log: creative card-style meal sections (Breakfast, Lunch, Dinner, Snack) */
.food-meal-collapsible.food-category-block {
  margin-bottom: 0.75rem;
  border: 1px solid rgba(129, 199, 132, 0.35);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.05) 0%, rgba(0, 0, 0, 0.06) 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.25s ease, border-color 0.2s ease;
}

.food-meal-collapsible.food-category-block:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(76, 175, 80, 0.15);
  border-color: rgba(129, 199, 132, 0.5);
}

.food-meal-collapsible .food-category-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(224, 242, 241, 0.95);
  background: transparent;
  border-left: 4px solid rgba(129, 199, 132, 0.75);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.2s ease, border-left-color 0.2s ease;
  user-select: none;
}

.food-meal-collapsible .food-category-summary::-webkit-details-marker,
.food-meal-collapsible .food-category-summary::marker {
  display: none;
}

.food-meal-collapsible .food-category-summary:hover {
  background: rgba(76, 175, 80, 0.12);
  border-left-color: rgba(129, 199, 132, 0.95);
}

.food-meal-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) .food-category-summary {
  border-bottom: 1px solid rgba(76, 175, 80, 0.2);
}

.food-meal-collapsible .food-meal-arrow {
  flex-shrink: 0;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  opacity: 0.9;
}

.food-meal-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) .food-meal-arrow {
  transform: rotate(90deg);
}

.food-meal-collapsible .food-category-body {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 14px 14px;
}

body.light-mode .food-meal-collapsible.food-category-block {
  border-color: rgba(76, 175, 80, 0.4);
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.03) 0%, rgba(255,255,255,0.5) 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body.light-mode .food-meal-collapsible.food-category-block:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

body.light-mode .food-meal-collapsible .food-category-summary {
  color: var(--text-dark);
  border-left-color: rgba(76, 175, 80, 0.6);
}

body.light-mode .food-meal-collapsible .food-category-summary:hover {
  background: rgba(76, 175, 80, 0.08);
  border-left-color: rgba(76, 175, 80, 0.85);
}

body.light-mode .food-meal-collapsible .food-category-body {
  background: rgba(76, 175, 80, 0.04);
}

/* Food log grid of square options — three sections: icon, name, nutrition */
.food-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 0;
}

.food-category-body .food-chips {
  margin-top: 6px;
}

.food-chip {
  aspect-ratio: 1;
  min-height: 88px;
  padding: 6px 6px 8px;
  border-radius: 8px;
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.4);
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  line-height: 1.2;
  gap: 4px;
}

/* Food group colours (grains, protein, dairy, fruits, vegetables, snacks, mixed) */
.food-chip--grains {
  background: rgba(245, 124, 0, 0.25);
  border-color: rgba(255, 152, 0, 0.5);
}

.food-chip--protein {
  background: rgba(211, 47, 47, 0.2);
  border-color: rgba(239, 83, 80, 0.5);
}

.food-chip--dairy {
  background: rgba(2, 119, 189, 0.22);
  border-color: rgba(33, 150, 243, 0.5);
}

.food-chip--fruits {
  background: rgba(194, 24, 91, 0.22);
  border-color: rgba(233, 30, 99, 0.5);
}

.food-chip--vegetables {
  background: rgba(46, 125, 50, 0.25);
  border-color: rgba(76, 175, 80, 0.5);
}

.food-chip--snacks {
  background: rgba(121, 85, 72, 0.3);
  border-color: rgba(161, 136, 127, 0.55);
}

.food-chip--mixed {
  background: rgba(69, 90, 100, 0.3);
  border-color: rgba(96, 125, 139, 0.55);
}

.food-chip--grains:hover { background: rgba(245, 124, 0, 0.4); border-color: rgba(255, 152, 0, 0.7); }
.food-chip--protein:hover { background: rgba(211, 47, 47, 0.35); border-color: rgba(239, 83, 80, 0.7); }
.food-chip--dairy:hover { background: rgba(2, 119, 189, 0.35); border-color: rgba(33, 150, 243, 0.7); }
.food-chip--fruits:hover { background: rgba(194, 24, 91, 0.35); border-color: rgba(233, 30, 99, 0.7); }
.food-chip--vegetables:hover { background: rgba(46, 125, 50, 0.4); border-color: rgba(76, 175, 80, 0.7); }
.food-chip--snacks:hover { background: rgba(121, 85, 72, 0.45); border-color: rgba(161, 136, 127, 0.75); }
.food-chip--mixed:hover { background: rgba(69, 90, 100, 0.45); border-color: rgba(96, 125, 139, 0.75); }

/* Top: icon */
.food-chip .food-chip-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  min-height: 24px;
  color: rgba(76, 175, 80, 0.95);
}

.food-chip--grains .food-chip-icon { color: rgba(255, 193, 7, 0.95); }
.food-chip--protein .food-chip-icon { color: rgba(239, 154, 154, 0.95); }
.food-chip--dairy .food-chip-icon { color: rgba(100, 181, 246, 0.95); }
.food-chip--fruits .food-chip-icon { color: rgba(244, 143, 177, 0.95); }
.food-chip--vegetables .food-chip-icon { color: rgba(129, 199, 132, 0.95); }
.food-chip--snacks .food-chip-icon { color: rgba(188, 170, 164, 0.95); }
.food-chip--mixed .food-chip-icon { color: rgba(144, 164, 174, 0.95); }

.food-chip .food-chip-icon i {
  font-size: inherit;
}

/* Middle: name */
.food-chip .food-chip-name {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 0.7rem;
  line-height: 1.15;
  min-height: 2.3em;
}

/* Bottom: nutrition (cal · P) */
.food-chip .food-chip-nutrition {
  flex: 0 0 auto;
  display: block;
  font-size: 0.65rem;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.food-chip:hover {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.6);
}

.food-chip:active {
  transform: scale(0.97);
}

.food-chip:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4);
}

body.light-mode .food-chip {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.35);
  color: var(--text-dark);
}

body.light-mode .food-chip .food-chip-icon {
  color: rgba(56, 142, 60, 0.9);
}

body.light-mode .food-chip:hover {
  background: rgba(76, 175, 80, 0.22);
  border-color: rgba(76, 175, 80, 0.5);
}

body.light-mode .food-chip--grains { background: rgba(245, 124, 0, 0.15); border-color: rgba(255, 152, 0, 0.4); }
body.light-mode .food-chip--protein { background: rgba(211, 47, 47, 0.12); border-color: rgba(239, 83, 80, 0.4); }
body.light-mode .food-chip--dairy { background: rgba(2, 119, 189, 0.12); border-color: rgba(33, 150, 243, 0.4); }
body.light-mode .food-chip--fruits { background: rgba(194, 24, 91, 0.12); border-color: rgba(233, 30, 99, 0.4); }
body.light-mode .food-chip--vegetables { background: rgba(46, 125, 50, 0.15); border-color: rgba(76, 175, 80, 0.4); }
body.light-mode .food-chip--snacks { background: rgba(121, 85, 72, 0.18); border-color: rgba(161, 136, 127, 0.45); }
body.light-mode .food-chip--mixed { background: rgba(69, 90, 100, 0.18); border-color: rgba(96, 125, 139, 0.45); }

body.light-mode .food-chip--grains:hover { background: rgba(245, 124, 0, 0.25); }
body.light-mode .food-chip--protein:hover { background: rgba(211, 47, 47, 0.2); }
body.light-mode .food-chip--dairy:hover { background: rgba(2, 119, 189, 0.2); }
body.light-mode .food-chip--fruits:hover { background: rgba(194, 24, 91, 0.2); }
body.light-mode .food-chip--vegetables:hover { background: rgba(46, 125, 50, 0.25); }
body.light-mode .food-chip--snacks:hover { background: rgba(121, 85, 72, 0.28); }
body.light-mode .food-chip--mixed:hover { background: rgba(69, 90, 100, 0.28); }

/* Exercise log: creative card-style category sections (Cardio, Strength, etc.) */
.exercise-meal-collapsible.exercise-category-block {
  margin-bottom: 0.75rem;
  border: 1px solid rgba(33, 150, 243, 0.35);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.05) 0%, rgba(0, 0, 0, 0.06) 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.25s ease, border-color 0.2s ease;
}

.exercise-meal-collapsible.exercise-category-block:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(33, 150, 243, 0.2);
  border-color: rgba(33, 150, 243, 0.5);
}

.exercise-meal-collapsible .exercise-category-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(224, 242, 241, 0.95);
  background: transparent;
  border-left: 4px solid rgba(33, 150, 243, 0.75);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.2s ease, border-left-color 0.2s ease;
  user-select: none;
}

.exercise-meal-collapsible .exercise-category-summary::-webkit-details-marker,
.exercise-meal-collapsible .exercise-category-summary::marker {
  display: none;
}

.exercise-meal-collapsible .exercise-category-summary:hover {
  background: rgba(33, 150, 243, 0.12);
  border-left-color: rgba(33, 150, 243, 0.95);
}

.exercise-meal-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) .exercise-category-summary {
  border-bottom: 1px solid rgba(33, 150, 243, 0.2);
}

.exercise-meal-collapsible .exercise-meal-arrow {
  flex-shrink: 0;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  opacity: 0.9;
}

.exercise-meal-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) .exercise-meal-arrow {
  transform: rotate(90deg);
}

.exercise-meal-collapsible .exercise-category-body {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 14px 14px;
}

body.light-mode .exercise-meal-collapsible.exercise-category-block {
  border-color: rgba(33, 150, 243, 0.4);
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.03) 0%, rgba(255,255,255,0.5) 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body.light-mode .exercise-meal-collapsible.exercise-category-block:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

body.light-mode .exercise-meal-collapsible .exercise-category-summary {
  color: var(--text-dark);
  border-left-color: rgba(33, 150, 243, 0.6);
}

body.light-mode .exercise-meal-collapsible .exercise-category-summary:hover {
  background: rgba(33, 150, 243, 0.08);
  border-left-color: rgba(33, 150, 243, 0.85);
}

body.light-mode .exercise-meal-collapsible .exercise-category-body {
  background: rgba(33, 150, 243, 0.04);
}

/* Exercise tile grid — same three-section layout as food chips */
.exercise-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 0;
}

.exercise-chip {
  aspect-ratio: 1;
  min-height: 88px;
  padding: 6px 6px 8px;
  border-radius: 8px;
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.4);
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  line-height: 1.2;
  gap: 4px;
}

.exercise-chip .exercise-chip-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  min-height: 24px;
  color: rgba(76, 175, 80, 0.95);
}

.exercise-chip .exercise-chip-icon i {
  font-size: inherit;
}

.exercise-chip .exercise-chip-name {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 0.7rem;
  line-height: 1.15;
  min-height: 2.3em;
}

.exercise-chip .exercise-chip-duration {
  flex: 0 0 auto;
  font-size: 0.65rem;
  opacity: 0.9;
  white-space: nowrap;
}

.exercise-chip:hover {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.6);
}

.exercise-chip:active {
  transform: scale(0.97);
}

.exercise-chip:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4);
}

body.light-mode .exercise-chip {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.35);
  color: var(--text-dark);
}

body.light-mode .exercise-chip .exercise-chip-icon {
  color: rgba(56, 142, 60, 0.9);
}

body.light-mode .exercise-chip:hover {
  background: rgba(76, 175, 80, 0.22);
  border-color: rgba(76, 175, 80, 0.5);
}

/* Exercise tile colours by category (cardio, strength, flexibility, balance, recovery) */
.exercise-chip--cardio {
  background: rgba(211, 47, 47, 0.22);
  border-color: rgba(239, 83, 80, 0.5);
}
.exercise-chip--cardio .exercise-chip-icon { color: rgba(239, 154, 154, 0.95); }
.exercise-chip--cardio:hover { background: rgba(211, 47, 47, 0.35); border-color: rgba(239, 83, 80, 0.7); }

.exercise-chip--strength {
  background: rgba(245, 124, 0, 0.25);
  border-color: rgba(255, 152, 0, 0.5);
}
.exercise-chip--strength .exercise-chip-icon { color: rgba(255, 193, 7, 0.95); }
.exercise-chip--strength:hover { background: rgba(245, 124, 0, 0.4); border-color: rgba(255, 152, 0, 0.7); }

.exercise-chip--flexibility {
  background: rgba(142, 36, 170, 0.22);
  border-color: rgba(186, 104, 200, 0.5);
}
.exercise-chip--flexibility .exercise-chip-icon { color: rgba(206, 147, 216, 0.95); }
.exercise-chip--flexibility:hover { background: rgba(142, 36, 170, 0.35); border-color: rgba(186, 104, 200, 0.7); }

.exercise-chip--balance {
  background: rgba(0, 150, 136, 0.25);
  border-color: rgba(38, 166, 154, 0.5);
}
.exercise-chip--balance .exercise-chip-icon { color: rgba(77, 208, 225, 0.95); }
.exercise-chip--balance:hover { background: rgba(0, 150, 136, 0.4); border-color: rgba(38, 166, 154, 0.7); }

.exercise-chip--recovery {
  background: rgba(2, 119, 189, 0.22);
  border-color: rgba(33, 150, 243, 0.5);
}
.exercise-chip--recovery .exercise-chip-icon { color: rgba(100, 181, 246, 0.95); }
.exercise-chip--recovery:hover { background: rgba(2, 119, 189, 0.35); border-color: rgba(33, 150, 243, 0.7); }

body.light-mode .exercise-chip--cardio { background: rgba(211, 47, 47, 0.15); }
body.light-mode .exercise-chip--strength { background: rgba(245, 124, 0, 0.18); }
body.light-mode .exercise-chip--flexibility { background: rgba(142, 36, 170, 0.15); }
body.light-mode .exercise-chip--balance { background: rgba(0, 150, 136, 0.18); }
body.light-mode .exercise-chip--recovery { background: rgba(2, 119, 189, 0.15); }

/* Symptom tiles: compact trigger on the form */
.symptom-tiles-collapsible {
  margin-top: 12px;
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.symptom-tiles-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: none;
}

.symptom-tiles-collapsible .symptom-tiles-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(224, 242, 241, 0.95);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 188, 212, 0.4);
  border-radius: 12px;
  border-left: 4px solid rgba(0, 188, 212, 0.85);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  width: 100%;
  box-sizing: border-box;
}

.symptom-tiles-collapsible .symptom-tiles-summary::-webkit-details-marker,
.symptom-tiles-collapsible .symptom-tiles-summary::marker {
  display: none;
}

.symptom-tiles-collapsible .symptom-tiles-summary:hover {
  background: rgba(0, 188, 212, 0.12);
  border-left-color: rgba(0, 188, 212, 0.9);
}

.symptom-tiles-container {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 14px 14px;
}

/* Symptom square tiles — same style as food chips (grid, aspect-ratio 1, icon + name) */
.symptom-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 0;
}

.symptom-chip {
  aspect-ratio: 1;
  min-height: 88px;
  padding: 6px 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.15);
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  line-height: 1.2;
  gap: 4px;
}

.symptom-chip .symptom-chip-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  min-height: 24px;
}

.symptom-chip .symptom-chip-icon i {
  font-size: inherit;
}

.symptom-chip .symptom-chip-name {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 0.7rem;
  line-height: 1.15;
  min-height: 2.3em;
}

.symptom-chip--digestive {
  background: rgba(121, 85, 72, 0.35);
  border-color: rgba(161, 136, 127, 0.5);
}
.symptom-chip--digestive .symptom-chip-icon { color: rgba(188, 170, 164, 0.95); }
.symptom-chip--digestive:hover { background: rgba(121, 85, 72, 0.6); border-color: rgba(161, 136, 127, 0.85); }

.symptom-chip--respiratory {
  background: rgba(2, 119, 189, 0.35);
  border-color: rgba(33, 150, 243, 0.5);
}
.symptom-chip--respiratory .symptom-chip-icon { color: rgba(100, 181, 246, 0.95); }
.symptom-chip--respiratory:hover { background: rgba(2, 119, 189, 0.6); border-color: rgba(33, 150, 243, 0.85); }

.symptom-chip--neurological {
  background: rgba(142, 36, 170, 0.35);
  border-color: rgba(186, 104, 200, 0.5);
}
.symptom-chip--neurological .symptom-chip-icon { color: rgba(206, 147, 216, 0.95); }
.symptom-chip--neurological:hover { background: rgba(142, 36, 170, 0.6); border-color: rgba(186, 104, 200, 0.85); }

.symptom-chip--systemic {
  background: rgba(211, 47, 47, 0.35);
  border-color: rgba(239, 83, 80, 0.5);
}
.symptom-chip--systemic .symptom-chip-icon { color: rgba(239, 154, 154, 0.95); }
.symptom-chip--systemic:hover { background: rgba(211, 47, 47, 0.6); border-color: rgba(239, 83, 80, 0.85); }

.symptom-chip--skin {
  background: rgba(46, 125, 50, 0.35);
  border-color: rgba(76, 175, 80, 0.5);
}
.symptom-chip--skin .symptom-chip-icon { color: rgba(129, 199, 132, 0.95); }
.symptom-chip--skin:hover { background: rgba(46, 125, 50, 0.6); border-color: rgba(76, 175, 80, 0.85); }

.symptom-chip--other {
  background: rgba(97, 97, 97, 0.35);
  border-color: rgba(158, 158, 158, 0.5);
}
.symptom-chip--other .symptom-chip-icon { color: rgba(188, 170, 164, 0.95); }
.symptom-chip--other:hover { background: rgba(97, 97, 97, 0.6); border-color: rgba(158, 158, 158, 0.85); }

.symptom-chip:active { transform: scale(0.97); }
.symptom-chip:focus { outline: none; box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4); }

body.light-mode .symptom-tiles-collapsible { border: none; background: transparent; box-shadow: none; }
body.light-mode .symptom-tiles-collapsible .symptom-tiles-summary { color: var(--text-dark); background: rgba(255, 255, 255, 0.65); border: 1px solid rgba(0, 150, 136, 0.4); border-left: 4px solid rgba(0, 150, 136, 0.75); }
body.light-mode .symptom-tiles-collapsible .symptom-tiles-summary:hover { background: rgba(0, 150, 136, 0.08); border-left-color: rgba(0, 150, 136, 0.85); }
body.light-mode .symptom-tiles-container { background: rgba(0, 150, 136, 0.04); }
body.light-mode .symptom-chip { color: var(--text-dark); }
body.light-mode .symptom-chip--digestive { background: rgba(121, 85, 72, 0.25); }
body.light-mode .symptom-chip--respiratory { background: rgba(2, 119, 189, 0.25); }
body.light-mode .symptom-chip--neurological { background: rgba(142, 36, 170, 0.25); }
body.light-mode .symptom-chip--systemic { background: rgba(211, 47, 47, 0.25); }
body.light-mode .symptom-chip--skin { background: rgba(46, 125, 50, 0.25); }
body.light-mode .symptom-chip--other { background: rgba(97, 97, 97, 0.25); }

/* Energy & Mental Clarity: collapsible section with mood-colored tiles */
/* Selected display: same tile style as medication empty state (dashed green border, dark green-grey bg) */
.energy-clarity-selected {
  font-size: 0.95rem;
  color: var(--text-muted, rgba(224, 242, 241, 0.6));
  font-style: italic;
  margin: 0 0 8px 0;
  min-height: 1.25rem;
  padding: 14px 16px;
  text-align: center;
  border: 1px dashed rgba(76, 175, 80, 0.3);
  border-radius: var(--radius-md);
  background: rgba(76, 175, 80, 0.05);
}

/* Energy & mental clarity: compact trigger on the form; full chrome only in the tile sheet */
.energy-clarity-collapsible {
  margin-top: 10px;
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.energy-clarity-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: none;
}

.energy-clarity-collapsible .energy-clarity-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(224, 242, 241, 0.95);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(76, 175, 80, 0.38);
  border-radius: 12px;
  border-left: 4px solid rgba(76, 175, 80, 0.85);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  width: 100%;
  box-sizing: border-box;
}

.energy-clarity-collapsible .energy-clarity-summary::-webkit-details-marker,
.energy-clarity-collapsible .energy-clarity-summary::marker {
  display: none;
}

.energy-clarity-collapsible .energy-clarity-summary:hover {
  background: rgba(76, 175, 80, 0.12);
  border-left-color: rgba(76, 175, 80, 0.95);
}

/* Shared: group tiles by colour across the whole UI (food, exercise, stressors, symptoms, energy) */
.tile-group,
.food-tiles-by-group .food-group,
.food-group,
.stressor-group,
.symptom-group {
  margin-bottom: 12px;
}

.tile-group:last-child,
.food-tiles-by-group .food-group:last-child,
.stressor-group:last-child,
.symptom-group:last-child {
  margin-bottom: 0;
}

.tile-group__title,
.food-group__title,
.stressor-group__title,
.symptom-group__title {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(224, 242, 241, 0.85);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tile-group__tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.light-mode .tile-group__title,
body.light-mode .food-group__title,
body.light-mode .stressor-group__title,
body.light-mode .symptom-group__title {
  color: var(--text-dark);
}

.energy-clarity-tiles {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 14px 14px;
}

/* Energy & mental clarity square tiles — same style as food/stressor chips (grid, aspect-ratio 1, icon + name) */
.energy-clarity-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 0;
}

.energy-clarity-chip {
  aspect-ratio: 1;
  min-height: 88px;
  padding: 6px 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.15);
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  line-height: 1.2;
  gap: 4px;
}

.energy-clarity-chip .energy-clarity-chip-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  min-height: 24px;
}

.energy-clarity-chip .energy-clarity-chip-icon i {
  font-size: inherit;
}

.energy-clarity-chip .energy-clarity-chip-name {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 0.7rem;
  line-height: 1.15;
  min-height: 2.3em;
}

.energy-clarity-chip--positive {
  background: rgba(46, 125, 50, 0.35);
  border-color: rgba(76, 175, 80, 0.5);
}
.energy-clarity-chip--positive .energy-clarity-chip-icon { color: rgba(129, 199, 132, 0.95); }
.energy-clarity-chip--positive:hover { background: rgba(46, 125, 50, 0.5); border-color: rgba(76, 175, 80, 0.7); }

.energy-clarity-chip--neutral {
  background: rgba(2, 119, 189, 0.35);
  border-color: rgba(33, 150, 243, 0.5);
}
.energy-clarity-chip--neutral .energy-clarity-chip-icon { color: rgba(100, 181, 246, 0.95); }
.energy-clarity-chip--neutral:hover { background: rgba(2, 119, 189, 0.5); border-color: rgba(33, 150, 243, 0.7); }

.energy-clarity-chip--negative {
  background: rgba(183, 28, 28, 0.35);
  border-color: rgba(244, 67, 54, 0.5);
}
.energy-clarity-chip--negative .energy-clarity-chip-icon { color: rgba(239, 154, 154, 0.95); }
.energy-clarity-chip--negative:hover { background: rgba(183, 28, 28, 0.5); border-color: rgba(244, 67, 54, 0.7); }

.energy-clarity-chip.selected {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}
.energy-clarity-chip--positive.selected { background: rgba(46, 125, 50, 0.55); border-color: rgba(129, 199, 132, 0.9); }
.energy-clarity-chip--neutral.selected { background: rgba(2, 119, 189, 0.5); border-color: rgba(100, 181, 246, 0.9); }
.energy-clarity-chip--negative.selected { background: rgba(183, 28, 28, 0.5); border-color: rgba(239, 154, 154, 0.9); }

.energy-clarity-chip:active { transform: scale(0.97); }
.energy-clarity-chip:focus { outline: none; box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4); }

body.light-mode .energy-clarity-selected {
  color: rgba(55, 71, 79, 0.85);
  border-color: rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.06);
}

body.light-mode .energy-clarity-collapsible {
  border: none;
  background: transparent;
  box-shadow: none;
}

body.light-mode .energy-clarity-collapsible .energy-clarity-summary {
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(76, 175, 80, 0.4);
  border-left: 4px solid rgba(76, 175, 80, 0.65);
}

body.light-mode .energy-clarity-collapsible .energy-clarity-summary:hover {
  background: rgba(76, 175, 80, 0.08);
  border-left-color: rgba(76, 175, 80, 0.85);
}

body.light-mode .energy-clarity-tiles {
  background: rgba(76, 175, 80, 0.04);
}

body.light-mode .energy-clarity-chip {
  color: var(--text-dark);
}

body.light-mode .energy-clarity-chip--positive {
  background: rgba(46, 125, 50, 0.2);
  border-color: rgba(76, 175, 80, 0.4);
}

body.light-mode .energy-clarity-chip--neutral {
  background: rgba(2, 119, 189, 0.2);
  border-color: rgba(33, 150, 243, 0.4);
}

body.light-mode .energy-clarity-chip--negative {
  background: rgba(183, 28, 28, 0.2);
  border-color: rgba(244, 67, 54, 0.4);
}

/* Stress & Triggers: compact trigger on the form; tiles only in the sheet */
.stressor-tiles-collapsible {
  margin-top: 12px;
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.stressor-tiles-collapsible:has(.tile-picker-trigger[aria-expanded="true"]) {
  box-shadow: none;
}

.stressor-tiles-collapsible .stressor-tiles-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(224, 242, 241, 0.95);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 152, 0, 0.45);
  border-radius: 12px;
  border-left: 4px solid rgba(255, 152, 0, 0.95);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  width: 100%;
  box-sizing: border-box;
}

.stressor-tiles-collapsible .stressor-tiles-summary::-webkit-details-marker,
.stressor-tiles-collapsible .stressor-tiles-summary::marker {
  display: none;
}

.stressor-tiles-collapsible .stressor-tiles-summary:hover {
  background: rgba(255, 152, 0, 0.12);
  border-left-color: rgba(255, 152, 0, 1);
}

.stressor-tiles-container {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 14px 14px;
}

/* Stressor / trigger square tiles — same style as food chips (grid, aspect-ratio 1, icon + name) */
.stressor-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 0;
}

.stressor-chip {
  aspect-ratio: 1;
  min-height: 88px;
  padding: 6px 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.15);
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  line-height: 1.2;
  gap: 4px;
}

.stressor-chip .stressor-chip-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  min-height: 24px;
}

.stressor-chip .stressor-chip-icon i {
  font-size: inherit;
}

.stressor-chip .stressor-chip-name {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 0.7rem;
  line-height: 1.15;
  min-height: 2.3em;
}

.stressor-chip--work {
  background: rgba(245, 124, 0, 0.45);
  border-color: rgba(255, 152, 0, 0.6);
}
.stressor-chip--work .stressor-chip-icon { color: rgba(255, 193, 7, 0.95); }
.stressor-chip--work:hover { background: rgba(245, 124, 0, 0.6); border-color: rgba(255, 152, 0, 0.85); }

.stressor-chip--relationship {
  background: rgba(142, 36, 170, 0.45);
  border-color: rgba(186, 104, 200, 0.6);
}
.stressor-chip--relationship .stressor-chip-icon { color: rgba(206, 147, 216, 0.95); }
.stressor-chip--relationship:hover { background: rgba(142, 36, 170, 0.6); border-color: rgba(186, 104, 200, 0.85); }

.stressor-chip--physical {
  background: rgba(0, 150, 136, 0.45);
  border-color: rgba(38, 166, 154, 0.6);
}
.stressor-chip--physical .stressor-chip-icon { color: rgba(77, 208, 225, 0.95); }
.stressor-chip--physical:hover { background: rgba(0, 150, 136, 0.6); border-color: rgba(38, 166, 154, 0.85); }

.stressor-chip--environment {
  background: rgba(2, 119, 189, 0.45);
  border-color: rgba(33, 150, 243, 0.6);
}
.stressor-chip--environment .stressor-chip-icon { color: rgba(100, 181, 246, 0.95); }
.stressor-chip--environment:hover { background: rgba(2, 119, 189, 0.6); border-color: rgba(33, 150, 243, 0.85); }

.stressor-chip--emotional {
  background: rgba(211, 47, 47, 0.45);
  border-color: rgba(239, 83, 80, 0.6);
}
.stressor-chip--emotional .stressor-chip-icon { color: rgba(239, 154, 154, 0.95); }
.stressor-chip--emotional:hover { background: rgba(211, 47, 47, 0.6); border-color: rgba(239, 83, 80, 0.85); }

.stressor-chip--other {
  background: rgba(97, 97, 97, 0.45);
  border-color: rgba(158, 158, 158, 0.6);
}
.stressor-chip--other .stressor-chip-icon { color: rgba(188, 170, 164, 0.95); }
.stressor-chip--other:hover { background: rgba(97, 97, 97, 0.6); border-color: rgba(158, 158, 158, 0.85); }

.stressor-chip:active { transform: scale(0.97); }
.stressor-chip:focus { outline: none; box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4); }

body.light-mode .stressor-tiles-collapsible {
  border: none;
  background: transparent;
  box-shadow: none;
}

body.light-mode .stressor-tiles-collapsible .stressor-tiles-summary {
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 152, 0, 0.45);
  border-left: 4px solid rgba(255, 152, 0, 0.85);
}

body.light-mode .stressor-tiles-collapsible .stressor-tiles-summary:hover {
  background: rgba(255, 152, 0, 0.08);
  border-left-color: rgba(255, 152, 0, 0.9);
}

body.light-mode .stressor-tiles-container {
  background: rgba(255, 152, 0, 0.04);
}

body.light-mode .stressor-chip {
  color: var(--text-dark);
}

body.light-mode .stressor-chip--work { background: rgba(245, 124, 0, 0.25); }
body.light-mode .stressor-chip--relationship { background: rgba(142, 36, 170, 0.25); }
body.light-mode .stressor-chip--physical { background: rgba(0, 150, 136, 0.25); }
body.light-mode .stressor-chip--environment { background: rgba(2, 119, 189, 0.25); }
body.light-mode .stressor-chip--emotional { background: rgba(211, 47, 47, 0.25); }
body.light-mode .stressor-chip--other { background: rgba(97, 97, 97, 0.25); }

.item-input {
  flex: 1;
  min-width: 0; /* Allow flex item to shrink below content size */
  background: rgba(38, 50, 56, 0.8);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  color: #e0f2f1;
  font-size: 1rem;
  transition: all var(--transition-normal);
}

.item-input:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.item-input::placeholder {
  color: #78909c;
}

.add-item-btn {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
  width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-start;
}

.add-item-btn:hover {
  background: linear-gradient(135deg, #66bb6a, #81c784);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.add-item-btn:active {
  transform: translateY(0);
}

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

@keyframes deleteSlideOut {
  0% { 
    opacity: 1; 
    transform: translateX(0); 
    max-height: 200px; 
    margin-top: 10px; 
  }
  50% { 
    opacity: 0.3; 
    transform: translateX(-100%); 
    max-height: 200px; 
    margin-top: 10px; 
  }
  100% { 
    opacity: 0; 
    transform: translateX(-100%); 
    max-height: 0; 
    margin-top: 0; 
    padding-top: 0; 
    padding-bottom: 0; 
  }
}

.hidden {
  display: none;
}

/* Chart view panels: combinedChartContainer & balanceChartContainer use .chart-container + .hidden.
   styles-charts.css loads later and sets .chart-container { display: block }, which was overriding
   .hidden — show only one of combined / balance / individual at a time. */
#combinedChartContainer.hidden,
#balanceChartContainer.hidden,
#individualChartsContainer.hidden {
  display: none !important;
}
.chart-container.hidden {
  display: none !important;
}


.button-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

.toggle-button, .clear-button, .export-button {
  background: var(--primary-gradient);
  border: none;
  padding: 18px 24px;
  color: white;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  max-width: none;
  min-height: 56px;
  font-size: 1.1rem;
  font-weight: 600;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
  transition: all var(--transition-normal);
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.toggle-button::before, .clear-button::before, .export-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.toggle-button:hover, .clear-button:hover, .export-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4), var(--primary-glow);
  background: linear-gradient(135deg, #388e3c 0%, #4caf50 50%, #66bb6a 100%);
}

.toggle-button:hover::before, .clear-button:hover::before, .export-button:hover::before {
  width: 300px;
  height: 300px;
}

.toggle-button:active, .clear-button:active, .export-button:active {
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

.highlight {
  background: linear-gradient(135deg, rgba(255, 87, 34, 0.3), rgba(255, 152, 0, 0.2));
  border-color: rgba(255, 87, 34, 0.5);
  animation: glow 2s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(255, 87, 34, 0.3);
}

/* Flare-up entry styling - Red glow effect */
.entry.flare-up-entry {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.25), rgba(229, 57, 53, 0.15));
  border-color: rgba(244, 67, 54, 0.6);
  animation: redGlow 2s ease-in-out infinite;
  box-shadow: 
    0 0 20px rgba(244, 67, 54, 0.4),
    0 0 40px rgba(244, 67, 54, 0.2),
    0 4px 15px rgba(0, 0, 0, 0.3);
}

.entry.flare-up-entry:hover {
  box-shadow: 
    0 0 30px rgba(244, 67, 54, 0.6),
    0 0 60px rgba(244, 67, 54, 0.3),
    0 8px 25px rgba(244, 67, 54, 0.2);
  border-color: rgba(244, 67, 54, 0.8);
}

.entry.flare-up-entry::before {
  background: linear-gradient(90deg, transparent, rgba(244, 67, 54, 0.15), transparent);
}

@keyframes redGlow {
  0%, 100% {
    box-shadow: 
      0 0 20px rgba(244, 67, 54, 0.4),
      0 0 40px rgba(244, 67, 54, 0.2),
      0 4px 15px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 
      0 0 30px rgba(244, 67, 54, 0.6),
      0 0 60px rgba(244, 67, 54, 0.4),
      0 4px 15px rgba(0, 0, 0, 0.3);
  }
}

/* AI Summary Button - Pink/Magenta Pulsing Glow Animation (matches button text color) */
@keyframes aiSummaryRedPulse {
  0%, 100% {
    box-shadow: 
      0 0 10px rgba(233, 30, 99, 0.5),
      0 0 20px rgba(233, 30, 99, 0.3),
      0 0 30px rgba(233, 30, 99, 0.2),
      0 4px 12px rgba(233, 30, 99, 0.2);
  }
  50% {
    box-shadow: 
      0 0 20px rgba(233, 30, 99, 0.7),
      0 0 40px rgba(233, 30, 99, 0.5),
      0 0 60px rgba(233, 30, 99, 0.3),
      0 4px 12px rgba(233, 30, 99, 0.3);
  }
}

/* AI Summary Overlay */
.ai-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: flex !important;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  pointer-events: all;
}

.ai-modal {
  background: var(--card-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 30px;
  max-width: 650px;
  max-height: 85vh;
  width: 90%;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 40px rgba(76, 175, 80, 0.3);
  border: 2px solid rgba(76, 175, 80, 0.5);
  animation: modalFloatIn 0.4s var(--ease-fluid);
  z-index: 10001;
  pointer-events: all;
}

.ai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

.ai-modal-title {
  color: var(--primary-color);
  margin: 0;
  font-size: 1.2rem;
}

.ai-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  width: auto;
  min-height: auto;
}

.ai-close-btn:hover {
  color: var(--primary-color);
}

.ai-content {
  max-height: 60vh;
  overflow-y: auto;
  color: var(--text-light);
  line-height: 1.6;
}

.ai-iframe {
  width: 100%;
  height: 60vh;
  border: none;
  border-radius: 8px;
  background: #fff;
}

.ai-loading {
  text-align: center;
  padding: 20px;
}

.spinner {
  border: 4px solid rgba(76, 175, 80, 0.2);
  border-top: 4px solid var(--primary-color);
  border-right: 4px solid rgba(76, 175, 80, 0.6);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  margin: 0 auto 20px;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
}

@keyframes spin {
  0% { 
    transform: rotate(0deg) scale(1);
    border-top-color: var(--primary-color);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
    border-top-color: #66bb6a;
  }
  100% { 
    transform: rotate(360deg) scale(1);
    border-top-color: var(--primary-color);
  }
}

.ai-error {
  color: #f44336;
  text-align: center;
  padding: 20px;
}

.security-warning {
  background: #ff5722;
  color: white;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.9rem;
  text-align: center;
}

/* Header buttons wrap: Targets (face) + Settings */
.header-buttons-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10002;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: all;
}

/* Floating Settings Button */
/* Settings Button - Top Right */
.settings-button-top {
  position: relative;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  min-height: auto;
  pointer-events: all;
}

.targets-button-top {
  position: relative;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  min-height: auto;
  pointer-events: all;
}

.targets-button-top:hover {
  background: rgba(76, 175, 80, 0.1);
  transform: scale(1.1);
}

.targets-button-top:active {
  transform: scale(0.95);
}

.targets-face-icon {
  width: 24px;
  height: 24px;
  color: var(--primary-color);
  transition: all var(--transition-normal);
  filter: drop-shadow(0 2px 4px rgba(76, 175, 80, 0.3));
}

.targets-button-top:hover .targets-face-icon {
  color: #66bb6a;
  filter: drop-shadow(0 4px 8px rgba(76, 175, 80, 0.5));
}

body.light-mode .targets-face-icon {
  color: var(--primary-color);
}


.settings-button-top:hover {
  background: rgba(76, 175, 80, 0.1);
  transform: scale(1.1) rotate(90deg);
}

.settings-button-top:active {
  transform: scale(0.95) rotate(90deg);
}

.settings-cog {
  width: 24px;
  height: 24px;
  color: var(--primary-color);
  transition: all var(--transition-normal);
  filter: drop-shadow(0 2px 4px rgba(76, 175, 80, 0.3));
}

.settings-button-top:hover .settings-cog {
  color: #66bb6a;
  filter: drop-shadow(0 4px 8px rgba(76, 175, 80, 0.5));
  transform: scale(1.1);
}

body.light-mode .settings-cog {
  color: var(--primary-color);
  filter: drop-shadow(0 2px 4px rgba(76, 175, 80, 0.4));
}

body.light-mode .settings-button-top:hover {
  background: rgba(76, 175, 80, 0.15);
}

/* Goals & Targets Modal */
.goals-modal-overlay {
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.goals-modal-content {
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.goals-modal-body {
  padding: 16px 20px;
}

.goals-slider-group {
  margin-bottom: 20px;
}

.goals-slider-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-light);
}

.goals-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.goals-slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.goals-value-label {
  min-width: 48px;
  text-align: right;
  font-weight: 600;
  color: rgba(76, 175, 80, 0.95);
}

body.light-mode .goals-slider-group label {
  color: var(--text-dark);
}

body.light-mode .goals-value-label {
  color: var(--primary-color);
}

/* Goals sliders inside tutorial (Goals & targets slide) */
.tutorial-goals-sliders {
  margin-top: 14px;
  margin-bottom: 4px;
}
.tutorial-goals-sliders .goals-slider-group {
  margin-bottom: 14px;
}
.tutorial-goals-sliders .goals-slider-group:last-of-type {
  margin-bottom: 0;
}

/* Goals progress block on Log tab */
.goals-progress-block {
  margin: 0 20px 16px;
  padding: 14px 16px;
  background: rgba(76, 175, 80, 0.08);
  border: 1px solid rgba(76, 175, 80, 0.25);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-light);
}

.goals-progress-title {
  font-weight: 700;
  color: rgba(76, 175, 80, 0.95);
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.goals-metric-row {
  margin-bottom: 12px;
}
.goals-metric-row:last-child {
  margin-bottom: 0;
}

.goals-metric-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.goals-icon {
  color: rgba(76, 175, 80, 0.85);
  font-size: 0.85rem;
  width: 1.1em;
  text-align: center;
}

.goals-metric-name {
  font-weight: 600;
  color: var(--text-light);
}

.goals-metric-nums {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted, rgba(255,255,255,0.75));
}

.goals-bar-wrap {
  height: 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.goals-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(76, 175, 80, 0.6), rgba(76, 175, 80, 0.9));
  transition: width 0.3s ease;
}

.goals-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.goals-days {
  display: inline-flex;
  gap: 3px;
}

.goals-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.goals-dot.filled {
  background: rgba(76, 175, 80, 0.9);
}

.goals-status-pill {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.goals-status-pill.on-track {
  background: rgba(76, 175, 80, 0.25);
  color: rgba(76, 175, 80, 0.95);
}

.goals-status-pill.mixed {
  background: rgba(255, 193, 7, 0.25);
  color: rgba(255, 193, 7, 0.95);
}

.goals-status-pill.below {
  background: rgba(244, 67, 54, 0.2);
  color: rgba(255, 138, 128, 0.95);
}

body.light-mode .goals-progress-block {
  background: rgba(76, 175, 80, 0.06);
  border-color: rgba(76, 175, 80, 0.3);
  color: var(--text-dark);
}

body.light-mode .goals-progress-title {
  color: var(--primary-color);
}

body.light-mode .goals-metric-name {
  color: var(--text-dark);
}

body.light-mode .goals-metric-nums {
  color: var(--text-muted, rgba(0,0,0,0.6));
}

body.light-mode .goals-bar-wrap {
  background: rgba(0,0,0,0.1);
}

body.light-mode .goals-dot {
  background: rgba(0,0,0,0.2);
}

body.light-mode .goals-dot.filled {
  background: var(--primary-color);
}

body.light-mode .goals-status-pill.on-track {
  background: rgba(76, 175, 80, 0.2);
  color: var(--primary-color);
}

body.light-mode .goals-status-pill.mixed {
  background: rgba(255, 193, 7, 0.3);
  color: #b38600;
}

body.light-mode .goals-status-pill.below {
  background: rgba(244, 67, 54, 0.15);
  color: #c62828;
}

/* AI Brain Button - Floating */
/* AI Tab Button - Pink Styling */
.tab-btn.ai-tab-btn {
  border: 2px solid rgba(233, 30, 99, 0.3);
}

.tab-btn.ai-tab-btn::before {
  display: none; /* Remove the indicator line */
}

.tab-btn.ai-tab-btn:hover:not(.active) {
  background: rgba(233, 30, 99, 0.15);
  border-color: rgba(233, 30, 99, 0.5);
  color: #ffffff;
  transform: translateY(-2px);
}

.tab-btn.ai-tab-btn.active {
  background: rgba(233, 30, 99, 0.15);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(233, 30, 99, 0.3);
  border-color: rgba(233, 30, 99, 0.6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.tab-btn.ai-tab-btn.active:hover {
  background: rgba(233, 30, 99, 0.15) !important;
  color: #ffffff !important;
  border-color: rgba(233, 30, 99, 0.9) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) !important;
  box-shadow: 0 0 20px rgba(233, 30, 99, 0.5), inset 0 0 10px rgba(233, 30, 99, 0.1) !important;
}


/* Remove any conflicting AI tab styles - let it use standard tab-content styles */

.ai-modal-description {
  background: rgba(233, 30, 99, 0.1);
  border: 1px solid rgba(233, 30, 99, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  color: rgba(224, 242, 241, 0.9);
  line-height: 1.6;
}

.ai-generate-btn {
  background: linear-gradient(135deg, #e91e63, #f06292);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: auto;
  width: auto;
  margin: 0;
  align-self: center;
}

.ai-generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4), 0 0 20px rgba(233, 30, 99, 0.3);
  background: linear-gradient(135deg, #c2185b, #e91e63);
}

.ai-results-wrapper {
  width: 100%;
  margin-top: 1rem;
}

/* Removed duplicate .ai-results-container rules - using the one above */

/* AI Modal Overlay */
.ai-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: transparent;
  display: none;
  z-index: 10001;
  pointer-events: all;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.ai-modal-overlay[style*="display: flex"] {
  display: flex !important;
}

.ai-modal-content {
  background: var(--card-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 0;
  width: 90vw;
  max-width: 1200px;
  height: 90vh;
  max-height: 85vh;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(233, 30, 99, 0.3);
  border: 2px solid rgba(233, 30, 99, 0.5);
  animation: modalFloatIn 0.4s var(--ease-fluid);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10002;
  pointer-events: all;
}

.ai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 30px 20px 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.ai-modal-title {
  color: #e91e63;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #e91e63, #f06292);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ai-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  transition: all var(--transition-normal);
  border-radius: 50%;
  line-height: 1;
  box-sizing: border-box;
  flex-shrink: 0;
}

.ai-modal-close:hover {
  color: #e91e63;
  background: rgba(233, 30, 99, 0.2);
  transform: rotate(90deg);
}

.ai-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding: 30px;
  max-height: calc(100vh - 200px);
  -webkit-overflow-scrolling: touch;
}

/* Settings Menu */
.settings-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  opacity: 0;
  z-index: 99999 !important;
  pointer-events: all;
  overflow: hidden;
  overflow-x: hidden;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 !important;
  isolation: isolate;
  transition: opacity var(--transition-normal) var(--ease-fluid);
}

.settings-overlay.settings-overlay--open {
  opacity: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-overlay[style*="display: flex"],
.settings-overlay[style*="display:flex"],
.settings-overlay[style*="display: block"] {
  display: block !important;
}

.settings-overlay[style*="display: block"] .settings-menu {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.settings-menu {
  background: linear-gradient(135deg, #263238, #37474f);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  max-width: 450px;
  width: 90%;
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(100%, -50%);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(76, 175, 80, 0.3);
  border: 2px solid rgba(76, 175, 80, 0.5);
  max-height: calc(85vh - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  z-index: 100000 !important;
  pointer-events: all;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  padding: 0 !important;
  isolation: isolate;
  opacity: 0;
  transition: transform 0.35s var(--ease-fluid), opacity 0.35s var(--ease-fluid);
}

.settings-overlay.settings-overlay--open .settings-menu {
  transform: translate(-50%, -50%);
  opacity: 1;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 30px 20px 30px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
  background: linear-gradient(135deg, #263238, #37474f);
  border-radius: 24px 24px 0 0;
}

.settings-content {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding: 10px 30px 0 30px;
  padding-top: 10px;
  padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom, 0px)));
  min-height: 0;
  margin-bottom: env(safe-area-inset-bottom, 0);
}

.settings-title {
  color: var(--primary-color);
  margin: 0;
  font-size: 1.3rem;
}

.settings-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-normal);
  box-sizing: border-box;
  flex-shrink: 0;
}

.settings-close:hover {
  color: var(--primary-color);
  background: rgba(76, 175, 80, 0.2);
  transform: rotate(90deg);
}

.settings-section {
  margin-bottom: var(--section-gap);
}

.settings-section h4 {
  color: var(--primary-color);
  margin-bottom: 10px;
  font-size: var(--heading-sm);
}

.settings-policy-box {
  margin-top: 1.25rem;
  padding: 1rem;
  background: rgba(233, 30, 99, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(233, 30, 99, 0.3);
}

.settings-policy-box h4 {
  color: #e91e63;
  margin: 0 0 0.5rem 0;
  font-size: var(--text-sm);
}

.settings-policy-box p {
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.85);
  margin: 0;
  line-height: 1.6;
}

.settings-hint {
  font-size: var(--text-sm);
  color: rgba(224, 242, 241, 0.8);
  margin: 0;
  line-height: 1.5;
  width: 100%;
  text-align: right;
}

.settings-option-with-hint {
  margin-top: -0.5rem;
  padding-top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.settings-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 0;
}

.settings-option label {
  color: var(--text-light);
  font-size: 0.9rem;
  margin: 0;
}

/* Full-width install row: button above hint (avoids side-by-side squeeze on narrow mobile) */
.settings-option--stacked {
  flex-direction: column;
  align-items: stretch;
  align-content: flex-start;
  gap: 8px;
}
.settings-option--stacked .settings-data-btn {
  flex: none;
  width: 100%;
  box-sizing: border-box;
}
.settings-option--stacked .settings-install-hint {
  width: 100%;
  text-align: left;
  margin: 0 0 10px 0;
}

.settings-option-llm-model {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}
.settings-option-llm-model label {
  flex: 1 1 100%;
}
.settings-select {
  min-width: 220px;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.settings-select:focus {
  outline: none;
  border-color: rgba(76, 175, 80, 0.6);
}
body.light-mode .settings-select {
  color: var(--text-dark);
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--border-light);
}

.toggle-switch {
  position: relative;
  width: 56px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active {
  background: var(--primary-gradient);
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-normal);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  pointer-events: none; /* so clicks go to the toggle, not the knob */
}

.toggle-switch.active::after {
  transform: translateX(28px);
}

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

/* Global mobile-first styles */
* {
  box-sizing: border-box;
}

label {
  font-size: 1.1rem;
  margin-bottom: 12px;
  display: block;
  font-weight: 600;
  color: var(--text-light);
  transition: all var(--transition-fast);
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  letter-spacing: 0.3px;
}

label:hover {
  color: var(--primary-color);
  transform: translateX(4px);
}

textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 40px;
  color: var(--text-light) !important;
}

/* Style select dropdown options */
select option {
  background: rgba(30, 30, 30, 0.95) !important;
  color: var(--text-light) !important;
  padding: 12px;
  border: none;
}

/* Style for item-select class (used in add-item sections) */
.item-select {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-light) !important;
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.95rem;
  width: 100%;
  margin: 0;
  min-height: auto;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e0f2f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 40px;
}

.item-select option {
  background: rgba(30, 30, 30, 0.98) !important;
  color: var(--text-light) !important;
  padding: 10px 12px;
}

.item-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  background: rgba(255, 255, 255, 0.08) !important;
}

.item-select:hover {
  border-color: rgba(76, 175, 80, 0.5);
  background: rgba(255, 255, 255, 0.07) !important;
}

/* Filter Section Styling */
.filter-section {
  margin-bottom: 20px;
}

.compact-filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 2;
  min-width: 250px;
}

.date-range input[type="date"] {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #2c2c2c;
  color: var(--text-light);
  font-size: 14px;
  margin: 0;
  min-height: auto;
}

body.light-mode .date-range input[type="date"] {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-dark);
  border-color: var(--border-light);
}

.date-separator {
  color: var(--text-light);
  font-weight: bold;
  font-size: 14px;
  white-space: nowrap;
}

body.light-mode .date-separator {
  color: var(--text-dark);
}

.filter-btn,
.sort-btn {
  flex: 1;
  min-width: 100px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  min-height: auto;
  position: relative;
  overflow: hidden;
}

.filter-btn:focus-visible,
.sort-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.filter-btn::before,
.sort-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.filter-btn:hover::before,
.sort-btn:hover::before {
  width: 300px;
  height: 300px;
}

.filter-btn {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-sm), 0 4px 15px rgba(76, 175, 80, 0.3);
}

.filter-btn:hover {
  background: linear-gradient(135deg, #388e3c 0%, #4caf50 50%, #66bb6a 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.sort-btn {
  background: linear-gradient(135deg, #607d8b, #546e7a);
  color: white;
  box-shadow: 0 4px 15px rgba(96, 125, 139, 0.3);
}

.sort-btn:hover {
  background: linear-gradient(135deg, #546e7a, #455a64);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(96, 125, 139, 0.4);
}

.filter-btn:active,
.sort-btn:active {
  transform: translateY(0);
}

.sort-buttons-group {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.sort-buttons-group .sort-btn-option {
  flex: 1;
  min-width: 70px;
}

.sort-buttons-group .sort-btn-option.active {
  background: linear-gradient(135deg, #607d8b, #546e7a);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px rgba(96, 125, 139, 0.3);
}

.sort-buttons-group .sort-btn-option.active:hover {
  background: linear-gradient(135deg, #546e7a, #455a64);
}

.sort-buttons-group .sort-btn-option:not(.active):hover {
  background: linear-gradient(135deg, #546e7a, #455a64);
}

/* View Logs: Oldest/Newest on separate rows on smaller screens and mobile */
@media (max-width: 768px) {
  .sort-buttons-group {
    flex-direction: column;
    width: 100%;
    flex: 1 1 100%;
  }
  .sort-buttons-group .sort-btn-option {
    width: 100%;
    min-width: 0;
  }
}

/* Settings Data Management */
.data-management-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.settings-data-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  min-height: 44px;
  margin: 0;
  width: auto;
}

.export-btn {
  background: #2196f3;
  color: white;
}

.export-btn:hover {
  background: #1976d2;
}

.import-btn {
  background: #4caf50;
  color: white;
}

.import-btn:hover {
  background: #388e3c;
}

.install-app-btn {
  background: #9c27b0;
  color: white;
  width: 100%;
  margin-bottom: 10px;
}

.install-app-btn:hover {
  background: #7b1fa2;
}

.install-android-btn {
  background: #4caf50;
  color: white;
  width: 100%;
}

.install-android-btn:hover {
  background: #388e3c;
}

.install-android-btn--disabled,
.install-android-btn--disabled:hover {
  background: #555;
  cursor: not-allowed;
  opacity: 0.7;
  pointer-events: none;
}

.install-ios-btn {
  background: #555;
  color: white;
  width: 100%;
  margin-top: 8px;
}

.install-ios-btn:hover {
  background: #424242;
}

.install-ios-device-btn {
  background: #007aff;
  color: white;
  width: 100%;
  margin-bottom: 4px;
}

.install-ios-device-btn:hover {
  background: #0056b3;
}

.settings-install-hint {
  font-size: 0.85rem;
  color: var(--text-secondary, #666);
  margin: 0 0 10px 0;
  line-height: 1.35;
}

.settings-install-icon {
  margin-right: 8px;
  opacity: 0.95;
}

.settings-install-icon i {
  font-size: 1.1em;
}

.launch-app-btn {
  background: #ff9800;
  color: white;
  width: 100%;
}

.launch-app-btn:hover {
  background: #f57c00;
}

.danger-zone {
  border-top: 1px solid #444;
  padding-top: 15px;
  margin-top: 15px;
}

.danger-btn {
  background: #f44336;
  color: white;
  width: 100%;
}

.danger-btn:hover {
  background: #d32f2f;
}

/* Enhanced mobile optimizations */
@media (max-width: 768px) {
  html {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
  }

  body {
    box-sizing: border-box;
    max-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    /* Top: clear notch/status; do not pad bottom — .app-bottom-nav already uses env(safe-area-inset-bottom) */
    padding: calc(5px + env(safe-area-inset-top, 0px)) max(5px, env(safe-area-inset-left, 0px)) 0 max(5px, env(safe-area-inset-right, 0px));
    font-size: 16px; /* Prevents zoom on iOS */
  }

  body::before {
    animation: none; /* Disable background animation on mobile for performance */
  }

  .ai-modal-overlay {
    padding: 0;
    align-items: center;
    justify-content: center;
  }

  .ai-modal-content {
    padding: 0;
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 16px;
    position: relative;
    margin: auto;
  }
  
  .ai-modal-body {
    padding: 20px;
  }
  
  .ai-modal-header {
    padding: 20px 20px 15px 20px;
  }

  .ai-modal-title {
    font-size: 1.2rem;
  }

  .ai-modal-close {
    font-size: 1.5rem;
    padding: 5px;
  }

  .ai-generate-btn {
    padding: 14px 24px;
    font-size: 1rem;
  }

  .ai-results-textbox {
    min-height: 300px;
    font-size: 0.9rem;
    padding: 15px;
  }

  .container {
    padding: 18px 18px 10px 18px;
    padding-bottom: 10px;
    margin: 0 0 0 0;
    margin-bottom: 0;
    border-radius: 20px;
  }
  
  .tab-content {
    padding-bottom: 10px;
    margin-bottom: 0;
  }
  
  .entry {
    margin-bottom: 0;
  }
  
  .chart-container {
    margin-bottom: 0;
  }
  
  .form-section:last-child {
    margin-bottom: 0;
  }
  
  .container:hover {
    transform: none; /* Disable hover transform on mobile */
  }
  
  .tab-navigation {
    gap: 4px;
    padding: 6px;
    margin: 1.5rem 0;
  }
  
  .tab-btn {
    min-width: 80px;
    padding: 12px 8px;
    font-size: 0.85rem;
  }
  
  .tab-icon {
    font-size: 1.3rem;
  }
  
  .tab-text {
    font-size: 0.75rem;
  }
  
  .tab-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .tab-header h2 {
    font-size: 1.5rem;
  }
  
  .tab-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .action-btn {
    flex: 1;
    justify-content: center;
  }
  
  .chart-view-toggle {
    width: 100%;
    justify-content: space-between;
  }
  
  .view-toggle-btn {
    flex: 1;
    justify-content: center;
  }
  
  /* Mobile: Show labels above button rows in charts tab */
  .chart-date-range-filter .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .chart-date-range-filter .filter-label {
    display: none; /* Hide regular label on mobile */
  }
  
  .chart-date-range-filter .filter-label-mobile {
    display: block; /* Show mobile label */
    font-size: 0.85rem;
    color: rgba(224, 242, 241, 0.8);
    font-weight: 600;
    margin-bottom: 4px;
  }
  
  .summary-card {
    padding: 1.5rem;
  }
  
  .summary-icon {
    font-size: 3rem;
  }
  
  .section-header {
    padding: 14px 16px;
    font-size: 1rem;
  }
  
  .section-content.open {
    padding: var(--card-content-padding-x);
  }

  h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  h2 {
    font-size: 1.4rem;
    margin: 1.5rem 0 1rem 0;
  }

  input, textarea, select, button {
    padding: 18px;
    margin: 12px 0;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 50px;
    border-radius: 12px;
  }

  .slider-container {
    margin: 25px 0;
  }

  input[type="range"] {
    height: 44px;
    border-radius: 22px;
  }

  .slider-label {
    font-size: 15px;
    left: 18px;
  }

  input[type="range"]::-webkit-slider-thumb {
    height: 44px;
    width: 12px;
  }

  input[type="range"]::-moz-range-thumb {
    height: 44px;
    width: 12px;
  }

  button {
    min-height: 56px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 12px;
    margin: 15px 0;
  }

  .toggle-button, .clear-button, .export-button {
    padding: 18px;
    min-height: 56px;
    font-size: 1.2rem;
    margin: 8px 0;
    border-radius: 12px;
  }

  .button-container {
    gap: 12px;
    margin-top: 25px;
  }

  textarea {
    min-height: 120px;
  }

  /* Goals + Settings: in-flow row above title (fixed overlay clashed with wrapped MOTD title) */
  .header-buttons-wrap {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    width: 100%;
    justify-content: flex-end;
    margin-bottom: 10px;
    box-sizing: border-box;
  }

  .title-container {
    padding-right: 0;
  }

  .settings-button-top,
  .targets-button-top {
    width: 40px;
    height: 40px;
  }

  .settings-cog,
  .targets-face-icon {
    width: 22px;
    height: 22px;
  }
  

  .ai-modal {
    width: 95%;
    max-height: 85vh;
    margin: 10px;
  }

  .settings-overlay {
    padding: 10px;
    align-items: center;
    justify-content: center;
  }

  .settings-menu {
    width: 95%;
    max-height: 85vh;
    margin: auto;
    align-self: center;
  }

  .entry {
    padding: 18px;
    margin-top: 12px;
    border-radius: 16px;
    font-size: 1rem;
    line-height: 1.6;
  }
  
  .entry:hover {
    transform: none; /* Disable hover transform on mobile */
  }
  
  .log-entry-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-right: 80px; /* Make room for delete and edit buttons on mobile */
  }
  
  .log-date {
    font-size: 1.1rem;
  }
  
  .header-badges {
    gap: 6px;
    flex-wrap: nowrap;
  }
  
  .header-icon-btn {
    padding: 0;
    font-size: 0.85rem;
    min-width: 26px;
    max-width: 26px;
    width: 26px;
    min-height: 26px;
    max-height: 26px;
    height: 26px;
    box-sizing: border-box;
  }
  
  .badge-count {
    font-size: 0.8rem;
    padding: 4px 7px;
    min-width: 22px;
    font-size: 0.55rem;
    padding: 1px 3px;
    min-width: 12px;
    top: -4px;
    right: -4px;
  }
  
  .log-metrics-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .metric-group {
    padding: 12px;
  }
  
  .metric-item {
    padding: 6px 0;
  }
  
  .metric-label {
    font-size: 0.9rem;
  }
  
  .metric-value {
    font-size: 0.95rem;
  }
  
  .log-notes {
    padding: 12px;
    font-size: 0.9rem;
  }

  /* Ensure actions are hidden when collapsed on mobile */
  .log-entry-actions {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
  
  .entry.expanded .log-entry-actions {
    display: flex !important;
    gap: 6px;
    padding: 8px 15px !important;
    margin: -18px -18px 8px -18px !important;
    min-height: 48px !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .delete-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
  
  .edit-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .log-actions {
    flex-direction: column;
  }
  
  .action-button {
    width: 100%;
  }
  
  .modal-content {
    max-width: 95%;
    max-height: 90vh;
    width: 95%;
  }
  
  .settings-menu {
    width: 95%;
    max-height: calc(90vh - env(safe-area-inset-bottom, 0px));
  }
  
  .settings-content {
    padding-top: 0;
    padding-bottom: max(100px, calc(100px + env(safe-area-inset-bottom, 0px)));
  }
  
  .ai-modal-content {
    width: 95vw;
    max-height: 90vh;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .add-item-section {
    flex-direction: column;
  }
  
  .add-item-btn {
    width: 100%;
  }
  
  /* Condition input container - stack input above button on mobile */
  #conditionInputContainer {
    flex-direction: column;
  }
  
  #conditionInputContainer .add-item-btn {
    width: 100%;
    margin-top: 8px;
  }

  .ai-modal-title {
    font-size: 1.1rem;
  }

  .ai-modal-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
  }

  .ai-modal-body {
    gap: 1rem;
  }

  .ai-modal-description {
    padding: 1rem;
    font-size: 0.9rem;
  }

  .ai-generate-btn {
    padding: 12px 20px;
    font-size: 0.95rem;
    width: 100%;
  }

  .ai-results-textbox {
    min-height: 250px;
    font-size: 0.85rem;
    padding: 12px;
  }

  canvas {
    margin: 20px 0;
    border-radius: 8px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .container {
    padding: 8px;
  }

  .ai-modal-overlay {
    padding: 0;
    align-items: center;
    justify-content: center;
  }

  .ai-modal-content {
    padding: 0;
    width: 98vw;
    height: 98vh;
    max-width: 98vw;
    max-height: 98vh;
    border-radius: 12px;
    position: relative;
    margin: auto;
  }

  .ai-modal-title {
    font-size: 1.1rem;
  }

  .ai-modal-header {
    margin-bottom: 15px;
    padding: 15px 15px 10px 15px;
  }

  .ai-modal-body {
    gap: 1rem;
    padding: 15px;
  }

  .ai-modal-description {
    padding: 1rem;
    font-size: 0.9rem;
  }

  .ai-generate-btn {
    padding: 12px 20px;
    font-size: 0.95rem;
    width: 100%;
  }

  .ai-results-textbox {
    min-height: 250px;
    font-size: 0.85rem;
    padding: 12px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .settings-button-top,
  .targets-button-top {
    width: 36px;
    height: 36px;
  }

  .settings-cog,
  .targets-face-icon {
    width: 20px;
    height: 20px;
  }
}

/* Offline Indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ff9800;
  color: white;
  text-align: center;
  padding: 8px;
  font-weight: bold;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-indicator.show {
  transform: translateY(0);
}

.online-indicator {
  background: #4caf50;
}

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

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

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

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

.success-notification {
  animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes validPulse {
  0% { 
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
  }
  50% { 
    box-shadow: 0 0 0 8px rgba(76, 175, 80, 0.4);
  }
  100% { 
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
  }
}

/* Add stagger animation delays for form elements */
#logForm > * {
  animation: slideInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

#logForm > *:nth-child(1) { animation-delay: 0.05s; }
#logForm > *:nth-child(2) { animation-delay: 0.1s; }
#logForm > *:nth-child(3) { animation-delay: 0.15s; }
#logForm > *:nth-child(4) { animation-delay: 0.2s; }
#logForm > *:nth-child(5) { animation-delay: 0.25s; }
#logForm > *:nth-child(6) { animation-delay: 0.3s; }
#logForm > *:nth-child(7) { animation-delay: 0.35s; }
#logForm > *:nth-child(8) { animation-delay: 0.4s; }
#logForm > *:nth-child(9) { animation-delay: 0.45s; }
#logForm > *:nth-child(10) { animation-delay: 0.5s; }
#logForm > *:nth-child(11) { animation-delay: 0.55s; }
#logForm > *:nth-child(12) { animation-delay: 0.6s; }
#logForm > *:nth-child(13) { animation-delay: 0.65s; }
#logForm > *:nth-child(14) { animation-delay: 0.7s; }
#logForm > *:nth-child(15) { animation-delay: 0.75s; }
#logForm > *:nth-child(16) { animation-delay: 0.8s; }
#logForm > *:nth-child(17) { animation-delay: 0.85s; }
#logForm > *:nth-child(18) { animation-delay: 0.9s; }
#logForm > *:nth-child(19) { animation-delay: 0.95s; }
#logForm > *:nth-child(20) { animation-delay: 1s; }

/* ============================================
   CLOUD SYNC STYLES
   ============================================ */

.cloud-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 8px;
  margin-bottom: 16px;
}

.cloud-status-text {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 500;
}

.cloud-status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.cloud-status-indicator.status-success {
  background: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
  animation: pulse 2s ease-in-out infinite;
}

.cloud-status-indicator.status-error {
  background: #f44336;
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
}

.cloud-status-indicator.status-syncing {
  background: #ff9800;
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.6);
  animation: pulse 1s ease-in-out infinite;
}

.cloud-auth-section {
  margin-top: 16px;
}

.cloud-auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-strength-indicator {
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  font-size: 0.85rem;
}

.password-strength-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.password-strength-fill {
  height: 100%;
  width: 0%;
  background-color: #f44336;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: 2px;
}

.password-strength-text {
  font-size: 0.8rem;
  color: rgba(224, 242, 241, 0.8);
  margin-bottom: 4px;
}

.password-requirements {
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
  font-size: 0.75rem;
}

.password-requirements li {
  margin: 2px 0;
  padding-left: 16px;
  position: relative;
}

.password-requirements li::before {
  content: '○';
  position: absolute;
  left: 0;
  color: rgba(224, 242, 241, 0.5);
}

.cloud-input {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 8px;
  color: var(--text-light);
  font-size: 0.95rem;
  transition: all 0.3s ease;
  flex: 1; /* Take up remaining space */
}

.password-input-wrapper .cloud-input {
  padding-right: 16px; /* Normal padding when in wrapper */
}

.cloud-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.cloud-input::placeholder {
  color: rgba(224, 242, 241, 0.5);
}

.password-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(76, 175, 80, 0.3);
  cursor: pointer;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  color: rgba(224, 242, 241, 0.6);
  flex-shrink: 0;
  min-width: 36px;
  width: 36px;
  height: 36px; /* Smaller than input field */
}

.password-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(76, 175, 80, 0.5);
  color: var(--text-light);
}

.password-toggle-btn:active {
  transform: scale(0.95);
}

.password-toggle-icon {
  font-size: 0.9rem;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.cloud-auth-buttons {
  display: flex;
  gap: 8px;
}

.cloud-sync-section {
  margin-top: 16px;
}

.cloud-user-info {
  padding: 12px 16px;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 500;
}

.cloud-sync-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.cloud-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.4);
  color: var(--text-light);
}

.cloud-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.cloud-btn:hover {
  background: rgba(76, 175, 80, 0.3);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  transform: translateY(-2px);
}

.cloud-btn:active {
  transform: translateY(0);
}

.cloud-btn.signup-btn {
  background: rgba(33, 150, 243, 0.2);
  border-color: rgba(33, 150, 243, 0.4);
}

.cloud-btn.signup-btn:hover {
  background: rgba(33, 150, 243, 0.3);
  border-color: #2196f3;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.cloud-btn.login-btn {
  background: rgba(76, 175, 80, 0.2);
  border-color: rgba(76, 175, 80, 0.4);
}

.cloud-btn.sync-btn {
  background: rgba(255, 152, 0, 0.2);
  border-color: rgba(255, 152, 0, 0.4);
}

.cloud-btn.sync-btn:hover {
  background: rgba(255, 152, 0, 0.3);
  border-color: #ff9800;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.cloud-btn.logout-btn {
  background: rgba(244, 67, 54, 0.2);
  border-color: rgba(244, 67, 54, 0.4);
}

.cloud-btn.logout-btn:hover {
  background: rgba(244, 67, 54, 0.3);
  border-color: #f44336;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.cloud-sync-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.cloud-sync-info small {
  color: rgba(224, 242, 241, 0.7);
  font-size: 0.85rem;
}

.cloud-auto-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.9rem;
  user-select: none;
  -webkit-user-select: none;
}

.cloud-auto-sync:hover {
  opacity: 0.9;
}

.cloud-auto-sync input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
  pointer-events: auto;
  z-index: 10;
  position: relative;
}

.cloud-setup-info {
  margin-top: 16px;
  padding: 12px;
  background: rgba(76, 175, 80, 0.05);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 8px;
}

.cloud-setup-info small {
  color: rgba(224, 242, 241, 0.8);
  font-size: 0.85rem;
  line-height: 1.5;
}

.cloud-setup-info strong {
  color: var(--primary-color);
}

/* Light mode adjustments */
body.light-mode .cloud-status {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
}

body.light-mode .cloud-status-text {
  color: var(--text-dark);
}

body.light-mode .cloud-input {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(76, 175, 80, 0.3);
  color: var(--text-dark);
}

body.light-mode .cloud-input:focus {
  background: rgba(0, 0, 0, 0.08);
}

body.light-mode .cloud-user-info {
  background: rgba(76, 175, 80, 0.1);
  color: var(--text-dark);
}

/* Export/Import Modal Styles */
.export-format-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.export-format-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(76, 175, 80, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.export-format-btn:hover {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.export-format-btn .format-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.export-format-btn .format-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.export-format-btn .format-desc {
  font-size: 0.75rem;
  color: rgba(224, 242, 241, 0.6);
}

.import-format-selection,
.import-merge-options {
  margin-bottom: 1.5rem;
}

/* Import Option Cards */
.import-option-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.import-option-card {
  display: flex;
  align-items: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(76, 175, 80, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  gap: 1rem;
}

.import-option-card:hover {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
}

.import-option-card.selected,
.import-option-card:has(input[type="radio"]:checked) {
  background: rgba(76, 175, 80, 0.15);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.import-option-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.import-option-card.selected .import-option-icon,
.import-option-card:has(input[type="radio"]:checked) .import-option-icon {
  background: rgba(76, 175, 80, 0.3);
  transform: scale(1.1);
}

.import-option-content {
  flex: 1;
}

.import-option-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.import-option-desc {
  font-size: 0.8rem;
  color: rgba(224, 242, 241, 0.7);
  line-height: 1.4;
}

/* Import File Section */
.import-file-section {
  margin-bottom: 1rem;
}

.import-file-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.import-file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 14px 24px;
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

.import-file-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.import-file-icon {
  font-size: 1.25rem;
}

.import-file-name {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  color: rgba(224, 242, 241, 0.9);
  font-size: 0.9rem;
  min-height: 20px;
  display: flex;
  align-items: center;
}

.import-file-name:empty {
  display: none;
}

#importPreview {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(76, 175, 80, 0.2);
}

#importPreviewContent table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}

#importPreviewContent th,
#importPreviewContent td {
  padding: 6px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#importPreviewContent th {
  background: rgba(76, 175, 80, 0.2);
  font-weight: 600;
}

/* Time input styling */
.time-input {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.9rem;
  color: var(--text-light);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
}

.time-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.time-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

body.light-mode .time-input {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-dark);
  border-color: rgba(76, 175, 80, 0.3);
}

body.light-mode .time-input:focus {
  background: rgba(0, 0, 0, 0.08);
}

body.light-mode .cloud-btn {
  color: var(--text-dark);
}

body.light-mode .cloud-sync-info small {
  color: rgba(0, 0, 0, 0.7);
}

body.light-mode .cloud-auto-sync {
  color: var(--text-dark);
}

body.light-mode .cloud-setup-info {
  background: rgba(76, 175, 80, 0.05);
}

body.light-mode .cloud-setup-info small {
  color: rgba(0, 0, 0, 0.8);
}

/* ============================================
   AI LLM SYNOPSIS STYLES
   ============================================ */

.ai-llm-synopsis {
  background: rgba(233, 30, 99, 0.08);
  border: 1px solid rgba(233, 30, 99, 0.25);
  border-radius: 12px;
  padding: 1.75rem;
  margin-top: 1rem;
  line-height: 1.9;
  box-shadow: 0 2px 8px rgba(233, 30, 99, 0.1);
}

.ai-llm-synopsis p {
  margin: 0.75rem 0;
  color: rgba(224, 242, 241, 0.95);
  font-size: 1rem;
}

.ai-llm-synopsis p:first-child {
  margin-top: 0;
}

.ai-llm-synopsis p:last-child {
  margin-bottom: 0;
}

.ai-llm-synopsis strong {
  color: #f06292;
  font-weight: 600;
  font-size: 1.05rem;
}

.ai-llm-synopsis .ai-brackets-highlight {
  color: #e91e63;
  font-weight: 600;
  background: rgba(233, 30, 99, 0.15);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.ai-bullet-point {
  margin-left: 1rem !important;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(233, 30, 99, 0.4);
  color: rgba(224, 242, 241, 0.95);
}

.ai-subsection-title {
  color: #e91e63;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(233, 30, 99, 0.25);
}

.ai-subsection-title:first-child {
  margin-top: 0;
}

.ai-llm-synopsis a {
  color: var(--primary-color);
  text-decoration: underline;
  transition: opacity 0.3s ease;
}

.ai-llm-synopsis a:hover {
  opacity: 0.8;
}

body.light-mode .ai-llm-synopsis {
  background: rgba(233, 30, 99, 0.05);
  border-color: rgba(233, 30, 99, 0.2);
}

body.light-mode .ai-llm-synopsis p {
  color: var(--text-dark);
}

body.light-mode .ai-llm-synopsis a {
  color: #2e7d32;
}

body.light-mode .ai-llm-synopsis .ai-brackets-highlight {
  color: #2e7d32;
  background: rgba(76, 175, 80, 0.2);
}

/* Metric Selector for Combined Chart */
.metric-selector-container {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(30, 30, 30, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.metric-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-selector-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e0f2f1;
}

.metric-selector-actions {
  display: flex;
  gap: 4px;
}

.metric-select-btn {
  padding: 3px 8px;
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.5);
  border-radius: 4px;
  color: #e0f2f1;
  cursor: pointer;
  font-size: 0.68rem;
  transition: all 0.3s ease;
}

.metric-select-btn:hover {
  background: rgba(76, 175, 80, 0.4);
  border-color: rgba(76, 175, 80, 0.7);
  transform: translateY(-1px);
}

.metric-select-btn.metric-select-btn-deselect {
  background: rgba(244, 67, 54, 0.2);
  border-color: rgba(244, 67, 54, 0.6);
  color: #ff8a80;
}

.metric-select-btn.metric-select-btn-deselect:hover {
  background: rgba(244, 67, 54, 0.35);
  border-color: rgba(244, 67, 54, 0.8);
}

.metric-checkboxes-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-group {
  background: rgba(20, 20, 20, 0.4);
  border-radius: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(76, 175, 80, 0.15);
  transition: all 0.3s ease;
}

.metric-group:hover {
  background: rgba(25, 25, 25, 0.5);
  border-color: rgba(76, 175, 80, 0.3);
}

.metric-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(76, 175, 80, 0.2);
}

.metric-group-icon {
  font-size: 0.95rem;
  filter: drop-shadow(0 0 4px rgba(76, 175, 80, 0.5));
}

.metric-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.metric-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 2px 4px;
}

.metric-checkbox-item {
  display: flex;
  align-items: center;
}

.metric-checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 1px 2px;
  border-radius: 2px;
  transition: background 0.2s ease;
}

.metric-checkbox-label:hover {
  background: rgba(76, 175, 80, 0.1);
}

.metric-checkbox-label.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.metric-checkbox-label.disabled .metric-checkbox {
  cursor: not-allowed;
  opacity: 0.7;
}

.metric-checkbox-label.disabled:hover {
  background: transparent;
}

.metric-checkbox {
  margin-right: 3px;
  width: 12px;
  height: 12px;
  cursor: pointer;
  accent-color: #4caf50;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 2px solid rgba(76, 175, 80, 0.5);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.metric-checkbox:hover {
  border-color: rgba(76, 175, 80, 0.8);
  background: rgba(76, 175, 80, 0.1);
}

.metric-checkbox:checked {
  background: #4caf50;
  border-color: #4caf50;
}

.metric-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 8px;
  font-weight: bold;
  line-height: 1;
}

.metric-checkbox-text {
  display: flex;
  align-items: center;
  gap: 3px;
  color: #e0f2f1;
  font-size: 0.68rem;
  white-space: nowrap;
}

.metric-color-indicator {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

/* Combined + balance chart metric pickers — denser layout on small screens */
@media (max-width: 768px) {
  .metric-selector-container {
    margin-top: 6px;
    padding: 6px 8px;
  }

  .metric-selector-header {
    margin-bottom: 4px;
    gap: 4px;
  }

  .metric-selector-title {
    font-size: 0.72rem;
  }

  .metric-select-btn {
    padding: 3px 6px;
    font-size: 0.64rem;
    min-height: 0;
  }

  .metric-checkboxes-grid {
    gap: 6px;
    max-height: none;
    overflow: visible;
  }

  .metric-group {
    padding: 5px 6px;
    border-radius: 5px;
  }

  .metric-group-header {
    gap: 4px;
    margin-bottom: 4px;
    padding-bottom: 3px;
  }

  .metric-group-icon {
    font-size: 0.85rem;
  }

  .metric-group-title {
    font-size: 0.68rem;
    letter-spacing: 0.2px;
  }

  .metric-group-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 4px;
  }

  .metric-checkbox-item {
    min-width: 0;
  }

  .metric-checkbox-label {
    padding: 3px 2px;
    min-height: 32px;
    align-items: center;
  }

  .metric-checkbox {
    width: 13px;
    height: 13px;
    margin-right: 4px;
  }

  .metric-checkbox:checked::after {
    font-size: 9px;
  }

  .metric-checkbox-text {
    font-size: 0.64rem;
    white-space: normal;
    line-height: 1.2;
    align-items: flex-start;
  }

  .metric-checkbox-text .metric-color-indicator {
    margin-top: 2px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .cloud-auth-buttons,
  .cloud-sync-buttons {
    flex-direction: column;
  }
  
  .cloud-btn {
    width: 100%;
  }
}

/* Mobile-centric tile pickers: horizontal chip strips, denser tiles, softer open shadows (meal/exercise cards only) */
@media (max-width: 768px) {
  .food-meal-collapsible.food-category-block:has(.tile-picker-trigger[aria-expanded="true"]),
  .exercise-meal-collapsible.exercise-category-block:has(.tile-picker-trigger[aria-expanded="true"]) {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  }

  .food-chips,
  .stressor-chips,
  .symptom-chips,
  .exercise-chips,
  .energy-clarity-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 4px;
    padding-bottom: 6px;
    margin-top: 6px;
    margin-left: -2px;
    margin-right: -2px;
    padding-left: 2px;
    padding-right: 2px;
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  }

  .food-chip,
  .stressor-chip,
  .symptom-chip,
  .exercise-chip,
  .energy-clarity-chip {
    flex: 0 0 auto;
    width: 76px;
    min-width: 76px;
    max-width: 76px;
    min-height: 76px;
    aspect-ratio: 1;
    scroll-snap-align: start;
  }

  .food-chip .food-chip-name,
  .stressor-chip .stressor-chip-name,
  .symptom-chip .symptom-chip-name,
  .energy-clarity-chip .energy-clarity-chip-name {
    font-size: 0.65rem;
    min-height: 2em;
    -webkit-line-clamp: 2;
  }

  .food-chip .food-chip-nutrition,
  .exercise-chip .exercise-chip-duration {
    font-size: 0.6rem;
  }

  .food-chip .food-chip-icon,
  .stressor-chip .stressor-chip-icon,
  .symptom-chip .symptom-chip-icon,
  .exercise-chip .exercise-chip-icon,
  .energy-clarity-chip .energy-clarity-chip-icon {
    font-size: 1.1rem;
    min-height: 20px;
  }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .food-chips,
  .stressor-chips,
  .symptom-chips,
  .exercise-chips,
  .energy-clarity-chips {
    scroll-snap-type: none;
  }
}

/* Filter search row above tile grids */
.tile-picker-search-wrap {
  margin-bottom: 10px;
}

.tile-picker-search {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(76, 175, 80, 0.35);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-light);
}

.tile-picker-search::placeholder {
  color: rgba(224, 242, 241, 0.45);
}

.tile-picker-search:focus {
  outline: none;
  border-color: rgba(76, 175, 80, 0.65);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

body.light-mode .tile-picker-search {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-dark);
  border-color: rgba(76, 175, 80, 0.4);
}

body.light-mode .tile-picker-search::placeholder {
  color: rgba(55, 71, 79, 0.5);
}

/* Demo Mode Toggle - Show only on mobile */
.demo-mode-mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .demo-mode-mobile-only {
    display: flex;
  }
}
