:root {
  --bg: #000000;
  --card: #161618;
  --card-border: #242428;
  --text: #f5f5f7;
  --muted: #8e8e93;
  --accent: #ea4815;
  --accent-bright: #ff6b35;
  --purple: #bf5af2;
  --green: #30d158;
  --blue: #0a84ff;
  --red: #ff453a;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 112px);
}

.wrap {
  max-width: 540px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* Lock Screen */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: radial-gradient(circle at 50% 15%, rgba(234, 72, 21, 0.16), transparent 55%), #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 24px);
}

.lock-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.lock-logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.8px;
  margin-bottom: 6px;
}

.lock-logo span {
  color: var(--accent-bright);
}

.lock-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

.pin-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.pin-dots.shake {
  animation: pinShake 0.35s ease;
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.pin-dot.filled {
  background: var(--text);
  border-color: var(--text);
  transform: scale(1.08);
}

.pin-error {
  min-height: 20px;
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
  margin-bottom: 16px;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 14px 20px;
  justify-content: center;
}

.pin-key {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(34, 34, 38, 0.8);
  color: #ffffff;
  font-size: 28px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, transform 0.1s ease;
}

.pin-key:active {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(0.94);
}

.pin-key.ghost {
  background: transparent;
  border-color: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

.pin-key.empty {
  visibility: hidden;
  pointer-events: none;
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  min-height: 52px;
  gap: 8px;
}

.home-header {
  min-width: 0;
}

.home-header h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 0 0 2px;
}

.home-header h1 span {
  color: var(--accent-bright);
}

.subtitle {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.glass-circle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(34, 34, 38, 0.78);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.glass-circle-btn:hover {
  background: rgba(48, 48, 54, 0.88);
}

.glass-circle-btn:active {
  transform: scale(0.93);
}

.glass-circle-btn svg {
  width: 19px;
  height: 19px;
  display: block;
}

.back-circle svg {
  width: 20px;
  height: 20px;
  margin-right: 2px;
}

.topbar-spacer {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.tg-title-pill {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(34, 34, 38, 0.78);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.tg-title-pill.is-centered {
  flex: 0 1 auto;
  margin: 0 auto;
  padding: 0 22px;
  max-width: calc(100% - 96px);
}

.tg-pill-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: -0.15px;
}

.tg-pill-title.single-line {
  font-size: 15px;
}

.tg-pill-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.15;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.nav-pill {
  display: flex;
  align-items: center;
  height: 40px;
  background: rgba(30, 30, 34, 0.78);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 3px;
  gap: 1px;
  flex-shrink: 0;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.today-btn {
  color: var(--accent-bright);
  padding: 6px 7px;
}

#datePicker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

@media (max-width: 400px) {
  .tg-title-pill { padding: 0 10px; }
  .tg-title-pill.is-centered { padding: 0 18px; }
  .tg-pill-title { font-size: 12.5px; }
  .tg-pill-title.single-line { font-size: 14.5px; }
  .nav-btn { padding: 6px 5px; font-size: 12px; }
  .nav-btn.today-btn { padding: 6px 4px; }
}

/* Week Strip */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 15px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.day-cell:hover {
  background: #161618;
}

.day-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}

.day-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.day-cell.is-today .day-name,
.day-cell.is-today .day-num {
  color: var(--accent);
}

.day-cell.is-selected {
  background: var(--accent);
}

.day-cell.is-selected .day-name {
  color: rgba(255, 255, 255, 0.85);
}

.day-cell.is-selected .day-num {
  color: #ffffff;
}

/* Views */
.view-section {
  display: none;
  animation: fadeIn 0.16s ease;
}

.view-section.active {
  display: block;
}

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

/* Section Headings */
.sec-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 22px 0 12px;
}

.sec-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
}

.sec-meta {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Top Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease;
}

.clickable {
  cursor: pointer;
  user-select: none;
}

.clickable:hover {
  border-color: #34343a;
  background: #1a1a1d;
}

.clickable:active {
  transform: scale(0.975);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 6px;
}

.chart-title-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.chev {
  color: #636366;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}

.chart-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
}

.chart-diff {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chart-diff.red { color: var(--red); }
.chart-diff.green { color: var(--green); }
.chart-diff.purple { color: var(--purple); }

.chart-svg-wrap {
  width: 100%;
  height: 48px;
  margin: 6px 0;
}

.chart-svg-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.chart-val-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Hero Detail Card */
.hero-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 16px 16px 14px;
  margin-bottom: 14px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.hero-val {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.1;
}

.hero-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 3px;
}

.hero-badge {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: #222226;
  color: var(--text);
  white-space: nowrap;
}

.hero-badge.red { color: var(--red); background: rgba(255, 69, 58, 0.14); }
.hero-badge.green { color: var(--green); background: rgba(48, 209, 88, 0.14); }
.hero-badge.purple { color: var(--purple); background: rgba(191, 90, 242, 0.15); }
.hero-badge.orange { color: var(--accent-bright); background: rgba(255, 107, 53, 0.15); }

.hero-chart-wrap {
  width: 100%;
  height: 82px;
  margin: 8px 0 4px;
}

.hero-chart-wrap.has-stats {
  margin-bottom: 12px;
}

.hero-chart-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #242428;
}

