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

:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --danger: #ef4444;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --tab-height: 56px;
  --header-height: 118px;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.07), 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);

  /* Log card accent colors */
  --c-water:    #2563eb;
  --c-water-bg: #dbeafe;
  --c-weight:   #7c3aed;
  --c-weight-bg:#ede9fe;
  --c-mood:     #d97706;
  --c-mood-bg:  #fef3c7;
  --c-food:     #16a34a;
  --c-food-bg:  #dcfce7;
  --c-med:      #0d9488;
  --c-med-bg:   #ccfbf1;
  --c-sleep:    #0284c7;
  --c-sleep-bg: #e0f2fe;
  --c-bowel:       #ca8a04;
  --c-bowel-bg:    #fefce8;
  --c-activity:    #f97316;
  --c-activity-bg: #ffedd5;

  /* BMI category colors (8 WHO classes) */
  --bmi-vsunder: #1e40af;
  --bmi-sunder:  #3b82f6;
  --bmi-under:   #06b6d4;
  --bmi-normal:  #10b981;
  --bmi-over:    #f59e0b;
  --bmi-obese1:  #f97316;
  --bmi-obese2:  #ef4444;
  --bmi-obese3:  #b91c1c;
}

html { height: 100%; }

body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--tab-height) + 72px);
}

button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }

/* ===========================
   Welcome Screen
   =========================== */
