/* ─────────────────────────────────────────
   BASE
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: #fff;
  min-height: 100vh;
  overscroll-behavior-y: none;
}


/* ─────────────────────────────────────────
   LAYOUT
───────────────────────────────────────── */
.app {
  background: #fff;
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
}

.screen {
  display: none;
  padding: 5px 24px 100px;
  animation: fadeUp 0.22s ease;
}

.screen.active { display: block; }


/* ─────────────────────────────────────────
   ANIMATIONS
───────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes chipIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideUpBar {
  from { transform: translateX(-50%) translateY(100%); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* Metric card entrance */
.anim-card { animation: popUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.anim-d1   { animation-delay: 0.06s; }
.anim-d2   { animation-delay: 0.14s; }
.anim-d3   { animation-delay: 0.22s; }
.anim-d4   { animation-delay: 0.30s; }

/* Form field stagger */
.form-body > .field-group:nth-child(1) { animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s both; }
.form-body > .field-group:nth-child(2) { animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.13s both; }
.form-body > .field-group:nth-child(3) { animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.21s both; }
.form-body > .field-group:nth-child(4) { animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.29s both; }
.form-body > .field-group:nth-child(5) { animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.37s both; }
.form-body > .macro-row              { animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.21s both; }

/* Learn list stagger */
.learn-topic-item:nth-child(1) { animation-delay: 0.05s; }
.learn-topic-item:nth-child(2) { animation-delay: 0.12s; }
.learn-topic-item:nth-child(3) { animation-delay: 0.19s; }
.learn-topic-item:nth-child(4) { animation-delay: 0.26s; }
.learn-topic-item:nth-child(5) { animation-delay: 0.33s; }
.learn-topic-item:nth-child(6) { animation-delay: 0.40s; }


/* ─────────────────────────────────────────
   LOGO
───────────────────────────────────────── */
.logo-img {
  display: block;
  height: 34px;
  width: auto;
  margin: 0 auto 20px;
}

a:has(.logo-img) {
  display: block;
  width: fit-content;
  margin: 0 auto 20px;
}

a:has(.logo-img) .logo-img { margin: 0; }


/* ─────────────────────────────────────────
   TYPOGRAPHY
───────────────────────────────────────── */
.section-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #aaa;
  margin-bottom: 6px;
}

.intro-block { margin-bottom: 32px; }

.intro-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1.1;
  margin-bottom: 10px;
}

.intro-desc {
  font-size: 0.82rem;
  color: #888;
  line-height: 1.6;
}

.screen-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1.1;
  margin-bottom: 16px;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.title-row .screen-title { margin-bottom: 0; }

.edit-btn {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #CC2325;
  text-decoration: none;
  white-space: nowrap;
}


/* ─────────────────────────────────────────
   FORM
───────────────────────────────────────── */
.form-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.field-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #aaa;
}

.input-row {
  display: flex;
  align-items: center;
  background: #fafafa;
  border-radius: 10px;
  padding: 0 14px;
  height: 52px;
  gap: 8px;
}

.field-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: #1a1a1a;
  outline: none;
  min-width: 0;
}