.hero-stats.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.stat-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.tdee-card {
  background: linear-gradient(135deg, rgba(191, 90, 242, 0.12), rgba(22, 22, 24, 0.95));
  border: 1px solid rgba(191, 90, 242, 0.28);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.tdee-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tdee-title {
  font-size: 13px;
  font-weight: 700;
  color: #e4b5ff;
  letter-spacing: 0.2px;
}

.tdee-val {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  margin-top: 2px;
}

.tdee-desc {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 6px;
  line-height: 1.4;
}

.trend-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Segmented Control */
.seg-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #1c1c1e;
  border: 1px solid #2c2c2e;
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 14px;
}

.seg-control.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.seg-btn.active {
  background: #3a3a3f;
  color: #ffffff;
}

/* Metric Analytics */
.metric-chart-wrap {
  width: 100%;
  height: 154px;
  margin: 6px 0 2px;
}

.metric-chart-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.goal-pill-bar {
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
}

.goal-pill-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.goal-pill-target {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.82;
}

/* Reports Insights (FoodNoms-style vs Goal) */
.insights-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.insight-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 128px;
}

.insight-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.insight-big {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 8px 0 2px;
  line-height: 1.1;
}

.insight-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.insight-mini-dots {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.insight-mini-dot {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #28282e;
}

.insight-mini-dot.on { background: var(--accent-bright); }
.insight-mini-dot.weigh { background: var(--green); }

.macro-split-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.macro-split-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.macro-legend-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.macro-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 700;
}

.macro-legend-pct {
  font-size: 12px;
  font-weight: 700;
}

.macro-legend-goal {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.macro-stack-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 120px;
}

.macro-stack-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 3px;
}

.macro-stack-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #242429;
  gap: 2px;
}

.macro-seg {
  height: 100%;
  transition: width 0.25s ease;
}

.nutrients-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.nutrient-insight-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 13px 13px 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease;
}

.nutrient-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.nutrient-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

.nutrient-avg-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.nutrient-avg {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.nutrient-goal-ref {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.nutrient-diff-line {
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 2px;
  margin-bottom: 6px;
}

.mini-goal-chart-wrap {
  width: 100%;
  height: 54px;
  margin: 4px 0 6px;
}

.mini-goal-chart-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.nutrient-foot {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-ref-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #242428;
  overflow: visible;
}

.day-ref-fill {
  height: 100%;
  border-radius: 999px;
  max-width: 100%;
  transition: width 0.28s ease;
}

.day-ref-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
}
.day-block {
  margin-bottom: 16px;
}

.day-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 2px 8px;
}

.day-block-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.day-block-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.breakdown-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  overflow: hidden;
}

.breakdown-row {
  padding: 13px 16px;
  border-bottom: 1px solid #242428;
}

.breakdown-row:last-child { border-bottom: none; }