.welcome-screen {
  display: none; position: fixed; inset: 0;
  background: var(--surface); z-index: 300;
  overflow-y: auto; align-items: flex-start; justify-content: center;
}
.welcome-screen.active { display: flex; }
.welcome-content {
  padding: 48px 28px; max-width: 400px; width: 100%;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.welcome-logo { font-size: 64px; color: var(--primary); margin-bottom: 16px; }
.welcome-title { font-size: 32px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.welcome-tagline { font-size: 15px; color: var(--text-muted); margin-bottom: 28px; }
.welcome-features { list-style: none; width: 100%; margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.welcome-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text); text-align: left; background: var(--bg); padding: 10px 14px; border-radius: 10px; }
.welcome-features li i { font-size: 20px; color: var(--primary); flex-shrink: 0; }
.welcome-privacy { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.welcome-email-label { width: 100%; font-size: 13px; font-weight: 600; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; text-align: left; margin-bottom: 16px; }
.optional { font-weight: 400; }
.welcome-start-btn { background: var(--primary); color: #fff; border-radius: var(--radius); padding: 14px 32px; font-size: 16px; font-weight: 700; width: 100%; transition: opacity 0.15s; }
.welcome-start-btn:hover { opacity: 0.88; }

/* ===========================
   Date Header
   =========================== */
.date-header {
  position: fixed; top: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 100; box-shadow: 0 1px 0 rgba(0,0,0,0.07);
  display: flex; flex-direction: column;
}
.date-nav-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; height: 50px; padding: 0 16px; flex-shrink: 0;
}
/* Week strip nav wrapper */
.week-strip-nav { display: flex; align-items: center; gap: 2px; padding: 0 6px 6px; }
.week-nav-btn {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.week-nav-btn:active, .week-nav-btn:hover { background: var(--primary-light); color: var(--primary); }
/* Week strip lives inside the sticky header — override standalone styles */
.date-header .week-strip {
  flex: 1; margin: 0; box-shadow: none; border-radius: 10px;
  background: var(--bg); padding: 4px 4px 6px;
}
.date-display {
  display: flex; flex-direction: column; gap: 0; cursor: pointer;
  padding: 5px 10px; border-radius: 10px;
  -webkit-tap-highlight-color: transparent; transition: background 0.15s;
}
.date-display:active { background: var(--primary-light); }
@media (hover: hover) { .date-display:hover { background: var(--primary-light); } }
#dateLabel { font-size: 10px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1; }
#dateValue { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; }

/* ===========================
   Streak Badge — low-key
   =========================== */
.streak-badge {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--bg);
  transition: background 0.2s;
  cursor: pointer;
}
.streak-badge:not(.zero) {
  background: linear-gradient(135deg, #ff6b35 0%, #f59e0b 100%);
  box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}
.streak-icon {
  font-size: 16px; line-height: 1;
  color: var(--text-muted);
}
.streak-badge:not(.zero) .streak-icon { color: #fff; }
#streakCount {
  font-size: 14px; font-weight: 800; line-height: 1;
  color: var(--text-muted);
}
.streak-badge:not(.zero) #streakCount { color: #fff; }

/* ===========================
   Week Strip
   =========================== */
.week-strip {
  display: flex; background: var(--surface); border-radius: var(--radius);
  padding: 8px 4px 10px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.week-day {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 4px 0 2px; border-radius: 10px;
  -webkit-tap-highlight-color: transparent; transition: background 0.12s;
}
.week-day:active:not(:disabled) { background: var(--primary-light); }
@media (hover: hover) { .week-day:hover:not(:disabled) { background: var(--primary-light); } }
.wd-label { font-size: 9px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1; }
.wd-num { font-size: 13px; font-weight: 700; color: var(--text); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.wd-dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; margin-top: 1px; transition: background 0.15s; }
.wd-dot.has-data { background: var(--primary); opacity: 0.5; }
.week-day.active .wd-num { background: var(--primary); color: #fff; }
.week-day.active .wd-label { color: var(--primary); }
.week-day.active .wd-dot.has-data { background: #fff; opacity: 0.8; }
.week-day.is-today .wd-num { outline: 2px solid var(--primary); outline-offset: -2px; }
.week-day:disabled { opacity: 0.25; cursor: default; }

/* ===========================
   Main Content
   =========================== */
.main-content { padding: 12px; max-width: 600px; margin: 0 auto; }

/* ===========================
   Tab Sections
   =========================== */
.tab-section { display: none; }
.tab-section.active { display: block; }
.section-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 12px; }

/* ===========================
   Tab Bar
   =========================== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tab-height);
  background: rgba(255,255,255,0.92); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px); border-top: 1px solid rgba(0,0,0,0.07);
  display: flex; z-index: 100; overflow: visible;
}
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--text-muted); transition: color 0.15s; padding: 3px 0; -webkit-tap-highlight-color: transparent; }
.tab-btn.active { color: var(--primary); }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 8px; }
.about-header-btn { flex: none; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 22px; border-radius: 50%; padding: 0; -webkit-tap-highlight-color: transparent; }

/* ===========================
   FAB + Bottom Sheet
   =========================== */
.fab-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 99; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fadeIn 0.2s ease; }
.fab-backdrop.open { display: block; }
body.fab-open { overflow: hidden; touch-action: none; }
body.fab-open .date-header,
body.fab-open .tab-btn { pointer-events: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fab-container { position: relative; z-index: 160; width: 56px; height: 56px; pointer-events: none; flex-shrink: 0; align-self: center; margin-top: -16px; }
.fab-container.open { pointer-events: auto; }
.fab-main { width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(79,70,229,0.45), 0 1px 4px rgba(0,0,0,0.15); -webkit-tap-highlight-color: transparent; pointer-events: auto; position: relative; overflow: hidden; transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1); }
.fab-main:active { transform: scale(0.92) !important; }
/* FAB icon swap: umbrella ↔ × */
.fab-icon-closed,
.fab-icon-open { position: absolute; font-size: 26px; line-height: 1; transition: opacity 0.18s ease, transform 0.28s cubic-bezier(0.34,1.56,0.64,1); }
.fab-icon-closed { opacity: 1; transform: scale(1) rotate(0deg); }
.fab-icon-open   { opacity: 0; transform: scale(0.6) rotate(-45deg); }
.fab-container.open .fab-icon-closed { opacity: 0; transform: scale(0.6) rotate(45deg); }
.fab-container.open .fab-icon-open   { opacity: 1; transform: scale(1) rotate(0deg); }
/* Bottom sheet */
.fab-sheet { position: fixed; bottom: 0; left: 0; right: 0; z-index: 150; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 16px calc(32px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 40px rgba(0,0,0,0.18); transform: translateY(100%); visibility: hidden; transition: transform 0.38s cubic-bezier(0.32,0.72,0,1), visibility 0s 0.38s; will-change: transform; touch-action: pan-y; }
.fab-sheet.open { transform: translateY(0); visibility: visible; transition: transform 0.38s cubic-bezier(0.32,0.72,0,1), visibility 0s 0s; }
.fab-sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 14px; }
.fab-sheet-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 14px; text-align: center; }
.fab-sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
/* Sheet items */
.fab-item { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 10px; border-radius: 16px; background: var(--bg); -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease, opacity 0.12s ease; cursor: pointer; }
.fab-item:active { transform: scale(0.91); opacity: 0.8; }
.fab-item-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.fab-item-label { font-size: 11px; font-weight: 600; color: var(--text); text-align: center; line-height: 1.2; }
/* Per-action icon colors */
.fab-item[data-action="food"]        .fab-item-icon { background: var(--c-food-bg);   color: var(--c-food); }
.fab-item[data-action="water"]       .fab-item-icon { background: var(--c-water-bg);  color: var(--c-water); }
.fab-item[data-action="mood"]        .fab-item-icon { background: var(--c-mood-bg);   color: var(--c-mood); }
.fab-item[data-action="activity"]    .fab-item-icon { background: var(--c-activity-bg); color: var(--c-activity); }
.fab-item[data-action="weight"]      .fab-item-icon { background: var(--c-weight-bg); color: var(--c-weight); }
.fab-item[data-action="sleep"]       .fab-item-icon { background: var(--c-sleep-bg);  color: var(--c-sleep); }
.fab-item[data-action="supplements"] .fab-item-icon { background: var(--c-med-bg);    color: var(--c-med); }
.fab-item[data-action="bowel"]       .fab-item-icon { background: var(--c-bowel-bg);  color: var(--c-bowel); }
/* Staggered entrance */
@keyframes fabItemIn { from { opacity: 0; transform: translateY(12px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
.fab-sheet.open .fab-item { animation: fabItemIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both; }
.fab-sheet.open .fab-item:nth-child(1) { animation-delay: 0.05s; }
.fab-sheet.open .fab-item:nth-child(2) { animation-delay: 0.08s; }
.fab-sheet.open .fab-item:nth-child(3) { animation-delay: 0.11s; }
.fab-sheet.open .fab-item:nth-child(4) { animation-delay: 0.14s; }
.fab-sheet.open .fab-item:nth-child(5) { animation-delay: 0.17s; }
.fab-sheet.open .fab-item:nth-child(6) { animation-delay: 0.20s; }
.fab-sheet.open .fab-item:nth-child(7) { animation-delay: 0.23s; }
.fab-sheet.open .fab-item:nth-child(8) { animation-delay: 0.26s; }

/* ===========================
   Unified Stats Grid (Log Tab)
   =========================== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; }
.sc {
  position: relative;
  background: linear-gradient(145deg, color-mix(in srgb, var(--sc-color) 10%, var(--surface)) 0%, var(--surface) 65%);
  border-radius: 14px;
  padding: 11px 12px;
  display: flex; flex-direction: column; gap: 3px; min-height: 90px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.sc::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 42%;
  background: linear-gradient(180deg, rgba(255,255,255,0.055) 0%, transparent 100%);
  pointer-events: none;
  border-radius: 14px 14px 0 0;
}
.sc-head { display: flex; align-items: center; gap: 5px; color: var(--sc-color); margin-bottom: 1px; }
.sc-head i { font-size: 13px; }
.sc-head span { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.sc-body { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.sc-val { font-size: 22px; font-weight: 800; line-height: 1; color: var(--text); }
.sc-val.muted { color: var(--text-muted); }
.sc-emoji { font-size: 24px; line-height: 1; }
.sc-unit { font-size: 11px; font-weight: 500; color: var(--text-muted); align-self: flex-end; padding-bottom: 1px; }
.sc-sub { font-size: 10px; color: var(--text-muted); line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sc-sub2 { opacity: 0.7; }
/* Water-specific */
.sc-water-btns { display: flex; gap: 5px; margin-left: auto; align-self: center; }
.sc-adj { width: 26px; height: 26px; border-radius: 50%; background: var(--border); color: var(--text); font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; -webkit-tap-highlight-color: transparent; }
.sc-adj--plus { background: color-mix(in srgb, var(--sc-color) 15%, transparent); color: var(--sc-color); }
.sc-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 2px; overflow: hidden; }
.sc-bar-fill { height: 100%; background: var(--sc-color); border-radius: 2px; transition: width 0.3s ease; }
/* Weight card — tappable */
.sc--weight { cursor: pointer; position: relative; }
.sc--weight:active { opacity: 0.8; }
.sc-edit-hint { position: absolute; top: 10px; right: 10px; font-size: 12px; color: var(--text-muted); opacity: 0.45; pointer-events: none; }
.sc--weight:hover .sc-edit-hint { opacity: 0.8; }
/* ===========================
   Day Timeline (Log Tab)
   =========================== */
.day-timeline { padding: 24px 0; }
.tl-empty { text-align: center; padding: 32px 16px 16px; color: var(--text-muted); }
.tl-empty-icon { font-size: 36px; display: block; margin-bottom: 8px; opacity: 0.35; }
.tl-entry { margin-bottom: 8px; }
.tl-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--tl-color, var(--text-muted)) 8%, var(--surface)) 0%, var(--surface) 60%) !important;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  /* override .entry-card flex layout */
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  gap: 0 !important;
}
.tl-main { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 10px; }
.tl-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.tl-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tl-time { font-size: 11px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.tl-meta { font-size: 12px; color: var(--text-muted); padding: 6px 12px; background: color-mix(in srgb, var(--tl-color, transparent) 5%, transparent); }
/* ===========================
   Compact Loggers (Sleep/Bowel)
   =========================== */
.compact-logger { background: var(--surface); border-radius: 14px; padding: 14px 16px; margin: 0 16px 12px; }
.compact-logger-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.compact-logger-icon { font-size: 18px; color: var(--text-muted); }
.compact-logger-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
/* ===========================
   Home Greeting
   =========================== */
.home-greeting {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  padding: 4px 0 10px;
}

/* ===========================
   Summary Grid (Home)
   =========================== */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.summary-card { background: var(--surface); border-radius: var(--radius); padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: var(--shadow); }
.summary-icon { font-size: 28px; line-height: 1; }
.summary-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ===========================
   Chart Card (Home)
   =========================== */
.chart-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px 16px 12px; box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 12px;
}
.bmi-card-wrap { padding-bottom: 16px; }
.chart-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.chart-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.chart-subtitle { font-size: 11px; color: var(--text-muted); }
.chart-stats { text-align: right; }
.chart-stat-current { font-size: 18px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.chart-stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.weight-chart { width: 100%; }
.chart-empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 0 16px; color: var(--text-muted); text-align: center; }
.chart-empty-state i { font-size: 36px; opacity: 0.35; }
.chart-empty-state p { font-size: 13px; }
.chart-single { text-align: center; padding: 16px 0 8px; }
.chart-single-weight { font-size: 36px; font-weight: 800; color: var(--primary); line-height: 1; }
.chart-single-weight span { font-size: 18px; font-weight: 600; }
.chart-single-delta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.chart-single-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; opacity: 0.7; }

