/* ================= HOME ================= */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.home-greeting { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.home-date { font-size: 13px; color: var(--ink-faint); font-weight: 600; margin-top: var(--space-1); }

.calendar-strip {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1) var(--space-1) var(--space-3);
  margin-bottom: var(--space-5);
}
.cal-day {
  flex: 0 0 auto;
  width: 46px;
  height: 62px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  color: var(--ink-soft);
}
.cal-day .dow { font-size: 10px; font-weight: 700; text-transform: uppercase; opacity: 0.7; }
.cal-day .dom { font-size: 15px; font-weight: 700; }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); }
.cal-day.today { border-color: var(--ink); }
.cal-day.selected { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.cal-day.selected .dot { background: var(--accent-contrast); }
.cal-day.over .dot { background: var(--danger); }
.cal-day.selected.over .dot { background: #ff9d94; }
.cal-day.under .dot { background: var(--good); }
.cal-day.selected.under .dot { background: #8fe0a8; }
.cal-day.future { opacity: 0.35; }

.ring-card {
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
.ring-wrap { position: relative; width: 108px; height: 108px; flex: 0 0 auto; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-center .num { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.ring-center .label { font-size: 10px; color: var(--ink-faint); font-weight: 700; text-transform: uppercase; margin-top: var(--space-1); }

.ring-stats { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }
.ring-stat-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.ring-stat-row .stat-label { color: var(--ink-soft); font-weight: 600; }
.ring-stat-row .stat-val { font-weight: 700; }

.macro-row {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.macro-card {
  flex: 1;
  padding: var(--space-3);
  text-align: left;
}
.macro-card .macro-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--ink-faint); letter-spacing: 0.03em; }
.macro-card .macro-val { font-size: 17px; font-weight: 800; margin-top: var(--space-1); }
.macro-card .macro-of { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.macro-bar { height: 5px; border-radius: 3px; background: var(--bg-sunken); margin-top: var(--space-2); overflow: hidden; }
.macro-bar-fill { height: 100%; border-radius: 3px; background: var(--ink); }

.log-list { display: flex; flex-direction: column; gap: var(--space-2); }
.log-item {
  padding: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.log-thumb {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--bg-sunken);
  flex: 0 0 auto;
}
.log-thumb-fallback {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint);
}
.log-info { flex: 1; min-width: 0; }
.log-desc { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-meta { font-size: 12px; color: var(--ink-faint); margin-top: var(--space-1); font-weight: 600; }
.log-cals { font-size: 15px; font-weight: 800; flex: 0 0 auto; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-faint);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 10px; stroke: var(--ink-faint); }
.empty-state .title { font-weight: 700; color: var(--ink-soft); font-size: 15px; }
.empty-state .sub { font-size: 13px; margin-top: 4px; }

/* Floating add button */
.fab-row {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  z-index: 40;
  pointer-events: none;
}
.fab-inner {
  max-width: 560px;
  width: 100%;
  padding: 0 18px;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.fab {
  pointer-events: auto;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.3; }
.fab:active { transform: scale(0.94); }

/* ================= LOG SHEET (modal) ================= */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,15,0.45);
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(24px + var(--safe-bottom));
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.sheet-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: var(--space-2) auto var(--space-4);
}
.sheet-title { font-size: 18px; font-weight: 800; margin-bottom: var(--space-4); }

.avatar-swatch {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 1px 2px rgba(20,20,15,0.12);
}
.avatar-swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
}
.avatar-emoji-opt {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-sunken);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
}
.avatar-emoji-opt.selected {
  border-color: var(--ink);
  background: var(--bg-elevated);
}

/* ================= FRIENDS ================= */
.friends-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.friends-header .onb-title { font-size: 22px; }

.friend-card { padding: var(--space-4); }
.friend-card-name { font-weight: 700; font-size: 15px; }
.friend-card-status { font-size: 11px; font-weight: 700; }
.friend-card-status.logged { color: var(--good); }
.friend-card-status.not-logged { color: var(--ink-faint); }
.friend-card-streak { font-size: 11px; font-weight: 700; color: var(--streak); }
.friend-card-streak svg { width: 12px; height: 12px; stroke: var(--streak); vertical-align: -2px; }
.friend-card-body { flex: 1; min-width: 0; }

.leaderboard-rank {
  font-size: 14px;
  font-weight: 800;
  width: 22px;
  flex: none;
  text-align: center;
}
.leaderboard-row.is-you {
  background: var(--bg-sunken);
}
.leaderboard-streak { color: var(--streak); }

.friend-request-row-actions .btn-icon-good { flex: none; }

.capture-options {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.capture-btn {
  flex: 1;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.capture-btn svg { width: 26px; height: 26px; stroke: var(--ink); }
.capture-btn:active { background: var(--bg-sunken); }

.photo-preview {
  width: 100%;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  max-height: 220px;
  object-fit: cover;
}

.analyzing-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--line-soft);
  margin-bottom: var(--space-4);
}
.analyzing-box .msg { font-size: 14px; font-weight: 600; color: var(--ink-soft); }

.favorite-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  width: 100%;
}
.favorite-row svg { width: 18px; height: 18px; stroke: var(--ink-faint); flex: none; }
.favorite-info { min-width: 0; }
.favorite-desc { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.favorite-meta { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; margin-top: 2px; }

/* ================= STATS ================= */
.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.stats-header .onb-title { font-size: 20px; }
.stats-range-toggle { margin-bottom: var(--space-5); }
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.stats-card { padding: var(--space-4); }
.stats-card-val { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.stats-card-label { font-size: 12px; color: var(--ink-faint); font-weight: 600; margin-top: var(--space-1); }

.stats-chart-card { padding: var(--space-4); }
.stats-chart-title { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: var(--space-4); }
.stats-chart-svg { width: 100%; }
.stats-legend { font-size: 11px; margin-top: var(--space-2); }
.stats-legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.stats-legend-dot.good { background: var(--good); }
.stats-legend-dot.danger { background: var(--danger); }
.stats-legend-dot.none { background: var(--line); }

.standout-val.good { color: var(--good); }
.standout-val.faint { color: var(--ink-faint); }

/* ================= WHAT'S NEW ================= */
.whatsnew-header { text-align: center; margin-bottom: var(--space-1); }
.whatsnew-mark { width: 52px; height: 52px; border-radius: var(--radius-md); font-size: 22px; margin: 0 auto var(--space-3); }
.whatsnew-title { font-size: 20px; }
.whatsnew-older-list { display: none; }
.whatsnew-older-list.visible { display: block; }
.whatsnew-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.4;
}
.whatsnew-item svg { width: 16px; height: 16px; stroke: var(--good); flex: none; margin-top: 3px; }
.whatsnew-older-entry {
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
}
.whatsnew-older-version { font-size: 13px; font-weight: 800; color: var(--ink-faint); }

.result-card {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.result-desc { font-size: 16px; font-weight: 700; margin-bottom: var(--space-3); }
.result-macros { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.result-macro { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.result-macro b { color: var(--ink); font-weight: 800; }
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
  margin-top: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ================= AUTH ================= */
.auth-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
  padding-top: 0;
}
.auth-header {
  text-align: center;
  margin-bottom: var(--space-7);
}
.auth-mark {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--space-4);
  font-size: 26px;
  font-weight: 800;
}
.auth-title { font-size: 24px; }

/* ================= ONBOARDING ================= */
.onb-progress {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-7);
}
.onb-progress .seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
.onb-progress .seg.done { background: var(--ink); }

.onb-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.onb-sub { font-size: 15px; color: var(--ink-soft); margin-top: 8px; line-height: 1.4; }

/* Selectable option cards used throughout onboarding (goal type, activity, pace). */
.option-card {
  padding: var(--space-4);
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
}
.option-card.selected { border-color: var(--ink); background: var(--bg-elevated); }
.option-card-row { display: flex; align-items: center; justify-content: space-between; font-size: 16px; }
.option-card-title { font-size: 15px; font-weight: 700; }
.option-card-sub { font-size: 13px; color: var(--ink-faint); font-weight: 500; margin-top: var(--space-1); }

.onb-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 18px calc(18px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex;
  gap: 10px;
}

.summary-card { padding: var(--space-5); }
.summary-card-headline { font-size: 15px; font-weight: 700; }
.summary-card-value { font-size: 22px; font-weight: 800; }
.summary-card-sub { font-size: 13px; }

/* ================= COACH ================= */
.coach-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}
.coach-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 16px;
}
.coach-title { font-size: 17px; font-weight: 800; }
.coach-status { font-size: 12px; color: var(--good); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.coach-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); }

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 90px;
}
.chat-bubble {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.45;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-contrast);
  border-bottom-right-radius: 5px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 5px;
}
.chat-bubble b, .chat-bubble strong { font-weight: 800; }

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
}
.chip {
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.chat-input-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 0; right: 0;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 14px;
  background: rgba(244, 243, 241, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  z-index: 45;
}
.chat-input-bar textarea {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 15px;
  resize: none;
  max-height: 100px;
  color: var(--ink);
}
.chat-input-bar textarea:focus { outline: none; border-color: var(--ink); }
.chat-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.chat-send:disabled { opacity: 0.35; }
.chat-send svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 2.3; }

