:root {
  --bg:      #0b1220;
  --surface: #111827;
  --card:    #141e2e;
  --border:  rgba(255,255,255,0.08);
  --accent:  #6366f1;
  --green:   #22c55e;
  --red:     #ef4444;
  --muted:   rgba(255,255,255,0.4);
  --text:    #f0f0f8;
  --radius:  16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  padding-bottom: 80px;
}

.back-link {
  display: inline-block;
  padding: 14px 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

.page-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-header { margin-bottom: 28px; }

.logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1;
}
.logo span { color: var(--accent); }

.sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

/* ---- CARDS ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
  color: var(--text);
}

/* ---- FIELD GRID ---- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

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

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.unit { font-size: 11px; color: var(--muted); margin-left: 4px; }

input[type="number"] {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border 0.2s;
  width: 100%;
}
input[type="number"]:focus { border-color: rgba(99,102,241,0.6); }
input::placeholder { color: var(--muted); }

/* ---- GENDER SEGMENT ---- */
.seg-wrap {
  display: flex;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.seg-btn {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.seg-btn.active { background: var(--accent); color: white; font-weight: 700; }

/* ---- GYM DAYS ---- */
.gym-days-wrap {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.day-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.day-btn.active {
  background: rgba(99,102,241,0.2);
  border-color: var(--accent);
  color: var(--accent);
}
.day-btn:hover { border-color: rgba(99,102,241,0.5); color: var(--accent); }

/* ---- CALC BUTTON ---- */
.calc-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.2s;
}
.calc-btn:hover { opacity: 0.88; }

/* ---- BF BAR ---- */
.results-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

.bf-bar-container {
  position: relative;
  height: 14px;
  background: linear-gradient(to right, #22c55e 0%, #3b82f6 25%, #eab308 50%, #f97316 75%, #ef4444 100%);
  border-radius: 99px;
  margin-bottom: 6px;
}
.bf-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: rgba(0,0,0,0.3);
  border-radius: 99px;
  /* this masks the right portion — we invert logic: bar shows how far along you are */
  background: transparent;
}

/* The actual fill indicator is the pointer markers */
.bf-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 22px;
  background: white;
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
  transition: left 0.4s ease;
}
.bf-marker--high { background: rgba(255,255,255,0.5); }

.bf-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
  margin-top: 4px;
  margin-bottom: 16px;
}

.bf-numbers {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.bf-num-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}
.bf-num-row--mid { padding: 8px 0; }
.bf-num-label { font-size: 13px; color: var(--muted); }
.bf-num-val { font-size: 16px; font-weight: 700; color: var(--text); }
.bf-num-val--mid { font-size: 24px; color: #6366f1; }

.bf-category { margin-bottom: 0; }
.category-pill {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 99px;
  border: 1px solid;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.06em;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ---- STAT GRID ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 4px; text-transform: uppercase; }
.stat-val { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.stat-sub { font-size: 11px; color: var(--muted); }

/* ---- TDEE HIGHLIGHT ---- */
.tdee-highlight {
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  margin-bottom: 14px;
}
.tdee-big {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 56px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}
.tdee-big span { font-size: 20px; color: var(--muted); }
.tdee-big-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.tdee-note { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }

/* ---- SAVE BUTTON ---- */
.save-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--green);
  color: white;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: opacity 0.2s;
}
.save-btn:hover { opacity: 0.88; }

.save-msg {
  text-align: center;
  color: var(--green);
  font-size: 14px;
  margin-top: 10px;
}

/* ---- SAVED SUMMARY ---- */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.summary-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-item span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.summary-item strong { font-size: 17px; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .field-grid  { grid-template-columns: 1fr; }
  .stat-grid   { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .logo { font-size: 36px; }
  .tdee-big { font-size: 44px; }
}

/* FOOD SEARCH DROPDOWN */
.food-search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.food-search-input {
  width: 100%;
  padding: 10px 14px;
  /* matches the modal background exactly */
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: white;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}
.food-search-input:focus {
  border-color: rgba(99,102,241,0.6);
}
.food-search-input::placeholder {
  color: rgba(255,255,255,0.3);
}

/* dropdown panel */
.food-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  /* same dark surface as the modal */
  background: #111827;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 999;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.food-dropdown.open {
  display: block;
}

.food-drop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.food-drop-item:last-child {
  border-bottom: none;
}
.food-drop-item:hover {
  background: rgba(99,102,241,0.2);
}

.food-drop-name {
  font-size: 14px;
  font-weight: 600;
}
.food-drop-cal {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.food-drop-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: rgba(255,255,255,0.35);
}