/* ===========================
   BMI Gauge
   =========================== */
.bmi-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.bmi-number { font-size: 44px; font-weight: 900; line-height: 1; flex-shrink: 0; }
.bmi-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 10px; border-radius: 20px; border: 1.5px solid; line-height: 1.35; }
.bmi-meta-row { font-size: 12px; color: var(--text-muted); margin-bottom: 0; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.bmi-sep { opacity: 0.35; }
.bmi-gauge-wrap { width: 100%; margin: 4px 0 4px; }
.bmi-goal { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.bmi-healthy-range { font-size: 11px; color: var(--text-muted); }
.bmi-healthy-range strong { color: var(--text); }
.bmi-setup-hint { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 0 8px; text-align: center; color: var(--text-muted); }
.bmi-setup-hint i { font-size: 32px; opacity: 0.35; }
.bmi-setup-hint p { font-size: 13px; }
.bmi-scale-table { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 1px; }
.bmi-scale-row { display: grid; grid-template-columns: 10px 1fr auto auto; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 6px; }
.bmi-scale-row--active { background: rgba(128,128,128,0.1); }
.bmi-scale-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bmi-scale-name { font-size: 12px; color: var(--text-muted); }
.bmi-scale-range { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.bmi-scale-arrow { font-size: 10px; color: var(--text-muted); }

/* ===========================
   Log Tab — Cards
   =========================== */
.log-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.log-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.log-card-head-left {
  display: flex; align-items: center; gap: 8px;
}

.log-card-ico {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.log-ico--water   { background: var(--c-water-bg);  color: var(--c-water); }
.log-ico--weight  { background: var(--c-weight-bg); color: var(--c-weight); }
.log-ico--mood    { background: var(--c-mood-bg);   color: var(--c-mood); }
.log-ico--food    { background: var(--c-food-bg);   color: var(--c-food); }
.log-ico--medicine { background: var(--c-med-bg);   color: var(--c-med); }

.log-card-name {
  font-size: 13px; font-weight: 700; color: var(--text);
}

.log-card-count {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--bg); border-radius: 10px; padding: 1px 7px;
}

.log-add-btn {
  display: flex; align-items: center; gap: 4px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 20px; padding: 6px 14px;
  font-size: 13px; font-weight: 700; min-height: 36px;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.log-add-btn:active, .log-add-btn:hover { background: var(--primary); color: #fff; }
.log-add-btn--food    { background: var(--c-food-bg);     color: var(--c-food); }
.log-add-btn--food:active, .log-add-btn--food:hover { background: var(--c-food); color: #fff; }
.log-add-btn--activity { background: var(--c-activity-bg); color: var(--c-activity); }
.log-add-btn--activity:active, .log-add-btn--activity:hover { background: var(--c-activity); color: #fff; }
.log-add-btn--medicine { background: var(--c-med-bg);      color: var(--c-med); }
.log-add-btn--medicine:active, .log-add-btn--medicine:hover { background: var(--c-med); color: #fff; }

.log-card-body { padding: 14px; }

/* Accent top-border per card type */
.log-card--water   { border-top: 3px solid var(--c-water); }
.log-card--weight  { border-top: 3px solid var(--c-weight); }
.log-card--mood    { border-top: 3px solid var(--c-mood); }
.log-card--food    { border-top: 3px solid var(--c-food); }
.log-card--medicine { border-top: 3px solid var(--c-med); }

/* ── Water in log card ── */
.water-counter-row { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 10px; }
.water-btn { width: 44px; height: 44px; border-radius: 50%; font-size: 24px; font-weight: 300; display: flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s; -webkit-tap-highlight-color: transparent; }
.water-btn.minus { background: var(--bg); color: var(--text-muted); }
.water-btn.minus:active, .water-btn.minus:hover { background: #fee2e2; color: var(--danger); }
.water-btn.plus { background: var(--c-water); color: #fff; }
.water-btn.plus:hover { opacity: 0.88; }
.water-count-display { display: flex; flex-direction: column; align-items: center; }
.water-count-display #waterGlasses { font-size: 40px; font-weight: 800; color: var(--c-water); line-height: 1; }
.water-unit { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.progress-bar-track { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 5px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 999px; transition: width 0.3s ease; max-width: 100%; }
.water-goal-label { font-size: 11px; color: var(--text-muted); text-align: center; }

/* ── Weight in log card ── */
.btn-log { background: var(--primary); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; flex-shrink: 0; transition: opacity 0.15s; }
.btn-log:hover { opacity: 0.88; }
.btn-log.full-width { display: block; width: 100%; text-align: center; flex-shrink: unset; margin-top: 4px; padding: 11px; }
.weight-display { font-size: 13px; color: var(--text-muted); padding: 2px 0; }
.weight-logged { color: var(--c-weight); font-weight: 700; }
.weight-empty { color: var(--text-muted); }

/* ── Mood in log card ── */
.emoji-row { display: flex; justify-content: space-between; margin-bottom: 10px; }
.emoji-btn {
  font-size: 22px; line-height: 1; padding: 6px 2px; border-radius: 12px;
  transition: transform 0.12s, background 0.15s;
  background: transparent; min-width: 44px; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  -webkit-tap-highlight-color: transparent;
}
.emoji-label { font-size: 9px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; }
.emoji-btn:hover { transform: scale(1.1); background: var(--c-mood-bg); }
.emoji-btn.selected { background: var(--c-mood-bg); outline: 2px solid var(--c-mood); transform: scale(1.08); border-radius: 12px; }
.emoji-btn.selected .emoji-label { color: var(--c-mood); }
.mood-note { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 14px; color: var(--text); resize: none; margin-bottom: 10px; transition: border-color 0.15s; background: var(--bg); }
.mood-note:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.mood-emoji-display { font-size: 22px; margin-right: 6px; }

/* ── Entry lists in log cards ── */
.log-entry-list { display: flex; flex-direction: column; }
.log-entry-list:not(:empty) { padding: 0 14px 14px; gap: 7px; }
.entry-group-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; padding: 8px 0 4px; }
.entry-card { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entry-info { flex: 1; min-width: 0; }
.entry-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta { font-size: 12px; color: var(--text-muted); }
.entry-card-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.edit-btn { color: var(--text-muted); font-size: 17px; padding: 6px; border-radius: 8px; transition: color 0.15s, background 0.15s; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.edit-btn:active, .edit-btn:hover { color: #0891b2; background: #ecfeff; }
.delete-btn { color: var(--text-muted); font-size: 17px; padding: 6px; border-radius: 8px; transition: color 0.15s, background 0.15s; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.delete-btn:active, .delete-btn:hover { color: var(--danger); background: #fef2f2; }
.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; padding: 16px 14px; }

/* Modal quick-add chips (inside suppModal) */
.modal-quick-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; padding: 10px 12px; background: var(--primary-light); border-radius: 10px; }
.mqc-label { font-size: 10px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.07em; width: 100%; margin-bottom: 2px; }
.supp-quick-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface); border: 1.5px solid var(--primary); border-radius: 20px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--primary); cursor: pointer; transition: background 0.15s, color 0.15s; -webkit-tap-highlight-color: transparent; }
.supp-quick-chip:active, .supp-quick-chip:hover { background: var(--primary); color: #fff; }
.sqc-dose { font-size: 10px; font-weight: 500; opacity: 0.65; }
.supp-quick-chip:hover .sqc-dose, .supp-quick-chip:active .sqc-dose { opacity: 0.85; }

/* Medication chips */
.medication-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 2px; }
.med-chips-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; width: 100%; margin-bottom: 2px; }
.med-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface); border: 1.5px solid var(--c-med-bg); border-radius: 20px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--text); transition: border-color 0.15s, background 0.15s; -webkit-tap-highlight-color: transparent; }
.med-chip:active, .med-chip:hover { border-color: var(--c-med); background: var(--c-med-bg); color: var(--c-med); }
.med-chip-dose { font-weight: 400; color: var(--text-muted); font-size: 11px; }
.med-chip:hover .med-chip-dose { color: var(--c-med); opacity: 0.8; }

/* ===========================
   About Tab
   =========================== */

/* Settings index list */
.about-index { padding-bottom: 8px; }
.settings-group-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 4px; margin: 20px 0 6px; }
.settings-group-label:first-child { margin-top: 4px; }
.settings-group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 4px; }
.settings-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); -webkit-tap-highlight-color: transparent; transition: background 0.12s; }
.settings-row:last-child { border-bottom: none; }
.settings-row:active { background: var(--bg); }
.settings-row-icon { font-size: 18px; color: var(--primary); flex-shrink: 0; width: 22px; text-align: center; }
.settings-row-label { flex: 1; font-size: 15px; font-weight: 500; color: var(--text); }
.settings-row-chevron { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.settings-row-value { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }

/* Unit input with inline toggle */
.unit-input-wrap { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); transition: border-color 0.15s; overflow: hidden; }
.unit-input-wrap:focus-within { border-color: var(--primary); background: var(--surface); }
.unit-input-wrap .unit-input { flex: 1; min-width: 0; border: none; background: transparent; border-radius: 0; padding: 10px 12px; font-size: 15px; color: var(--text); font-family: inherit; outline: none; }
.unit-input-wrap .unit-input:focus { border: none; background: transparent; outline: none; }
.unit-divider { width: 1px; background: var(--border); align-self: stretch; flex-shrink: 0; }
.unit-toggle { display: flex; align-items: center; padding: 4px; gap: 2px; flex-shrink: 0; }
.unit-btn { padding: 5px 9px; font-size: 12px; font-weight: 600; border-radius: 5px; color: var(--text-muted); transition: background 0.15s, color 0.15s; line-height: 1; }
.unit-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* Goal stats */
.goal-stats { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.goal-stat-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.goal-stat-icon { font-size: 14px; flex-shrink: 0; }
.goal-stat-tag { font-size: 11px; color: var(--text-muted); margin-left: 2px; }

/* Sub-page */
.about-subpage[hidden] { display: none; }
.settings-back-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; color: var(--primary); padding: 4px 0; margin-bottom: 12px; -webkit-tap-highlight-color: transparent; }
.settings-page-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 16px; }

.about-card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.about-section-title { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 14px; }
.about-card-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.4; }