.typing-dots { display: flex; gap: 4px; padding: 4px 2px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-faint);
  animation: typingBounce 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ================= SETTINGS ================= */
.settings-profile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-1) var(--space-6);
}
.avatar-edit-btn { border-radius: 50%; position: relative; flex: none; }
.avatar-preview-row { display: flex; justify-content: center; margin-bottom: var(--space-5); }
.settings-field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
}
.settings-name { font-size: 18px; font-weight: 800; }
.settings-sub { font-size: 13px; color: var(--ink-faint); margin-top: var(--space-1); }

.settings-group {
  margin-bottom: var(--space-6);
}
.settings-list {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: var(--bg-elevated);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1 1 auto;
}
.settings-row .left span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-row .row { gap: var(--space-2); flex: 0 0 auto; }
.settings-row svg { width: 19px; height: 19px; stroke: var(--ink-soft); stroke-width: 1.8; flex: none; }
.settings-row .chev { width: 16px; height: 16px; margin-left: var(--space-1); stroke: var(--ink-faint); flex: none; }
.settings-row .val {
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  flex: 0 1 auto;
}
.settings-row.danger { color: var(--danger); }
.settings-row.danger svg { stroke: var(--danger); }
.settings-row-note {
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 500;
  line-height: 1.4;
  padding: 0 var(--space-4) var(--space-3);
}

.toggle {
  width: 46px; height: 27px;
  border-radius: 14px;
  background: var(--line);
  position: relative;
  transition: background 0.15s ease;
  flex: 0 0 auto;
}
.toggle.on { background: var(--accent); }
.toggle .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 23px; height: 23px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.15s ease;
}
.toggle.on .knob { transform: translateX(19px); }

.settings-time-input {
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-faint);
  text-align: right;
  flex: 0 0 auto;
  padding: 0;
}

.weight-chart-card {
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}
.weight-value { font-size: 22px; font-weight: 800; margin-top: var(--space-1); }
.weight-sparkline { width: 100%; height: 50px; margin-top: var(--space-4); }
