/* ===========================
   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: 92px;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
}

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;
  /* Push content below fixed header and above fixed footer */
  padding-top: var(--header-height);
  padding-bottom: calc(var(--tab-height) + 72px); /* extra room for FAB */
}

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 48px;
  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  (sleek, frosted)
   =========================== */
.date-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,0.07);
}

/* ─── Nav row ─── */
.date-nav-row {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 4px;
}

.date-nav {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}

.date-nav:active {
  background: var(--primary-light);
  color: var(--primary);
}

@media (hover: hover) {
  .date-nav:hover {
    background: var(--primary-light);
    color: var(--primary);
  }
}

/* ─── Center date ─── */
.date-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
  cursor: pointer;
  padding: 4px 14px;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}

.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;
}

/* ===========================
   Week Strip
   =========================== */
.week-strip {
  display: flex;
  padding: 0 4px 4px;
}

.week-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 0 4px;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}

.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: 12px;
  font-weight: 700;
  color: var(--text);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-day.active .wd-num {
  background: var(--primary);
  color: #fff;
}

.week-day.active .wd-label { color: var(--primary); }

.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;
}

.subsection-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 16px 0 8px;
}

/* ===========================
   Tab Bar  (sleek, frosted)
   =========================== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-height);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(0,0,0,0.07);
  display: flex;
  z-index: 100;
}

.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;
}

/* ===========================
   FAB Speed Dial
   =========================== */
.fab-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  z-index: 150;
  animation: fadeIn 0.15s ease;
}

.fab-backdrop.open { display: block; }

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

.fab-container {
  position: fixed;
  bottom: calc(var(--tab-height) + 16px);
  right: 20px;
  z-index: 160;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.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);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.fab-main:active { transform: scale(0.93); }

.fab-container.open .fab-main { transform: rotate(45deg); }

.fab-plus-icon {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  display: block;
  transition: inherit;
}

.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  padding-bottom: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform-origin: bottom right;
}

.fab-container.open .fab-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.fab-label {
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.fab-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  flex-shrink: 0;
  transition: transform 0.1s;
}

.fab-item:active .fab-icon-btn { transform: scale(0.9); }

/* ===========================
   Dashboard — Summary Grid
   =========================== */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.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;
}

/* ===========================
   Quick Add Row
   =========================== */
.quick-add-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-btn {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

.quick-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ===========================
   Glance List (Dashboard)
   =========================== */
.glance-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.glance-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  box-shadow: var(--shadow);
}

.glance-item strong { color: var(--text); }

/* ===========================
   Add Button
   =========================== */
.add-btn {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  transition: opacity 0.15s;
  display: inline-block;
}

.add-btn:hover { opacity: 0.88; }

.add-btn.full-width {
  display: block;
  width: 100%;
  text-align: center;
}

/* ===========================
   Entry List
   =========================== */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 6px;
  padding: 0 4px;
}

.entry-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow);
}

.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);
}

.delete-btn {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-btn:hover {
  color: var(--danger);
  background: #fef2f2;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 28px 0;
}

/* ===========================
   Mood Tab
   =========================== */
.mood-picker-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 4px;
}

.mood-prompt {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
}

.emoji-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.emoji-btn {
  font-size: 30px;
  line-height: 1;
  padding: 6px;
  border-radius: 12px;
  transition: transform 0.1s, background 0.15s;
  background: transparent;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-btn:hover {
  transform: scale(1.15);
  background: var(--primary-light);
}

.emoji-btn.selected {
  background: var(--primary-light);
  outline: 2px solid var(--primary);
  transform: scale(1.1);
}

.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;
}

.mood-note:focus {
  outline: none;
  border-color: var(--primary);
}

.mood-emoji-display {
  font-size: 22px;
  margin-right: 6px;
}

/* ===========================
   Water Tab
   =========================== */
.water-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  text-align: center;
}

.water-counter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 10px;
}

.water-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 26px;
  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:hover {
  background: #fee2e2;
  color: var(--danger);
}

.water-btn.plus {
  background: var(--primary);
  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: 48px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.water-unit {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.water-ml {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.progress-bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  border-radius: 999px;
  transition: width 0.3s ease;
  max-width: 100%;
}

.water-goal-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Water glass visual */
.water-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.glass-icon {
  font-size: 24px;
  line-height: 1;
  opacity: 0.3;
  transition: opacity 0.2s;
}

.glass-icon.filled { opacity: 1; }

/* ===========================
   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;
}

.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;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.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; }

/* ===========================
   Quantity Row (Food Modal)
   =========================== */
.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) {
  background: var(--primary-light);
  color: var(--primary);
}

.cal-nav:disabled {
  opacity: 0.2;
  cursor: default;
}

@media (hover: hover) {
  .cal-nav:hover:not(:disabled) {
    background: var(--primary-light);
    color: var(--primary);
  }
}

.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) { background: var(--primary-light); }

@media (hover: hover) {
  .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;
}

/* ===========================
   Desktop adjustments
   =========================== */
@media (min-width: 600px) {
  .main-content { padding: 20px 24px; }

  .modal {
    border-radius: var(--radius);
    margin-bottom: 80px;
    max-width: 420px;
  }

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

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