.med-form-grid { display: flex; flex-direction: column; gap: 8px; }
.med-form-grid .form-input { width: 100%; font-size: 14px; }

/* Meal time multi-select toggles */
.meal-time-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.meal-time-toggle {
  padding: 5px 13px; border-radius: 20px; font-size: 13px; font-weight: 600;
  background: var(--bg); color: var(--text-muted);
  border: 1.5px solid var(--border);
  transition: all 0.12s; -webkit-tap-highlight-color: transparent;
}
.meal-time-toggle.selected {
  background: var(--primary-light); color: var(--primary);
  border-color: var(--primary);
}
.meal-time-toggle:active, .meal-time-toggle:hover { border-color: var(--primary); }

.add-preset-btn {
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 8px; padding: 9px 14px;
  font-size: 13px; font-weight: 700;
  transition: background 0.15s, color 0.15s; width: 100%; justify-content: center;
}
.add-preset-btn:hover { background: var(--primary); color: #fff; }

.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 8px 0; }
.preset-item { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.preset-item-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.preset-item-meta { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.preset-delete { color: var(--text-muted); font-size: 13px; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: color 0.15s, background 0.15s; }
.preset-delete:hover { color: var(--danger); background: #fef2f2; }

.meal-type-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.meal-type-tag { display: inline-flex; align-items: center; gap: 5px; background: var(--primary-light); color: var(--primary); border-radius: 20px; padding: 5px 10px 5px 12px; font-size: 13px; font-weight: 600; }
.meal-type-delete { color: var(--primary); font-size: 11px; opacity: 0.7; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: opacity 0.15s, background 0.15s; }
.meal-type-delete:hover { opacity: 1; background: rgba(79,70,229,0.15); }
.meal-type-add-row { display: flex; gap: 8px; align-items: center; }
.meal-type-add-row .form-input { flex: 1; font-size: 13px; padding: 8px 10px; }
.btn-icon-add { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 20px; font-weight: 300; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity 0.15s; }
.btn-icon-add:hover { opacity: 0.85; }

.save-about-btn { background: var(--primary); color: #fff; width: 100%; padding: 13px; border-radius: var(--radius); font-size: 15px; font-weight: 700; margin-bottom: 20px; transition: background 0.2s, box-shadow 0.2s, opacity 0.15s; }
.save-about-btn:hover { opacity: 0.88; }
.save-about-btn.has-changes {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  box-shadow: 0 4px 16px rgba(79,70,229,0.45);
}

/* Data management */
.data-mgmt-row { display: flex; gap: 10px; }
.data-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 8px; border-radius: var(--radius);
  font-size: 13px; font-weight: 700; transition: opacity 0.15s;
}
.data-btn--export { background: var(--primary); color: #fff; }
.data-btn--import { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.data-btn:hover { opacity: 0.82; }
/* Google Drive Sync card */
.drive-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
  font-size: 13px; font-weight: 500;
}
.drive-status--off  { background: var(--bg); color: var(--text-muted); }
.drive-status--on   { background: #dcfce7; color: #166534; }
.drive-status-icon  { font-size: 17px; flex-shrink: 0; }
.drive-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.drive-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 700; transition: opacity 0.15s;
}
.drive-btn:disabled { opacity: 0.55; pointer-events: none; }
.drive-btn--connect    { background: #4285f4; color: #fff; }
.drive-btn--sync       { background: var(--primary); color: #fff; }
.drive-btn--disconnect { background: var(--bg); color: var(--text-muted); border: 1.5px solid var(--border); font-weight: 600; font-size: 12px; padding: 10px 12px; }
.drive-btn:hover       { opacity: 0.85; }
.drive-merge-note      { margin-top: 10px; }
@keyframes drive-spin { to { transform: rotate(360deg); } }
.drive-spin { display: inline-block; animation: drive-spin 0.9s linear infinite; }

.app-info { text-align: center; padding: 4px 0 12px; }
.app-info-text { font-size: 12px; color: var(--text-muted); }
.app-version { font-size: 11px; color: var(--text-muted); opacity: 0.5; margin-top: 4px; }

/* ===========================
   Modals
   =========================== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: flex-end; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 18px 32px; width: 100%; max-width: 600px; box-shadow: var(--shadow-md); animation: slideUp 0.22s ease-out; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-clear-link { display: block; width: 100%; margin-top: 6px; padding: 10px 0; font-size: 14px; font-weight: 500; color: #ef4444; background: none; border: none; cursor: pointer; text-align: center; }
.modal-clear-link:hover { opacity: 0.75; }
.form-label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.form-input { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: inherit; font-size: 15px; color: var(--text); background: var(--bg); transition: border-color 0.15s; min-width: 0; width: 100%; box-sizing: border-box; }
.form-input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
select.form-input {
  appearance: none; -webkit-appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-btn { flex: 1; padding: 12px; border-radius: var(--radius); font-size: 15px; font-weight: 600; transition: opacity 0.15s; }
.modal-btn.cancel { background: var(--bg); color: var(--text-muted); }
.modal-btn.cancel:hover { background: var(--border); }
.modal-btn.save { background: var(--primary); color: #fff; }
.modal-btn.save:hover { opacity: 0.88; }
.modal-btn.danger { background: transparent; color: #ef4444; border: 1px solid #ef444430; flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }
.modal-btn.danger:hover { background: #fef2f2; }
.quantity-row { display: flex; gap: 8px; }
.quantity-input { flex: 1; }
.unit-select { width: 100px; flex-shrink: 0; }

/* ===========================
   Date Picker Calendar
   =========================== */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-month-label { font-size: 16px; font-weight: 700; color: var(--text); }
.cal-nav { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--text-muted); -webkit-tap-highlight-color: transparent; }
.cal-nav:active:not(:disabled), .cal-nav:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); }
.cal-nav:disabled { opacity: 0.2; cursor: default; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 4px; }
.cal-weekdays span { text-align: center; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; margin-bottom: 8px; }
.cal-day, .cal-empty { aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 500; color: var(--text); border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.cal-day:active:not(:disabled), .cal-day:hover:not(:disabled) { background: var(--primary-light); }
.cal-day.is-today { color: var(--primary); font-weight: 700; }
.cal-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day:disabled { opacity: 0.2; cursor: default; }
.cal-day.has-data { position: relative; }
.cal-day.has-data::after {
  content: ''; position: absolute; bottom: 3px; left: 50%;
  transform: translateX(-50%); width: 4px; height: 4px;
  border-radius: 50%; background: var(--primary); opacity: 0.5;
}
.cal-day.selected.has-data::after { background: #fff; opacity: 0.85; }
.cal-day.is-today.has-data::after { background: var(--primary); }

/* ===========================
   Activity Log Card
   =========================== */
:root {
  --c-activity:    #f97316;
  --c-activity-bg: #ffedd5;
}
.log-ico--activity  { background: var(--c-activity-bg); color: var(--c-activity); }
.log-card--activity { border-top: 3px solid var(--c-activity); }
.log-ico--sleep     { background: var(--c-sleep-bg);    color: var(--c-sleep); }
.log-card--sleep    { border-top: 3px solid var(--c-sleep); }
.log-ico--bowel     { background: var(--c-bowel-bg);    color: var(--c-bowel); }
.log-card--bowel    { border-top: 3px solid var(--c-bowel); }

/* Sleep inputs */
.sleep-time-label { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.sleep-time-text { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sleep-time-text i { font-size: 13px; }
.sleep-time-input { width: 100%; font-size: 15px; }
.sleep-duration-badge { font-size: 13px; font-weight: 700; color: var(--c-sleep); background: var(--c-sleep-bg); padding: 3px 10px; border-radius: 20px; }


/* Bowel type selector */
.bowel-type-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.bowel-type-btn { padding: 10px 4px; min-height: 44px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--text-muted); background: var(--bg); border: 1.5px solid var(--border); cursor: pointer; user-select: none; -webkit-user-select: none; transition: background 0.12s, color 0.12s, border-color 0.12s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.bowel-type-btn.selected { background: var(--c-bowel-bg); color: var(--c-bowel); border-color: var(--c-bowel); }
.bowel-type-btn:active { opacity: 0.75; }

/* ─── Food Modal ────────────────────────────────── */
.food-meal-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.food-meal-pill { padding: 8px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-muted); background: var(--bg); border: 1.5px solid var(--border); cursor: pointer; user-select: none; -webkit-user-select: none; transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.food-meal-pill.selected { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent); }
.food-meal-pill:active { transform: scale(0.96); }
/* Individual item chips — no outer container card */
#foodItemList { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.food-item-row { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; height: 52px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; transition: border-color 0.15s; }
.food-item-row:focus-within { border-color: var(--primary); }
.food-item-input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; font-size: 14px; color: var(--text); font-family: inherit; }
.food-item-qty-unit { display: flex; align-items: center; flex-shrink: 0; background: color-mix(in srgb, var(--text) 7%, transparent); border-radius: 999px; padding: 0 10px 0 12px; height: 32px; gap: 4px; }
.food-item-qty { width: 36px; background: transparent; border: none; outline: none; font-size: 13px; font-weight: 500; color: var(--text); font-family: inherit; text-align: right; padding: 0; }
.food-item-qty::placeholder { color: var(--text-muted); }
.food-item-qty-divider { width: 1px; height: 12px; background: var(--text-muted); opacity: 0.25; flex-shrink: 0; }
.food-item-unit-wrap { display: none; }
.food-item-unit { appearance: none; -webkit-appearance: none; background: transparent; border: none; outline: none; font-size: 12px; font-weight: 600; color: var(--text-muted); font-family: inherit; cursor: pointer; padding: 0 14px 0 0; }
.food-item-unit-caret { font-size: 9px; color: var(--text-muted); pointer-events: none; margin-left: -10px; flex-shrink: 0; }
.food-item-remove { flex-shrink: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: transparent; border: none; border-radius: 8px; color: var(--text-muted); font-size: 14px; cursor: pointer; opacity: 0.45; -webkit-tap-highlight-color: transparent; transition: opacity 0.12s, color 0.12s; }
.food-item-remove:hover { color: #ef4444; opacity: 1; }
.food-add-item-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 11px; font-size: 13px; font-weight: 600; color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); border: 1.5px solid color-mix(in srgb, var(--primary) 25%, transparent); border-radius: 14px; cursor: pointer; margin-bottom: 14px; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: background 0.15s; }
.food-add-item-btn:hover { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.food-add-item-btn:active { opacity: 0.75; }
.food-advanced-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 4px 0; margin-bottom: 10px; -webkit-tap-highlight-color: transparent; }
.food-advanced-toggle:hover { color: var(--text); }
.food-advanced-toggle i { font-size: 12px; }

/* ===========================
   Food Calorie Tag
   =========================== */
.entry-cal { color: var(--c-food); font-weight: 700; }

/* ===========================
   Empty States with Icon
   =========================== */
.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px 14px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-state-icon { font-size: 28px; opacity: 0.3; line-height: 1; }
.empty-state p { margin: 0; }

/* ===========================
   Mood Trend Strip (Home)
   =========================== */
.mood-trend-card { margin-bottom: 12px; }
.mood-trend-strip { display: flex; justify-content: space-between; padding: 4px 0 6px; }
.mood-trend-day { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.mood-trend-label { font-size: 9px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mood-trend-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1; transition: transform 0.1s; }

/* ===========================
   Weekly Summary (Home)
   =========================== */
.weekly-summary-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; padding: 4px 0 4px; }
.weekly-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--bg); border-radius: 10px; padding: 10px 4px; }
.weekly-stat-val { font-size: 20px; font-weight: 800; color: var(--primary); line-height: 1; }
.weekly-stat-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ===========================
   Desktop
   =========================== */
@media (min-width: 600px) {
  .main-content { padding: 12px; }
  .modal { border-radius: var(--radius); margin-bottom: 80px; max-width: 420px; }
  .modal-overlay { align-items: center; }
  .summary-grid { grid-template-columns: repeat(4,1fr); }
}

/* ===========================
   Theme Picker (inline on settings index)
   =========================== */
.settings-row--static { cursor: default; }
.settings-row--static:active { background: transparent; }
.theme-picker { display: flex; background: var(--bg); border-radius: 8px; padding: 2px; gap: 2px; flex-shrink: 0; }
.theme-picker-btn { padding: 5px 10px; font-size: 12px; font-weight: 600; border-radius: 6px; color: var(--text-muted); transition: background 0.15s, color 0.15s; white-space: nowrap; }
.theme-picker-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* ===========================
   About tab: hide week strip, shrink header
   =========================== */
body[data-tab="about"] .week-strip-nav { display: none; }
body[data-tab="about"] { padding-top: 62px; } /* overridden by syncHeaderOffset() at runtime */

/* ===========================
   Micro-Animations
   =========================== */

/* Entry cards fade-slide in */
@keyframes entryIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.entry-card { animation: entryIn 0.18s ease-out both; }

/* Stagger via nth-child */
.entry-card:nth-child(1) { animation-delay: 0.00s; }
.entry-card:nth-child(2) { animation-delay: 0.04s; }
.entry-card:nth-child(3) { animation-delay: 0.08s; }
.entry-card:nth-child(4) { animation-delay: 0.12s; }
.entry-card:nth-child(5) { animation-delay: 0.16s; }
.entry-card:nth-child(n+6) { animation-delay: 0.20s; }

/* Entry card delete fade-out */
@keyframes entryOut {
  from { opacity: 1; transform: scale(1); max-height: 80px; }
  to   { opacity: 0; transform: scale(0.95); max-height: 0; padding: 0; margin: 0; }
}
.entry-card.removing {
  animation: entryOut 0.18s ease-in forwards;
  pointer-events: none; overflow: hidden;
}

/* Modal spring entrance */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  60%  { transform: translateY(-4px); opacity: 1; }
  to   { transform: translateY(0); opacity: 1; }
}


/* Tab section fade */
.tab-section {
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.tab-section.active {
  opacity: 1; pointer-events: auto;
}
/* First active state before JS runs — prevent invisible initial render */
.tab-section:first-of-type { opacity: 1; }

/* Water counter pop */
@keyframes waterPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  70%  { transform: scale(0.93); }
  100% { transform: scale(1); }
}
.water-pop { animation: waterPop 0.28s cubic-bezier(0.34,1.56,0.64,1); }

/* Summary cards fade-in on load */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.summary-card { animation: cardIn 0.25s ease-out both; }
.summary-card:nth-child(1) { animation-delay: 0.05s; }
.summary-card:nth-child(2) { animation-delay: 0.10s; }
.summary-card:nth-child(3) { animation-delay: 0.15s; }
.summary-card:nth-child(4) { animation-delay: 0.20s; }

/* Theme toggle icon spin */
@keyframes iconSpin {
  from { transform: rotate(0deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(360deg) scale(1); opacity: 1; }
}
.theme-icon-spin { animation: iconSpin 0.35s cubic-bezier(0.34,1.56,0.64,1); }

/* ===========================
   Dark Mode
   — applied by OS when no user pref, OR by explicit data-theme="dark"
   =========================== */
/* OS auto-dark + explicit dark toggle */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #0f172a; --surface: #1e293b; --text: #f1f5f9; --text-muted: #94a3b8;
    --border: #334155; --primary: #818cf8; --primary-light: #1e1b4b; --danger: #f87171;
    --c-water: #60a5fa; --c-water-bg: #1e3a5f; --c-weight: #a78bfa; --c-weight-bg: #2e1065;
    --c-mood: #fbbf24; --c-mood-bg: #451a03; --c-food: #4ade80; --c-food-bg: #052e16;
    --c-med: #2dd4bf; --c-med-bg: #042f2e; --c-activity: #fb923c; --c-activity-bg: #431407;
    --c-sleep: #38bdf8; --c-sleep-bg: #0c4a6e; --c-bowel: #fbbf24; --c-bowel-bg: #3b2500;
  }
  html:not([data-theme="light"]) .date-header { background: rgba(15,23,42,0.92); box-shadow: 0 1px 0 rgba(255,255,255,0.06); }
  html:not([data-theme="light"]) .tab-bar { background: rgba(15,23,42,0.92); border-top-color: rgba(255,255,255,0.07); }
  html:not([data-theme="light"]) .entry-card { background: #0f172a; }
  html:not([data-theme="light"]) .modal-btn.cancel { background: #334155; color: var(--text-muted); }
  html:not([data-theme="light"]) .data-btn--import { background: var(--bg); color: var(--text); border-color: var(--border); }
}

html[data-theme="dark"] {
  --bg: #0f172a; --surface: #1e293b; --text: #f1f5f9; --text-muted: #94a3b8;
  --border: #334155; --primary: #818cf8; --primary-light: #1e1b4b; --danger: #f87171;
  --c-water: #60a5fa; --c-water-bg: #1e3a5f; --c-weight: #a78bfa; --c-weight-bg: #2e1065;
  --c-mood: #fbbf24; --c-mood-bg: #451a03; --c-food: #4ade80; --c-food-bg: #052e16;
  --c-med: #2dd4bf; --c-med-bg: #042f2e; --c-activity: #fb923c; --c-activity-bg: #431407;
  --c-sleep: #38bdf8; --c-sleep-bg: #0c4a6e; --c-bowel: #fbbf24; --c-bowel-bg: #3b2500;
}
html[data-theme="dark"] .date-header { background: rgba(15,23,42,0.92); box-shadow: 0 1px 0 rgba(255,255,255,0.06); }
html[data-theme="dark"] .tab-bar { background: rgba(15,23,42,0.92); border-top-color: rgba(255,255,255,0.07); }
html[data-theme="dark"] .entry-card { background: #0f172a; }
html[data-theme="dark"] .modal-btn.cancel { background: #334155; color: var(--text-muted); }
html[data-theme="dark"] .data-btn--import { background: var(--bg); color: var(--text); border-color: var(--border); }

/* ─── Toast ──────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: calc(var(--tab-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  max-width: min(320px, 90vw);
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}
.toast--visible  { opacity: 1; transform: translateY(0); }
.toast--success  { background: #10b981; }
.toast--error    { background: #ef4444; }
.toast--info     { background: var(--primary); }
.toast i         { font-size: 16px; flex-shrink: 0; }

/* ─── Timeline More Button ───────────────────────── */

.tl-more-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
  margin-left: auto;
}
.tl-more-btn:hover, .tl-more-btn:focus { opacity: 1; background: var(--bg); }
@media (pointer: fine) { .tl-card:not(:hover) .tl-more-btn { opacity: 0.15; } }

/* ─── Context Menu ───────────────────────────────── */

.ctx-menu {
  display: none;
  position: fixed;
  z-index: 9998;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  overflow: hidden;
  min-width: 150px;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.ctx-item:hover           { background: var(--bg); }
.ctx-item--danger         { color: var(--danger); }
.ctx-item + .ctx-item     { border-top: 1px solid var(--border); }

/* ─── Modal header action bar (iOS-style: Cancel | Title | Save) ── */
.modal-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.modal-hdr-title { flex: 1; font-size: 17px; font-weight: 700; }
.modal-hdr-cancel {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  border-radius: 50%;
}
.modal-hdr-cancel i { font-size: 20px; }
.modal-hdr-cancel:hover { color: var(--text); background: var(--border); }
.modal-hdr-save {
  font-size: 15px; font-weight: 700; flex-shrink: 0;
  color: var(--primary); background: none; border: none; cursor: pointer; padding: 4px 0;
}
.modal-hdr-save:hover { opacity: 0.75; }

/* ─── Sleep Presets ──────────────────────────────── */

.sleep-presets { display: flex; gap: 8px; margin-bottom: 14px; }
.sleep-preset-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.sleep-preset-chip i { font-size: 17px; flex-shrink: 0; }
.sleep-preset-chip:hover { border-color: var(--c-sleep); color: var(--c-sleep); background: var(--c-sleep-bg); }

/* sleep time row with centre arrow+duration */
.sleep-input-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 14px; }
.sleep-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-bottom: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sleep-arrow i { font-size: 16px; }
#sleepDurationPreview {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-sleep);
  white-space: nowrap;
  min-height: 14px;
}