.breakdown-meal {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.breakdown-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.breakdown-bar {
  height: 7px;
  border-radius: 999px;
  min-width: 8px;
  transition: width 0.28s ease;
}

.breakdown-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #242428;
  overflow: hidden;
}

.breakdown-val {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* Goals 2-col Ring Grid */
.goals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.goal-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease;
}

.goal-info { min-width: 0; }

.goal-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}

.goal-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.goal-status {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.goal-sub {
  font-size: 11px;
  color: #636366;
  margin-top: 2px;
}

/* Apple-style Gradient Progress Rings */
.ring-wrap {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  position: relative;
}

.ring-track {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px solid #2c2c2e;
}

.ring-mask {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  -webkit-mask-image: radial-gradient(circle, transparent 16.4px, #000 17.1px, #000 22.5px, transparent 23.1px);
  mask-image: radial-gradient(circle, transparent 16.4px, #000 17.1px, #000 22.5px, transparent 23.1px);
}

.ring-rot { position: absolute; inset: 0; }

.ring-conic {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.ring-cap {
  position: absolute;
  top: 0;
  left: 20px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.ring-cap-shadow {
  position: absolute;
  top: 0;
  left: 20px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: 3.5px 0 4.5px 1px rgba(0, 0, 0, 0.88), 1.5px 0 2px rgba(0, 0, 0, 0.65);
  z-index: 2;
}

.ring-cap-tip {
  position: absolute;
  top: 0;
  left: 18px;
  width: 8px;
  height: 6px;
  border-radius: 0 3px 3px 0;
  z-index: 3;
}

/* 30-Day Streak Grid */
.streak-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.streak-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.streak-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.streak-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
  margin-bottom: 10px;
}

.streak-dots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  margin-bottom: 10px;
}

.dot-box {
  aspect-ratio: 1;
  border-radius: 3px;
  background: #242428;
}

.dot-box.active-green { background: var(--green); }
.dot-box.active-blue { background: var(--blue); }

.streak-footer {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Meals & Weight Lists */
.meal-group { margin-top: 20px; }

.meal-group-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 10px;
}

.meal-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.meal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 3px;
}

.meal-item {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.meal-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.meal-details {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.macro-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
}

.m-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #e5e5ea;
}

.dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #000;
}

.list-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  overflow: hidden;
}

.weight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid #242428;
}

.weight-row:last-child { border-bottom: none; }

.weight-date { font-size: 15px; font-weight: 600; color: var(--text); }
.weight-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.weight-right { display: flex; align-items: center; gap: 10px; }

.weight-delta {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: #222226;
  color: var(--muted);
}

.weight-delta.down { color: var(--green); background: rgba(48, 209, 88, 0.14); }
.weight-delta.up { color: var(--red); background: rgba(255, 69, 58, 0.14); }

.weight-val {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  min-width: 68px;
  text-align: right;
}

.empty-box {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Settings Form */
.settings-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
}

.settings-card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.field input {
  background: #0d0d10;
  border: 1px solid #2c2c32;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  width: 100%;
}

.field input:focus {
  border-color: var(--accent-bright);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #242428;
  gap: 12px;
}

.toggle-row:last-of-type { border-bottom: none; }

.toggle-label { font-size: 14px; font-weight: 600; }
.toggle-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #333338;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background: var(--green);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

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

.btn-secondary {
  width: 100%;
  background: #24242a;
  color: var(--text);
  border: 1px solid #32323a;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.btn-danger {
  width: 100%;
  background: rgba(255, 69, 58, 0.14);
  color: var(--red);
  border: 1px solid rgba(255, 69, 58, 0.25);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.hint-box {
  background: rgba(10, 132, 255, 0.1);
  border: 1px solid rgba(10, 132, 255, 0.25);
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 12.5px;
  color: #c7e2ff;
  line-height: 1.45;
  margin-top: 10px;
}

/* Floating Bottom Dock (Nav Pill + Detached Chat Button) */
.tabbar-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
  padding: 0 12px;
}

.bottom-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 440px;
}

