:root {
  --bg: #0f1117;
  --bg-elevated: #171a24;
  --card: #1b1e29;
  --border: #2a2e3d;
  --text: #e8e9f3;
  --muted: #8a8fa3;
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --success: #00d68f;
  --danger: #ff5c7a;
  --radius: 18px;
  --radius-sm: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0 0 4px; font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 6vw, 2.4rem); }
h2 { font-size: 1.15rem; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero {
  background: radial-gradient(circle at 30% 20%, #3d2fb8 0%, #17123d 45%, var(--bg) 100%);
  padding: 40px 16px 46px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: 640px; margin: 0 auto; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: #b8a9ff;
  margin-bottom: 6px;
  font-weight: 700;
}

/* ---------- Countdown ---------- */
.countdown {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 8px;
  flex-wrap: wrap;
}
.countdown-unit {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-width: 64px;
  backdrop-filter: blur(6px);
}
.countdown-unit span {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.countdown-unit label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.countdown-caption { margin-top: 6px; font-size: 0.9rem; }

/* ---------- Toast ---------- */
.toast {
  background: rgba(0,214,143,0.12);
  border: 1px solid rgba(0,214,143,0.4);
  color: var(--success);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-align: center;
}

/* ---------- Motivation ---------- */
.motivation-box {
  background: linear-gradient(135deg, rgba(108,92,231,0.18), rgba(108,92,231,0.05));
  border: 1px solid rgba(108,92,231,0.35);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.motivation-icon { font-size: 1.4rem; }
.motivation-text { flex: 1; min-width: 200px; font-size: 0.98rem; line-height: 1.45; }
.motivation-text.pulse { animation: pulse 0.5s ease; }
@keyframes pulse { 0% { opacity: 0.2; transform: translateY(4px); } 100% { opacity: 1; transform: translateY(0); } }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 620px) {
  .cards { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.person-card { position: relative; border-top: 3px solid var(--accent, var(--primary)); }
.crown {
  position: absolute;
  top: -12px;
  right: 14px;
  background: linear-gradient(135deg, #ffd76b, #ff9f43);
  color: #3a2400;
  font-weight: 800;
  font-size: 0.7rem;
  padding: 5px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255,159,67,0.4);
}

.person-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-row { display: flex; justify-content: space-between; margin-bottom: 12px; }
.stat { text-align: center; flex: 1; }
.stat-value { display: block; font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.stat-value.accent { color: var(--accent, var(--success)); }
.stat-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.progressbar {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progressbar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 1.1s cubic-bezier(.22,1,.36,1);
}

.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  background: rgba(108,92,231,0.15);
  border: 1px solid rgba(108,92,231,0.4);
  color: #cdc4ff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
}

/* ---------- Chart ---------- */
.chart-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.chart-toggle { display: flex; gap: 6px; background: rgba(255,255,255,0.05); padding: 4px; border-radius: 999px; }
.chip {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.active { background: var(--primary); color: white; }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input, .field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }

.person-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.person-option {
  flex: 1;
  min-width: 120px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
}
.person-option input { display: none; }
.person-option:has(input:checked) { border-color: var(--primary); background: rgba(108,92,231,0.15); }

.checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.checkbox-field input { width: 18px; height: 18px; }

.more-details { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.more-details summary { cursor: pointer; font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.more-details[open] summary { margin-bottom: 12px; }

.settings-card summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.settings-card[open] summary { border-radius: var(--radius) var(--radius) 0 0; border-bottom: none; }
.settings-card form { border-radius: 0 0 var(--radius) var(--radius); border-top: none; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 8px 20px rgba(108,92,231,0.35); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-small { padding: 8px 14px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.6; cursor: default; }

.logout-link, .back-link {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 4px;
}
.login-cta { text-decoration: none; display: block; text-align: center; }

.site-footer { text-align: center; padding: 24px 16px 40px; color: var(--muted); font-size: 0.8rem; }

/* ---------- Auth page ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #3d2fb8 0%, #17123d 45%, var(--bg) 100%);
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 26px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.auth-logo { font-size: 2.2rem; margin-bottom: 6px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card p { margin-bottom: 20px; }
.auth-card form { text-align: left; }
.alert {
  background: rgba(255,92,122,0.12);
  border: 1px solid rgba(255,92,122,0.4);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ---------- Animations ---------- */
.fade-in-up {
  animation: fadeInUp 0.6s cubic-bezier(.22,1,.36,1) both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cute background blobs (polar bear blue / panda pink) ---------- */
body { position: relative; overflow-x: hidden; }
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.25;
  z-index: -1;
  pointer-events: none;
}
.blob-blue { width: 340px; height: 340px; background: #4FD1E8; top: -80px; left: -100px; }
.blob-pink { width: 300px; height: 300px; background: #FF6FA5; bottom: 10%; right: -90px; }

/* ---------- Feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.feed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
}
.feed-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.feed-body { flex: 1; min-width: 0; }
.feed-body p { margin: 0; font-size: 0.9rem; line-height: 1.3; }
.feed-body p + p { margin-top: 1px; }
.feed-delta { font-weight: 800; margin-left: 4px; }
.feed-delta.good { color: var(--success); }
.feed-delta.bad { color: var(--danger); }
.feed-delta.neutral { color: var(--muted); font-weight: 600; }
.food-item { align-items: flex-start; }
.food-item .feed-avatar { margin-top: 2px; }

.feed-actions { flex-shrink: 0; }
.feed-actions summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
}
.feed-actions summary::-webkit-details-marker { display: none; }
.feed-actions[open] summary { background: rgba(255,255,255,0.08); }
.feed-actions-panel {
  position: absolute;
  right: 16px;
  margin-top: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.stack-tight { display: flex; flex-direction: column; gap: 6px; }
.feed-edit-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
  width: 100%;
}

.btn-tiny { padding: 6px 10px; font-size: 0.78rem; }
.btn-danger { background: rgba(255,92,122,0.15); color: var(--danger); border: 1px solid rgba(255,92,122,0.4); }

.settings-panel { border-radius: 0 0 var(--radius) var(--radius); border-top: none; }

/* ---------- Food page additions ---------- */
.hero-compact { padding: 28px 16px 30px; }
.nav-pill {
  display: inline-block;
  margin-top: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.fasting-pill {
  margin-left: auto;
  background: rgba(108,92,231,0.18);
  border-color: rgba(108,92,231,0.4);
  color: #cdc4ff;
  font-weight: 700;
}
.person-head { position: relative; }

.goal-projection {
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.food-thumbs { display: flex; gap: 4px; margin-top: 4px; }
.food-thumbs img {
  width: 40px !important; height: 40px !important;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.food-thumbs a:active img { transform: scale(0.94); }
.food-item .feed-body p strong { word-break: break-word; }

/* ---------- Lightbox ---------- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.lightbox-overlay.open { opacity: 1; pointer-events: auto; }
.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- Deficit summary ---------- */
.deficit-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (min-width: 480px) {
  .deficit-summary { grid-template-columns: repeat(2, 1fr); }
}
.deficit-summary-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.deficit-summary-item .stat-value { display: block; }

.motivation-box-compact {
  padding: 12px 16px;
  font-size: 0.9rem;
}
.motivation-box-compact .motivation-icon { font-size: 1.1rem; }

/* ---------- Day-fill choice group ---------- */
.day-choice-group { display: flex; flex-direction: column; gap: 8px; }
.day-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  cursor: pointer;
}
.day-choice:has(input:checked) { border-color: var(--primary); background: rgba(108,92,231,0.12); }
.day-choice input { width: 16px; height: 16px; flex-shrink: 0; }

textarea.field-textarea,
.field textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

/* ---------- Person filter chips ---------- */
.person-filter { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.person-filter .chip {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
}
.person-filter .chip.active { background: var(--primary); border-color: var(--primary); }

/* ---------- Mini divider inside dashboard cards ---------- */
.mini-divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- Nicer photo thumbnail button (with a tap hint badge) ---------- */
.food-thumb { position: relative; display: inline-block; border-radius: 8px; overflow: visible; }
.food-thumb::after {
  content: '🔍';
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--primary);
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ---------- Quick nav (sticky section jump bar) ---------- */
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 64px; }
.quick-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  margin: 18px -16px 0;
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(15,17,23,0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-nav::-webkit-scrollbar { display: none; }
.quick-nav a {
  flex-shrink: 0;
  text-decoration: none;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.quick-nav a:active { background: var(--primary); color: white; border-color: var(--primary); }
.quick-nav-static { position: static; margin-top: 16px; }

/* ---------- Macro bars ---------- */
.macro-bars { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.macro-bar-row { display: flex; align-items: center; gap: 8px; }
.macro-label { width: 14px; font-size: 0.7rem; font-weight: 800; color: var(--muted); flex-shrink: 0; }
.macro-bar-track { flex: 1; height: 6px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
.macro-bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.macro-protein { background: #6C5CE7; }
.macro-carbs { background: #4FD1E8; }
.macro-fat { background: #FF9F43; }
.macro-value { font-size: 0.7rem; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
