/* =========================================================
   MOBILE-FIRST HEALTHAPP STYLESHEET
   Optimized for smartphone screens, verticality, & thumb reach
   ========================================================= */

:root {
  --bg-primary: #0b1120;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --bg-input: #0f172a;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #10b981;    /* Emerald green */
  --accent-primary-hover: #059669;
  --accent-secondary: #38bdf8;  /* Sky blue */
  --accent-warning: #f59e0b;    /* Amber */
  --accent-danger: #ef4444;     /* Rose red */
  --accent-purple: #a855f7;
  
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
  
  --touch-target: 48px;
  --bottom-nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 600px; /* Optimal reading/touch width */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px calc(var(--bottom-nav-height) + var(--safe-bottom) + 20px) 14px;
  gap: 16px;
}

/* --- Mobile Header --- */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 4px 6px 4px;
}

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

.brand-icon {
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  line-height: 1;
}

.brand-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.brand-accent {
  color: var(--accent-primary);
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.live-header-text {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-danger);
  letter-spacing: 0.5px;
}

.live-pulse {
  width: 8px;
  height: 8px;
  background-color: var(--accent-danger);
  border-radius: var(--radius-full);
  animation: pulse 1.2s infinite;
}

/* --- Mobile Bottom Navigation --- */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 500;
  max-width: 600px;
  margin: 0 auto;
}

.nav-tab {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  user-select: none;
}

.nav-tab-icon {
  font-size: 20px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.nav-tab-label {
  font-size: 11px;
  font-weight: 700;
}

.nav-tab.active {
  color: var(--accent-primary);
}

.nav-tab.active .nav-tab-icon {
  transform: translateY(-2px) scale(1.1);
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: calc(50% - 14px);
  width: 8px;
  height: 8px;
  background-color: var(--accent-danger);
  border-radius: var(--radius-full);
  box-shadow: 0 0 6px var(--accent-danger);
  animation: pulse 1.5s infinite;
}

/* --- Cards & Layout --- */
.card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

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

.card-header h3, .card-header h2 {
  font-size: 17px;
  font-weight: 800;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease-out;
}

.tab-pane.active {
  display: flex;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-left { text-align: left; }
.text-center { text-align: center; }

/* --- Mobile Buttons & Inputs (Touch Targets >= 48px) --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-target);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.2s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #0b1120;
}
.btn-primary:active {
  background-color: var(--accent-primary-hover);
}

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

.btn-success {
  background-color: var(--accent-primary);
  color: #0b1120;
}

.btn-danger-subtle {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-subtle:active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-full);
}

.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.badge {
  background-color: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Mobile Inputs (16px font prevents iOS zoom) */
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  min-height: var(--touch-target);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  outline: none;
  width: 100%;
  -webkit-appearance: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Forms: Clean Vertical Stacking */
.vertical-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.macro-details {
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.macro-summary-toggle {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-secondary);
  cursor: pointer;
  outline: none;
}

/* =========================================================
   1. CALORIE TRACKER (Vertical Smartphone Layout)
   ========================================================= */

.date-navigator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}

.current-date-wrap {
  position: relative;
  text-align: center;
  flex: 1;
}

.date-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}