.field-input::placeholder { color: #c0c0c8; }

.input-unit {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #bbb;
  flex-shrink: 0;
}

.height-row { display: flex; gap: 10px; }
.height-row .input-row { flex: 1; }

.select-row {
  background: #fafafa;
  border-radius: 10px;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
}

.field-select {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  color: #1a1a1a;
  outline: none;
  cursor: pointer;
  width: 100%;
}

.form-error {
  font-size: 0.8rem;
  color: #CC2325;
  min-height: 1em;
}


/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
.seg-row { display: flex; gap: 8px; }

.seg-btn {
  flex: 1;
  height: 48px;
  border: 2px solid #E5E5EA;
  border-radius: 10px;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}

.seg-btn.active             { background: #CC2325; border-color: #CC2325; color: #fff; }
.seg-btn:not(.active):hover { border-color: #CC2325; color: #CC2325; }
.seg-btn:active             { transform: scale(0.95); }
.seg-btn:disabled           { opacity: 1; cursor: default; pointer-events: none; }

.primary-btn {
  width: 100%;
  height: 54px;
  background: #CC2325;
  border: none;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
}

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


/* ─────────────────────────────────────────
   STATS BAR
───────────────────────────────────────── */
.stats-bar {
  display: flex;
  justify-content: space-between;
  padding-bottom: 2px;
  margin-bottom: 22px;
}

.stat-chip       { display: flex; flex-direction: column; gap: 1px; }

.stat-chip-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #bbb;
  text-transform: uppercase;
}

.stat-chip-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a1a;
}


/* ─────────────────────────────────────────
   HEALTH INDEX — METRIC CARDS
───────────────────────────────────────── */

/* Swipeable TDEE/BMR card — must come before .metric-card so padding: 16px wins */
.slide-card         { overflow: hidden; padding: 0; position: relative; cursor: grab; }
.slide-card:active  { cursor: grabbing; }

.slide-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 28px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.slide-dots {
  position: absolute;
  bottom: 10px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.dot        { width: 6px; height: 6px; border-radius: 50%; background: #D0D0D8; transition: background 0.2s; }
.dot.active { background: #1a1a1a; }

.metric-pair {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card {
  background: #fafafa;
  border-radius: 14px;
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.metric-pair .metric-card { aspect-ratio: 1; }

.metric-card.full {
  flex: none;
  width: 100%;
  margin-bottom: 12px;
}

.metric-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #aaa;
  margin-bottom: 6px;
}

.metric-value {
  display: block;
  font-size: 3rem;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1;
  margin-top: 20px;
  margin-bottom: 6px;
}

.metric-sub {
  display: block;
  font-size: 0.72rem;
  color: #aaa;
  font-weight: 500;
}

.metric-value-lg {
  display: block;
  font-size: 2.1rem;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 14px;
  line-height: 1;
}


/* ─────────────────────────────────────────
   HEALTH INDEX — GRADIENT BARS
───────────────────────────────────────── */
.gbar-wrap { margin-top: 4px; }

.gbar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.bf-gradient {
  background: linear-gradient(to right,
    #2196f3 0%, #2196f3 24%,
    #4caf50 40%, #4caf50 62%,
    #f44336 68%, #f44336 100%);
}

.weight-gradient {
  background: linear-gradient(to right,
    #2196f3 0%, #2196f3 12%,
    #4caf50 25%, #4caf50 42%,
    #ff9800 62%,
    #f44336 84%, #f44336 100%);
}

.gbar-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2.5px solid #1a1a1a;
  border-radius: 50%;
  transition: left 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
  left: 5%;
}

.gbar-labels      { display: flex; justify-content: space-between; }

.gbar-labels span {
  font-size: 0.58rem;
  font-weight: 600;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bf-ideal-range {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.bf-ideal-range span {
  font-size: 0.65rem;
  font-weight: 600;
  color: #bbb;
  letter-spacing: 0.04em;
}


/* ─────────────────────────────────────────
   GOAL PAGE
───────────────────────────────────────── */
.obj-cal-card {
  background: #fafafa;
  border-radius: 14px;
  padding: 16px;
}

.obj-cal-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.obj-cal-edit {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1.5px dashed #c0c0ca86;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: text;
}

.edit-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  color: #C0C0CA;
  pointer-events: none;
}

.daily-target-input {
  background: transparent;
  border: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  color: #1a1a1a;
  width: 160px;
  line-height: 1;
}

.daily-target-input::placeholder          { color: #c0c0c8; }
.daily-target-input::-webkit-inner-spin-button,
.daily-target-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.daily-target-input                       { -moz-appearance: textfield; appearance: textfield; }

.daily-target-unit {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #aaa;
}

.cal-delta {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 6px;
  min-height: 1.2em;
}

.cal-deficit,
.cal-surplus { color: #CC2325; }
.cal-error   { color: #f0a020; }

.goal-status-line {
  font-size: 0.82rem;
  font-weight: 500;
  color: #CC2325;
  min-height: 1.2em;
  margin-top: -2px;
}

.goal-warning {
  font-size: 0.8rem;
  color: #f0a020;
  min-height: 1.2em;
  margin-top: 4px;
}

.time-to-goal {
  font-size: 0.88rem;
  font-weight: 600;
  color: #555;
  min-height: 1.2em;
  margin-top: 4px;
}

.projected-date {
  font-size: 0.78rem;
  font-weight: 500;
  color: #aaa;
}


/* ─────────────────────────────────────────
   GOAL PAGE — MACROS
───────────────────────────────────────── */
.macro-row {
  display: flex;
  background: #fafafa;
  border-radius: 14px;
  padding: 18px 12px;
  margin-top: 8px;
}

.macro-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.macro-item + .macro-item { border-left: 1.5px solid #E0E0E5; }

.macro-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #aaa;
}

.macro-val                        { display: flex; align-items: baseline; gap: 2px; }
.macro-val span:first-child       { font-size: 1.45rem; font-weight: 800; color: #1a1a1a; }
.macro-row.is-empty .macro-val span:first-child { color: #c0c0c8; }

.macro-unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: #aaa;
}

.macro-pct {
  font-size: 0.65rem;
  font-weight: 600;
  color: #bbb;
  letter-spacing: 0.04em;
}


/* ─────────────────────────────────────────
   LEARN PAGE
───────────────────────────────────────── */
.learn-topics { margin-top: 28px; }

.learn-intro {
  font-size: 0.82rem;
  color: #888;
  line-height: 1.65;
  margin-bottom: 20px;
}

.learn-topic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.learn-topic-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #F5F5F7;
  border-radius: 12px;
  padding: 14px;
  animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.learn-topic-icon  { font-size: 1.3rem; flex-shrink: 0; margin-top: 1px; }

.learn-topic-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 3px;
}

.learn-topic-desc {
  font-size: 0.75rem;
  color: #999;
  line-height: 1.5;
}

.beta-notice {
  font-size: 0.78rem;
  color: #bbb;
  line-height: 1.7;
  text-align: center;
  margin-top: 24px;
  padding: 0 8px;
}

.coming-soon {
  color: #bbb;
  font-size: 0.95rem;
  margin-top: 48px;
  text-align: center;
}


/* ─────────────────────────────────────────
   TAB BAR
───────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: #fff;
  border-top: 1px solid #E5E5EA;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
  animation: slideUpBar 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #c0c0c8;
  transition: color 0.15s;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tab-item.active { color: #CC2325; }