.tabbar {
  pointer-events: auto;
  flex: 1;
  height: 60px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  gap: 3px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(30, 30, 34, 0.74);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 4px 6px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #e5e5ea;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.tab-btn:active { transform: scale(0.95); }
.tab-btn svg { width: 19px; height: 19px; display: block; }
.tab-btn span { font-size: 10.5px; font-weight: 600; letter-spacing: -0.1px; }

.tab-btn.active {
  background: rgba(255, 255, 255, 0.13);
  color: var(--accent-bright);
}

.chat-fab {
  pointer-events: auto;
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid rgba(255, 107, 53, 0.48);
  background: linear-gradient(155deg, rgba(234, 72, 21, 0.42), rgba(34, 34, 38, 0.88));
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65), 0 0 18px rgba(234, 72, 21, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.14s ease, background 0.18s ease;
}

.chat-fab:active {
  transform: scale(0.94);
}

.chat-fab svg {
  width: 21px;
  height: 21px;
  display: block;
}

.chat-fab span {
  font-size: 10.5px;
  font-weight: 700;
}

.chat-badge {
  position: absolute;
  top: 7px;
  right: 11px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 8px var(--accent-bright);
}

/* Native Popup Chat (Bottom Sheet, non-fullscreen) */
.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.56);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 8px calc(env(safe-area-inset-bottom) + 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.chat-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.chat-sheet {
  width: 100%;
  max-width: 520px;
  height: min(80dvh, 700px);
  background: rgba(20, 20, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  box-shadow: 0 -10px 45px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(30px);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-backdrop.open .chat-sheet {
  transform: translateY(0);
}

.chat-handle-bar {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  margin: 9px auto 2px;
  flex-shrink: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

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

.chat-title {
  font-size: 16px;
  font-weight: 700;
}

.chat-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.chat-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-chips {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.chat-chip {
  background: #232329;
  border: 1px solid #32323a;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chat-chip:active {
  transform: scale(0.96);
}

.fav-drawer {
  background: #141418;
  border-bottom: 1px solid #2b2b33;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 14px;
  flex-shrink: 0;
}

.fav-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: #1d1d22;
  margin-bottom: 6px;
  cursor: pointer;
  gap: 8px;
}

.fav-item-row:last-child { margin-bottom: 0; }
.fav-item-name { font-size: 13.5px; font-weight: 600; }
.fav-item-meta { font-size: 11.5px; color: var(--muted); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.msg-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 10px 13px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.user .msg-bubble {
  background: linear-gradient(145deg, #ea4815, #cf3c0f);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.msg-row.assistant .msg-bubble {
  background: #1f1f25;
  border: 1px solid #2d2d35;
  color: var(--text);
  border-bottom-left-radius: 5px;
}

.msg-img {
  max-width: 210px;
  max-height: 190px;
  border-radius: 14px;
  object-fit: cover;
  margin-bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.msg-time {
  font-size: 10.5px;
  color: #6e6e73;
  margin-top: 3px;
  padding: 0 4px;
}

.confirm-card {
  margin-top: 8px;
  background: #141418;
  border: 1px solid #303038;
  border-radius: 16px;
  padding: 11px 12px;
  width: 100%;
  min-width: 230px;
}

.confirm-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 3px;
}

.confirm-details {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.35;
}

.confirm-macros {
  font-size: 12.5px;
  font-weight: 600;
  color: #e5e5ea;
  margin-bottom: 10px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-confirm {
  background: #248a3d;
  color: #ffffff;
  border: none;
  border-radius: 11px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-cancel {
  background: #2c2c32;
  color: #f5f5f7;
  border: none;
  border-radius: 11px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.confirm-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.chat-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 0;
  flex-shrink: 0;
}

.preview-thumb-wrap {
  position: relative;
  display: inline-block;
}

.preview-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #000000;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(24, 24, 29, 0.96);
  flex-shrink: 0;
}

.attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #27272e;
  border: 1px solid #35353e;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: #101014;
  border: 1px solid #2e2e36;
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.35;
  max-height: 110px;
  resize: none;
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent-bright);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(34, 34, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