.date-picker-input {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Calorie Hero Card (Vertical Stack) */
.calorie-hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px 16px;
  background: linear-gradient(180deg, #1e293b 0%, #131b2e 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.ring-container {
  position: relative;
  width: 175px;
  height: 175px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 14;
}

.ring-fg {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 515.2; /* 2 * pi * 82 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
}

.ring-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ring-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ring-value {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--text-primary);
}

.ring-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* KPI Stack (Budget & Consumed) */
.calorie-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.kpi-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.kpi-card:active {
  transform: scale(0.98);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.kpi-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
}

.kpi-value.highlight {
  color: var(--accent-secondary);
}

.kpi-unit {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Weekly Calorie Progress Card (Food Mode) */
.weekly-calorie-card {
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-sizing: border-box;
}

.weekly-calorie-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.weekly-calorie-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.weekly-calorie-stats {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.weekly-calorie-stats strong {
  color: var(--text-primary);
  font-weight: 800;
}

.weekly-progress-track {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.weekly-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8 0%, #3b82f6 50%, #6366f1 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s ease, background 0.3s ease;
}

.weekly-progress-fill.over-budget {
  background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%);
}

.weekly-calorie-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  gap: 8px;
}

.weekly-remaining-text {
  font-weight: 600;
  color: var(--text-muted);
}

.weekly-remaining-text.over-budget {
  color: var(--accent-danger);
}

.weekly-dates-label {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.85;
  white-space: nowrap;
}

/* Macronutrient Card (Collapsible, hidden/collapsed by default) */
.macros-card {
  width: 100%;
  background-color: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.macros-heading-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
  user-select: none;
  list-style: none;
}
.macros-heading-toggle::-webkit-details-marker {
  display: none;
}

.macros-toggle-icon {
  font-size: 10px;
  transition: transform 0.2s ease;
}

details[open] .macros-toggle-icon {
  transform: rotate(180deg);
}

.macros-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.macros-heading {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.macro-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.macro-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}

.macro-bar {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.macro-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.macro-fill.protein { background-color: #f43f5e; width: 0%; }
.macro-fill.carbs   { background-color: #0ea5e9; width: 0%; }
.macro-fill.fat     { background-color: #eab308; width: 0%; }

/* Quick Presets (Toolbar, Search, Categories & Pagination) */
.preset-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.preset-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.preset-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

#presetSearchInput,
.preset-search-box input {
  width: 100%;
  padding: 10px 36px 10px 38px !important;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#presetSearchInput:focus {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.preset-clear-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.preset-category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.preset-category-tabs::-webkit-scrollbar {
  display: none;
}

.preset-cat-tab {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.preset-cat-tab:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.preset-cat-tab.active {
  background-color: var(--accent-secondary);
  color: #0b1120;
  border-color: var(--accent-secondary);
  font-weight: 800;
}

.cat-count-badge {
  font-size: 10px;
  background-color: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 800;
}

.preset-cat-tab.active .cat-count-badge {
  background-color: rgba(0, 0, 0, 0.2);
  color: #0b1120;
}

.preset-cat-tab[data-category="deleted"].has-deleted:not(.active) .cat-count-badge {
  background-color: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
}

.quick-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
}

.preset-chip {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  line-height: 1.35;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
  transition: all 0.15s ease;
}

.preset-chip:active {
  background-color: var(--accent-primary);
  color: #0b1120;
  transform: scale(0.96);
}

.preset-chip-deleted {
  opacity: 0.88;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  background-color: rgba(245, 158, 11, 0.08);
  color: var(--text-secondary);
}

.preset-chip-deleted:hover,
.preset-chip-deleted:active {
  border-color: var(--accent-primary);
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--text-primary);
}

.empty-state-presets {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 24px 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* Preset Search Sections (Presets vs History) */
.preset-search-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-search-section:not(:first-child) {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.preset-search-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 2px;
}

.preset-search-section-header .section-count {
  font-size: 11px;
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

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

.preset-chip-history {
  border-color: rgba(56, 189, 248, 0.25);
  background-color: rgba(15, 23, 42, 0.65);
}

.preset-chip-history:hover,
.preset-chip-history:active {
  border-color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.15);
}

/* Preset Pagination */
.preset-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  gap: 10px;
}

.btn-page {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 32px;
}

.btn-page:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-page:not(:disabled):active {
  background-color: var(--accent-secondary);
  color: #0b1120;
  transform: scale(0.96);
}

.preset-page-info {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
}

/* Portion / Fraction Pills (Add Food Form) */
.portion-calc-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-secondary);
  background-color: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.portion-quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.portion-pill {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.portion-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.portion-pill.active {
  background-color: var(--accent-primary);
  color: #0b1120;
  border-color: var(--accent-primary);
  font-weight: 800;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.custom-portion-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-portion-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Preset Portion Modal Grid */
.preset-portion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.preset-portion-btn {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-portion-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.preset-portion-btn.active {
  background-color: rgba(52, 211, 153, 0.15);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.25);
}

.portion-fraction {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

.preset-portion-btn.active .portion-fraction {
  color: var(--accent-primary);
}

.portion-kcal {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* AI Food Scanner Styles */
.ai-dropzone {
  border: 2px dashed rgba(56, 189, 248, 0.35);
  background-color: rgba(56, 189, 248, 0.04);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.ai-dropzone:hover, .ai-dropzone.dragover {
  border-color: var(--accent-secondary);
  background-color: rgba(56, 189, 248, 0.08);
  transform: translateY(-1px);
}

.ai-dropzone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ai-upload-icon {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 8px rgba(56, 189, 248, 0.3));
}

.ai-image-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: block;
}

.ai-remove-image-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(15, 23, 42, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.ai-remove-image-btn:hover {
  background-color: #ef4444;
  transform: scale(1.1);
}

.ai-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(56, 189, 248, 0.15);
  border-top-color: var(--accent-secondary);
  border-radius: 50%;
  margin: 0 auto;
  animation: ai-spin 0.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

.ai-analysis-banner {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(52, 211, 153, 0.12) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Food Log Items */
.food-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.food-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface-elevated);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.food-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
  text-align: left;
  cursor: pointer;
}

.food-item-info:hover .food-item-title {
  color: var(--accent-secondary);
}

.food-item-title {
  font-size: 15px;
  font-weight: 700;
  word-break: break-word;
  overflow-wrap: break-word;
  transition: color 0.15s ease;
}

.food-item-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.food-item-cals {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-tag {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-primary);
  white-space: nowrap;
}

.food-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-edit-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  min-width: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-edit-item:hover, .btn-edit-item:active {
  color: var(--accent-secondary);
  background-color: rgba(56, 189, 248, 0.12);
  transform: scale(1.1);
}

.btn-delete-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  min-width: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.btn-delete-item:hover, .btn-delete-item:active {
  color: var(--accent-danger);
  background-color: rgba(239, 68, 68, 0.12);
  transform: scale(1.1);
}

/* =========================================================
   2. WORKOUTS LIST (Vertical Routines Cards)
   ========================================================= */

.banner-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.banner-content h2 {
  font-size: 19px;
  font-weight: 800;
}

.banner-content p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.4;
}

.workout-vertical-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.routine-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border-color);
}

.routine-card-header h3 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}

.routine-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.routine-exercises-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 4px 0;
  padding: 10px 12px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.preview-ex-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-ex-sets {
  color: var(--accent-secondary);
  font-weight: 700;
  font-size: 12px;
}

.routine-card-footer {
  display: flex;
  gap: 10px;
}

/* =========================================================
   3. ACTIVE WORKOUT COMPANION (Mobile Set Logging & Rest)
   ========================================================= */

.empty-session-card {
  padding: 50px 20px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

.empty-icon {
  font-size: 44px;
}

.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.vertical-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Live Header Card */
.live-header-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(135deg, #1e293b 0%, #151d2e 100%);
  border: 1px solid var(--accent-primary);
  margin-bottom: 16px;
}

.live-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.live-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-title-wrap h2 {
  font-size: 18px;
  font-weight: 800;
}

.live-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.live-kpi-box {
  background-color: var(--bg-surface-elevated);
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.live-kpi-lbl {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-secondary);
}

.live-kpi-val {
  font-size: 15px;
  font-weight: 900;
  color: var(--accent-secondary);
  margin-top: 2px;
}

/* Rest Timer Banner (Sticky / Full Width) */
.rest-timer-banner {
  background: linear-gradient(90deg, #1e3a8a 0%, #0f172a 100%);
  border: 1px solid var(--accent-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 10px;
  z-index: 100;
  animation: slideDown 0.3s ease-out;
  margin-bottom: 16px;
}

.rest-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rest-info {
  display: flex;
  flex-direction: column;
}

.rest-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-secondary);
}

.rest-time-display {
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: #fff;
}

.rest-quick-controls {
  display: flex;
  gap: 6px;
}

.btn-rest-ctl {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-rest-ctl.primary {
  background-color: var(--accent-secondary);
  color: #0b1120;
  border: none;
}

.btn-rest-ctl.skip {
  background-color: var(--accent-primary);
  color: #0b1120;
  border: none;
}

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

.rest-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.rest-progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  transition: width 1s linear;
}

/* Active Exercise Cards (Clean Mobile Set Logging) */
.active-exercises-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exercise-active-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.exercise-active-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.exercise-active-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.flex-row-gap-8 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-accent {
  background-color: rgba(56, 189, 248, 0.12);
  color: var(--accent-secondary);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.badge-success {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Single Target Bar at top of Exercise Card */
.ex-target-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface-elevated);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ex-target-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.target-chip {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-secondary);
  letter-spacing: 0.2px;
}

/* Quick Target Edit Drawer */
.target-quick-edit-box {
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  animation: fadeIn 0.15s ease-out;
}

/* Modern Touch Set Checkbox Buttons */
.active-sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin: 4px 0;
}

.set-check-btn {
  min-height: 52px;
  padding: 10px 12px;
  background-color: var(--bg-surface-elevated);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

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

.set-check-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-secondary);
}

.set-check-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  background-color: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.15s ease;
}

.set-check-btn.completed {
  background-color: rgba(34, 197, 94, 0.12);
  border-color: #22c55e;
}

.set-check-btn.completed .set-check-name {
  color: #4ade80;
}

.set-check-btn.completed .set-check-icon {
  background-color: #22c55e;
  color: #0b1120;
  border-color: #22c55e;
}

/* Timed Exercise Set Buttons & Live Countdown */
.set-check-btn.timed-btn {
  position: relative;
  overflow: hidden;
}

.set-check-btn .play-icon {
  font-size: 11px;
  color: var(--accent-secondary);
  background-color: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.set-check-btn.timer-running {
  border-color: var(--accent-secondary);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15) 0%, rgba(30, 41, 59, 0.95) 100%);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.timer-running-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.set-live-countdown {
  font-size: 17px;
  font-weight: 900;
  color: var(--accent-secondary);
  letter-spacing: -0.5px;
  animation: pulse 1s infinite;
}

.timer-running-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.btn-timer-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-timer-action.btn-timer-pause {
  color: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

.btn-timer-action.btn-timer-skip {
  background-color: var(--accent-primary);
  color: #0b1120;
  border-color: var(--accent-primary);
}

.btn-timer-action:active {
  transform: scale(0.92);
}

.timer-progress-line {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  transition: width 1s linear;
  z-index: 1;
}

.exercise-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.session-footer-actions {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}

/* =========================================================
   4. HISTORY (Vertical Cards)
   ========================================================= */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-title {
  font-size: 16px;
  font-weight: 800;
}

.history-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-chip {
  background-color: var(--bg-input);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.history-chip strong {
  color: var(--accent-secondary);
}

/* =========================================================
   MOBILE BOTTOM-SHEET MODALS / DIALOGS
   ========================================================= */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content.bottom-sheet {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 16px 20px calc(var(--safe-bottom) + 20px) 20px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideUpSheet 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-handle,
.modal-header {
  flex-shrink: 0;
}

.modal-content.bottom-sheet form,
.modal-content.bottom-sheet .summary-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  margin-right: -4px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.modal-handle {
  width: 44px;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  margin: 0 auto 14px auto;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 26px;
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-actions-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* Routine Builder Vertical Cards */
.routine-exercise-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.routine-builder-card {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.routine-builder-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Summary Modal */
.summary-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.summary-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.summary-kpi-box {
  background-color: var(--bg-surface-elevated);
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.summary-kpi-val {
  font-size: 16px;
  font-weight: 900;
  color: var(--accent-primary);
}

.summary-kpi-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
  max-width: 600px;
  margin: 0 auto;
}

.toast {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-left: 4px solid var(--accent-primary);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 700;
  animation: slideDownToast 0.25s ease-out;
}

.toast.toast-error {
  border-left-color: var(--accent-danger);
}

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

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

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

/* User Pill & Header Tools */
.header-right-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.1s ease, border-color 0.2s ease;
}

.user-pill-btn:active {
  transform: scale(0.96);
  border-color: var(--accent-primary);
}

.user-pill-icon {
  font-size: 14px;
}

.user-pill-name {
  color: var(--accent-secondary);
  text-transform: capitalize;
}

.user-pill-badge {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-left: 2px;
}

/* Checkbox Toggle Styling (Mobile-friendly custom touch component) */
.checkbox-wrap {
  display: flex;
  align-items: center;
  margin: 6px 0 2px 0;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}

.custom-checkbox {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 6px;
  background-color: var(--bg-surface-elevated);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.checkbox-label input[type="checkbox"]:checked + .custom-checkbox {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .custom-checkbox::after {
  content: "✓";
  font-size: 14px;
  font-weight: 900;
  color: #0b1120;
  line-height: 1;
}

.checkbox-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

.checkbox-label:hover .checkbox-text,
.checkbox-label input[type="checkbox"]:checked ~ .checkbox-text {
  color: var(--text-primary);
}

.checkbox-label:active .custom-checkbox {
  transform: scale(0.92);
}

/* Manage Mode Preset Chips */
.quick-presets.manage-mode .preset-chip {
  border: 1px dashed var(--accent-secondary);
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent-secondary);
  position: relative;
  padding-right: 12px;
}

.quick-presets.manage-mode .preset-chip:active {
  background-color: var(--accent-secondary);
  color: #0b1120;
}

/* Sleek Manage Presets Toggle Button */
#toggleManagePresetsBtn.active-manage {
  background-color: var(--accent-primary) !important;
  color: #0b1120 !important;
  border-color: transparent !important;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

/* =========================================================
   5. WEIGHT TRACKER & INTERACTIVE GRAPH
   ========================================================= */

/* Weight Hero Card */
.weight-hero-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #1e293b 0%, #131b2e 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.weight-hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.weight-hero-kpi {
  background-color: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.clickable-kpi {
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.2s ease;
}

.clickable-kpi:active {
  transform: scale(0.97);
  border-color: var(--accent-primary);
}

.weight-kpi-lbl {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.weight-kpi-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.weight-kpi-val {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.weight-kpi-val.highlight {
  color: #eab308;
}

.weight-kpi-unit {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.weight-diff-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weight-diff-banner {
  background-color: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.weight-diff-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.weight-diff-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-primary);
}

/* Range Filter Buttons */
.chart-range-picker {
  display: flex;
  gap: 4px;
  background-color: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-full);
}

.chart-range-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chart-range-btn.active {
  background-color: var(--accent-primary);
  color: #0b1120;
}

/* SVG Chart Container */
.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 240px;
  margin-top: 8px;
}

.weight-svg-chart {
  width: 100%;
  height: 240px;
  overflow: visible;
  display: block;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 100;
}

.chart-tooltip strong {
  font-size: 13px;
  color: var(--accent-primary);
}

.chart-tooltip span {
  font-size: 10px;
  color: var(--text-secondary);
}

.chart-tooltip small {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* Stepper Input */
.weight-input-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.btn-stepper {
  min-width: 44px;
  height: var(--touch-target);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 800;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.btn-stepper:active {
  background-color: var(--accent-primary);
  color: #0b1120;
}

/* Weight History List */
.weight-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.weight-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.weight-row-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.weight-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weight-row-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.weight-row-note {
  font-size: 12px;
  color: var(--text-muted);
}

.weight-delta {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.weight-delta.diff-down {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.weight-delta.diff-up {
  background-color: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

.weight-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.weight-pill-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-secondary);
}

.weight-pill-val small {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-delete-weight {
  font-size: 16px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.btn-delete-weight:hover, .btn-delete-weight:active {
  color: var(--accent-danger);
}

/* =========================================================
   WORKOUTS SEGMENTED SUB-NAVIGATION & SUB-PANES
   ========================================================= */
.sub-nav-segmented {
  display: flex;
  background-color: var(--bg-surface-elevated);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 4px;
  margin-bottom: 4px;
  box-shadow: var(--shadow-sm);
}

.sub-nav-btn {
  flex: 1;
  min-height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  position: relative;
}

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

.sub-nav-btn.active {
  background-color: var(--accent-primary);
  color: #0b1120;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.35);
}

.live-pill-badge {
  background-color: var(--accent-danger);
  color: #ffffff;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
  animation: pulse 1.2s infinite;
}

.sub-nav-btn.active .live-pill-badge {
  background-color: #0b1120;
  color: var(--accent-danger);
}

.workout-subpane {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease-out;
}

.workout-subpane.active {
  display: flex;
}

/* ================= WATER TRACKER & MODE TOGGLE STYLES ================= */

/* Mode Switcher Toggle inside Remaining-box */
.hero-mode-toggle {
  display: flex;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 4px;
  gap: 4px;
  width: 100%;
  max-width: 250px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
  margin-bottom: 2px;
}

.hero-mode-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-mode-pill:hover {
  color: var(--text-primary);
}

.hero-mode-pill.active {
  background: var(--bg-surface-elevated, #1e293b);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.hero-mode-pill[data-mode="food"].active {
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.hero-mode-pill[data-mode="water"].active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.4);
}

/* Water Mode Card Variations */
.calorie-hero-card.water-mode-active {
  background: linear-gradient(180deg, #0e2740 0%, #0a182b 100%);
  border: 1px solid rgba(14, 165, 233, 0.35);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.15);
}

.calorie-hero-card.water-mode-active .ring-fg {
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
}

#waterRingUnit {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

#waterRingUnit:hover {
  color: #38bdf8;
}

.water-kpi-highlight {
  border-color: rgba(56, 189, 248, 0.3) !important;
}

.water-highlight-val {
  color: #38bdf8 !important;
}

.badge.water-badge {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Mode Boxes Group (preserves identical 16px vertical gap between sections) */
.mode-boxes-group,
#foodModeBoxes,
#waterModeBoxes {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

/* Water Quick Add 1-Tap Buttons */
.water-quick-buttons-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-sublabel {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.water-quick-buttons-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.btn-water-quick {
  background: var(--bg-surface-elevated, #1e293b);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-water-quick:hover {
  background: rgba(14, 165, 233, 0.15);
  border-color: #38bdf8;
  transform: translateY(-2px);
}

.btn-water-quick:active {
  transform: scale(0.96);
  background: rgba(14, 165, 233, 0.3);
}

.wq-icon {
  font-size: 20px;
  line-height: 1;
}

.wq-label {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.wq-sub {
  font-size: 10px;
  color: #7dd3fc;
  font-weight: 600;
}

/* Live Conversion Badge */
.water-conversion-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  color: #38bdf8;
  font-size: 12px;
  font-weight: 600;
}


/* Water Primary Button */
.btn-water {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: none;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-water:hover {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.45);
}

.btn-water:active {
  transform: scale(0.98);
}

/* Icon Picker for Presets */
.icon-selector-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.icon-pick-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-pick-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-pick-btn.active {
  background: rgba(14, 165, 233, 0.25);
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}
