/* ==========================================
   CALTRACK — Stylesheet
   Palette: Deep space dark + teal + orange
   ========================================== */

/* GLOBAL — must come first so it can be overridden by specifics */
.hidden { display: none !important; }

:root {
  --bg: #0D1117;
  --surface: #161B26;
  --surface2: #1E2736;
  --surface3: #252D3D;
  --border: #2A3347;
  --teal: #00D4AA;
  --teal-dim: #00A882;
  --orange: #FF6B35;
  --orange-dim: #CC5528;
  --purple: #9B6DFF;
  --text: #E8EDF5;
  --text-2: #9BA8BF;
  --text-3: #5C6B85;
  --green: #34D399;
  --red: #F87171;
  --yellow: #FBBF24;
  --font-display: 'Space Grotesk', sans-serif;
  --font-ui: 'Inter', sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --nav-h: 68px;
  --header-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-ui); overflow: hidden; }

/* ====== SCREENS ====== */
.screen { position: fixed; inset: 0; overflow-y: auto; display: none; }
.screen.active { display: flex; }

/* ====== SETUP SCREEN ====== */
#setup-screen {
  background: radial-gradient(ellipse at 30% 0%, #0E2A3A 0%, var(--bg) 60%);
  align-items: center; justify-content: center; padding: 24px;
}
.setup-container { width: 100%; max-width: 420px; }
.setup-logo {
  width: 72px; height: 72px; margin: 0 auto 16px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.setup-logo span { font-size: 32px; position: relative; z-index: 1; }
.logo-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid var(--teal); animation: spin 8s linear infinite;
  background: conic-gradient(var(--teal) 75%, transparent 75%);
  -webkit-mask: radial-gradient(circle, transparent 68%, black 68%);
  mask: radial-gradient(circle, transparent 68%, black 68%);
}
@keyframes spin { to { transform: rotate(360deg); } }

.setup-title { font-family: var(--font-display); font-size: 2rem; font-weight: 700; text-align: center; color: var(--teal); }
.setup-subtitle { text-align: center; color: var(--text-2); margin-bottom: 32px; margin-top: 4px; font-size: 0.9rem; }
.setup-form { display: flex; flex-direction: column; gap: 14px; }

/* ====== APP SCREEN ====== */
#app-screen { flex-direction: column; background: var(--bg); }

/* ====== HEADER ====== */
.app-header {
  height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.nav-date {
  background: none; border: none; color: var(--text-2); font-size: 1.4rem;
  cursor: pointer; padding: 8px; line-height: 1; transition: color 0.2s;
}
.nav-date:hover { color: var(--teal); }
.header-date { text-align: center; cursor: pointer; }
.header-date span { display: block; }
#header-day-label { font-weight: 700; font-size: 1.05rem; font-family: var(--font-display); }
.date-sub { font-size: 0.72rem; color: var(--text-2); }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 6px; }

/* ====== TODAY BUTTON ====== */
.today-btn {
  background: var(--teal); color: #0D1117;
  border: none; border-radius: 999px;
  padding: 4px 12px; font-size: 0.75rem; font-weight: 700;
  cursor: pointer; font-family: var(--font-ui);
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.today-btn:hover { background: var(--teal-dim); }
.today-btn.hidden { display: none; }

/* ====== ROUTINE FORM ====== */
.routine-form { display: flex; flex-direction: column; gap: 10px; }
.routine-day-row {
  display: flex; align-items: center; gap: 10px;
}
.routine-day-name {
  width: 80px; flex-shrink: 0;
  font-size: 0.82rem; font-weight: 700; color: var(--text-2);
}
.routine-day-row input {
  flex: 1; padding: 9px 12px; font-size: 0.88rem;
}
.routine-day-emoji {
  font-size: 1.2rem; flex-shrink: 0; width: 28px; text-align: center;
}

/* ====== MAIN CONTENT ====== */
.app-content {
  flex: 1; overflow-y: auto; padding: 16px 16px calc(var(--nav-h) + 16px);
  -webkit-overflow-scrolling: touch;
}

/* ====== BOTTOM NAV ====== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 8px; z-index: 100;
}
.nav-item {
  flex: 1; background: none; border: none; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.68rem; font-family: var(--font-ui); cursor: pointer;
  padding: 8px 4px; transition: color 0.2s; min-width: 0;
}
.nav-item.active { color: var(--teal); }
.nav-icon { font-size: 1.2rem; }
.nav-add {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--orange); border: none; color: white;
  font-size: 1.6rem; font-weight: 300; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,107,53,0.35); transition: transform 0.15s;
  flex-shrink: 0; line-height: 1;
}
.nav-add:active { transform: scale(0.92); }

/* ====== FORMS ====== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }

label { font-size: 0.78rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-3); }

input[type="text"], input[type="number"], input[type="password"], input[type="email"],
select, textarea {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 0.92rem;
  font-family: var(--font-ui); width: 100%; outline: none; transition: border-color 0.2s;
  appearance: none; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239BA8BF' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea { resize: vertical; min-height: 80px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
a { color: var(--teal); }

.btn-group { display: flex; gap: 8px; }
.btn-toggle {
  flex: 1; padding: 10px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.88rem; transition: all 0.2s;
}
.btn-toggle.active { background: var(--teal); border-color: var(--teal); color: #0D1117; font-weight: 700; }

.btn-primary {
  background: var(--teal); color: #0D1117; border: none; border-radius: var(--radius-sm);
  padding: 13px 20px; font-size: 0.95rem; font-weight: 700; cursor: pointer;
  font-family: var(--font-ui); transition: background 0.2s; letter-spacing: 0.02em;
}
.btn-primary:hover { background: var(--teal-dim); }
.btn-secondary {
  background: var(--surface3); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 20px; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; font-family: var(--font-ui); transition: background 0.2s;
}
.btn-secondary:hover { background: var(--border); }
.btn-outline {
  background: transparent; color: var(--teal); border: 1px solid var(--teal);
  border-radius: var(--radius-sm); padding: 11px 16px; font-size: 0.88rem;
  font-weight: 600; cursor: pointer; font-family: var(--font-ui);
}
.btn-danger {
  background: rgba(248,113,113,0.12); color: var(--red); border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm); padding: 13px 20px; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; font-family: var(--font-ui);
}
.btn-full { width: 100%; }
.flex-1 { flex: 1; }

/* ====== CARDS ====== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-sm { padding: 12px; border-radius: var(--radius-sm); }

/* ====== ENERGY RINGS ====== */
.energy-section { margin-bottom: 12px; }
.energy-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.energy-header h2 { font-family: var(--font-display); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-2); }
.energy-rings { display: flex; justify-content: space-around; align-items: center; padding: 8px 0; }
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ring-label { font-size: 0.72rem; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.ring-container { position: relative; width: 90px; height: 90px; }
.ring-svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface3); stroke-width: 8; }
.ring-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.6s cubic-bezier(0.4,0,0.2,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-val { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; line-height: 1; }
.ring-unit { font-size: 0.6rem; color: var(--text-2); }

/* Macro bar */
.macro-bar-section { margin-top: 12px; }
.macro-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.macro-bar-label { font-size: 0.75rem; color: var(--text-2); width: 100px; display: flex; justify-content: space-between; }
.macro-bar-track { flex: 1; height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.macro-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.macro-bar-pct { font-size: 0.7rem; color: var(--text-3); width: 32px; text-align: right; }

/* Water tracker */
.water-section { display: flex; justify-content: space-between; align-items: center; }
.water-info { display: flex; flex-direction: column; }
.water-title { font-weight: 700; }
.water-sub { font-size: 0.8rem; color: var(--text-2); }
.water-btns { display: flex; gap: 8px; align-items: center; }
.water-btn {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface2);
  border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}

/* ====== MEAL SECTIONS ====== */
.meal-section { margin-bottom: 10px; }
.meal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: background 0.15s; user-select: none;
}
.meal-header:hover { background: var(--surface2); }
.meal-title { font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.meal-kcal { font-size: 0.8rem; color: var(--text-2); }
.meal-chevron { color: var(--text-3); transition: transform 0.25s; font-size: 0.8rem; }
.meal-section.open .meal-chevron { transform: rotate(180deg); }
.meal-section.open .meal-header { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: transparent; }

.meal-items { display: none; background: var(--surface); border: 1px solid var(--border); border-top: none; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.meal-section.open .meal-items { display: block; }

/* ====== SWIPEABLE FOOD ITEMS ====== */
.food-item-wrap {
  position: relative;
  overflow: hidden;
}
.food-item-wrap + .food-item-wrap { border-top: 1px solid var(--border); }

/* The visible row that slides */
.food-item {
  display: flex; align-items: center; padding: 11px 16px; gap: 12px;
  cursor: pointer; background: var(--surface);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1), background 0.15s;
  position: relative; z-index: 1; user-select: none;
  -webkit-user-select: none;
}
.food-item:hover { background: var(--surface2); }
.food-item.swiped { transform: translateX(-148px); }

/* Actions revealed behind the row */
.food-item-actions {
  position: absolute; right: 0; top: 0; bottom: 0;
  display: flex; align-items: stretch; z-index: 0;
}
.fi-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 68px; border: none; cursor: pointer; font-size: 0.68rem; font-weight: 700;
  gap: 4px; padding: 0; transition: filter 0.15s;
}
.fi-action:active { filter: brightness(0.85); }
.fi-action-move { background: var(--teal); color: #0D1117; }
.fi-action-del  { background: var(--red);  color: white; }
.fi-action-icon { font-size: 1.1rem; }

/* Move picker — hidden inline element (replaced by floating modal) */
.food-move-picker { display: none; }

/* ====== MOVE FOOD FLOATING MENU ====== */
#move-food-modal {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#move-food-modal.hidden { display: none; }

#move-food-modal .mfm-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(3px);
}

#move-food-modal .mfm-box {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px; width: 100%; max-width: 340px;
  animation: mfmIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes mfmIn {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.mfm-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 6px;
}
.mfm-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.mfm-food-name {
  font-size: 0.78rem; color: var(--text-2); margin-bottom: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mfm-close {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-2); width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 0.8rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.mfm-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.mfm-option {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; font-family: var(--font-ui);
  transition: all 0.18s;
}
.mfm-option:hover, .mfm-option:active { background: var(--teal); border-color: var(--teal); }
.mfm-option:hover .mfm-opt-label, .mfm-option:active .mfm-opt-label { color: #0D1117; }
.mfm-option:hover .mfm-opt-emoji, .mfm-option:active .mfm-opt-emoji { transform: scale(1.15); }
.mfm-option.current {
  background: var(--surface); border-color: var(--border);
  opacity: 0.4; cursor: default; pointer-events: none;
}
.mfm-opt-emoji { font-size: 1.6rem; transition: transform 0.18s; }
.mfm-opt-label { font-size: 0.82rem; font-weight: 600; color: var(--text); }

.food-icon { font-size: 1.3rem; flex-shrink: 0; }
.food-info { flex: 1; min-width: 0; }
.food-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-portion { font-size: 0.75rem; color: var(--text-2); }
.food-cal { font-family: var(--font-display); font-weight: 700; color: var(--orange); font-size: 0.92rem; flex-shrink: 0; }
.food-cal span { font-size: 0.65rem; font-weight: 400; color: var(--text-3); }
/* hide old delete button — actions now in swipe panel */
.food-del { display: none; }

.add-food-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  cursor: pointer; color: var(--teal); font-size: 0.88rem; font-weight: 600;
  border-top: 1px solid var(--border); transition: background 0.15s;
}
.add-food-btn:hover { background: rgba(0,212,170,0.06); }
.empty-meal { padding: 12px 16px; font-size: 0.8rem; color: var(--text-3); text-align: center; }

/* ====== EXERCISE SECTION ====== */
.exercise-log-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.ex-icon { font-size: 1.4rem; }
.ex-info { flex: 1; }
.ex-name { font-weight: 600; font-size: 0.9rem; }
.ex-detail { font-size: 0.75rem; color: var(--text-2); }
.ex-cal { font-family: var(--font-display); font-weight: 700; color: var(--teal); }

/* ====== FOODS DB PAGE ====== */
.foods-search-bar { position: relative; margin-bottom: 14px; }
.foods-search-bar input { padding-left: 40px; }
.foods-search-bar .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 1rem; }
.food-db-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.food-db-item:hover { background: var(--surface2); }
.food-db-item:last-child { border-bottom: none; }
.food-db-cal { font-family: var(--font-display); font-weight: 700; color: var(--orange); margin-left: auto; }
.food-db-macros { font-size: 0.72rem; color: var(--text-3); }

/* ====== STATS PAGE ====== */
.stat-period { display: flex; gap: 8px; margin-bottom: 16px; }
.period-btn {
  flex: 1; padding: 8px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.82rem; font-weight: 600;
  font-family: var(--font-ui); transition: all 0.2s;
}
.period-btn.active { background: var(--teal); border-color: var(--teal); color: #0D1117; }

.stats-avg-card { text-align: center; padding: 20px; }
.stats-avg-val { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; color: var(--teal); }
.stats-avg-label { font-size: 0.8rem; color: var(--text-2); margin-top: 4px; }
.stats-macro-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 14px; }
.stat-macro-item { background: var(--surface2); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-macro-val { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.stat-macro-label { font-size: 0.7rem; color: var(--text-2); margin-top: 2px; }

/* Bar chart */
.bar-chart { padding: 8px 0; }
.bar-chart-title { font-size: 0.8rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 16px; }
.bar-chart-inner { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: 20px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.bar-inner { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.5s ease; }
.bar-day { font-size: 0.62rem; color: var(--text-3); margin-top: 4px; white-space: nowrap; }
.bar-val { font-size: 0.58rem; color: var(--text-2); min-height: 14px; line-height: 14px; white-space: nowrap; }

/* ====== SEARCH RESULTS ====== */
.search-results { max-height: 280px; overflow-y: auto; }
.search-result-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.search-result-item:hover .sr-name { color: var(--teal); }
.sr-icon { font-size: 1.2rem; }
.sr-info { flex: 1; }
.sr-name { font-weight: 600; font-size: 0.88rem; }
.sr-portion { font-size: 0.73rem; color: var(--text-2); }
.sr-cal { font-family: var(--font-display); font-weight: 700; color: var(--orange); }
.sr-add { background: var(--teal); color: #0D1117; border: none; border-radius: 6px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-size: 0.78rem; }

/* ====== MODALS ====== */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; background: var(--surface); width: 100%; max-width: 500px;
  border-radius: var(--radius) var(--radius) 0 0; max-height: 90vh; overflow-y: auto;
  padding: 20px 20px 36px; z-index: 1;
  animation: slideUp 0.28s cubic-bezier(0.4,0,0.2,1);
}
.modal-add { max-height: 92vh; }
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.close-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; }

/* ====== TAB PILLS ====== */
.tab-pills { display: flex; gap: 8px; margin-bottom: 18px; background: var(--surface2); padding: 4px; border-radius: 10px; }
.pill {
  flex: 1; padding: 8px 6px; background: none; border: none; color: var(--text-2);
  border-radius: 8px; cursor: pointer; font-size: 0.82rem; font-weight: 600;
  font-family: var(--font-ui); transition: all 0.2s; text-align: center;
}
.pill.active { background: var(--surface3); color: var(--teal); }

.pill-content { display: none; }
.pill-content.active { display: block; }

/* ====== SEARCH BOX ====== */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input { padding-left: 40px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); }
.meal-selector { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.meal-selector label { font-size: 0.78rem; color: var(--text-2); font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.05em; }
.meal-selector select { flex: 1; }

/* ====== AI SECTION ====== */
.ai-intro { text-align: center; margin-bottom: 16px; }
.ai-icon { font-size: 2rem; margin-bottom: 8px; }
.ai-intro h3 { font-family: var(--font-display); font-weight: 700; }
.ai-intro p { font-size: 0.83rem; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.ai-format-box { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 14px; position: relative; }
.format-label { font-size: 0.7rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.format-text { font-size: 0.78rem; color: var(--text-2); font-family: monospace; line-height: 1.5; word-break: break-all; }
.copy-btn { margin-top: 8px; background: var(--surface3); border: 1px solid var(--border); color: var(--teal); border-radius: 6px; padding: 5px 12px; font-size: 0.78rem; cursor: pointer; font-weight: 600; }
.ai-preview { background: rgba(0,212,170,0.08); border: 1px solid rgba(0,212,170,0.25); border-radius: var(--radius-sm); padding: 14px; margin: 14px 0; }
.ai-preview .preview-name { font-weight: 700; font-size: 1rem; margin-bottom: 8px; }
.ai-preview .preview-macros { display: flex; gap: 12px; flex-wrap: wrap; }
.ai-preview .macro-chip { background: var(--surface2); border-radius: 6px; padding: 4px 10px; font-size: 0.78rem; }

.gemini-section { margin-top: 16px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-3); font-size: 0.78rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.img-preview { margin-bottom: 10px; }
.img-preview img { width: 100%; max-height: 160px; object-fit: cover; border-radius: var(--radius-sm); }

/* ====== CAL PREVIEW ====== */
.cal-preview { background: rgba(0,212,170,0.08); border: 1px solid rgba(0,212,170,0.2); border-radius: var(--radius-sm); padding: 12px; text-align: center; margin-bottom: 14px; font-family: var(--font-display); font-weight: 700; color: var(--teal); font-size: 1.1rem; }

/* ====== SETTINGS ====== */
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-info { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-size: 0.82rem; line-height: 1.6; color: var(--text-2); }
.api-key-section { display: flex; flex-direction: column; gap: 6px; }
.hint { font-size: 0.72rem; color: var(--text-3); }

/* ====== FOOD DETAIL - EXTENDED ====== */
.detail-extra-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px;
}
.detail-extra-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 8px 12px; border: 1px solid var(--border);
}
.detail-extra-row.warn { border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.06); }
.de-label { font-size: 0.75rem; color: var(--text-2); }
.de-val   { font-family: var(--font-display); font-weight: 700; font-size: 0.88rem; color: var(--text); }
.detail-extra-row.warn .de-val { color: var(--red); }
.food-detail { padding: 4px 0; }
.detail-header { margin-bottom: 16px; }
.detail-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.detail-portion { color: var(--text-2); font-size: 0.85rem; margin-top: 2px; }
.detail-cal { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--teal); margin: 12px 0 4px; }
.detail-macros { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 16px 0; }
.detail-macro { background: var(--surface2); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.dm-val { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.dm-label { font-size: 0.68rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }

/* ====== SAVE-TO-DB ====== */
.save-to-db { margin-top: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.82rem; color: var(--text-2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.checkbox-label input { width: auto; }

/* ====== TOAST ====== */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--surface3); color: var(--text); padding: 10px 20px; border-radius: 999px;
  font-size: 0.88rem; font-weight: 600; z-index: 2000; white-space: nowrap;
  border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: fadeInUp 0.25s ease;
}
.toast.hidden { display: none; }
@keyframes fadeInUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ====== EMPTY STATE ====== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.85rem; line-height: 1.6; }

/* ====== LOADING ====== */
.loading { display: flex; align-items: center; justify-content: center; padding: 24px; gap: 8px; color: var(--text-2); font-size: 0.85rem; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--teal); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ====== SECTION TITLE ====== */
.section-title { font-size: 0.72rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; margin: 18px 0 10px; }

/* TDEE info badges */
.tdee-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.tdee-key { color: var(--text-3); }
.tdee-val { color: var(--teal); font-weight: 700; }

/* Responsive */
@media (min-width: 500px) {
  .modal-content { border-radius: var(--radius) var(--radius) 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ====== EXERCISE DELETE (separate from hidden .food-del) ====== */
.ex-del-btn {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  padding: 4px 8px; font-size: 0.9rem; transition: color 0.2s; flex-shrink: 0;
}
.ex-del-btn:hover { color: var(--red); }

/* ====== SWIPE HINT — small arrow on right edge ====== */
.food-item::after {
  content: '‹';
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 0.9rem; opacity: 0.3;
  pointer-events: none; transition: opacity 0.2s;
}
.food-item.swiped::after,
.food-item:active::after { opacity: 0; }

/* ====== WEIGHT BANNER ====== */
.weight-banner {
  background: linear-gradient(135deg, rgba(0,212,170,0.1), rgba(155,109,255,0.08));
  border: 1px solid rgba(0,212,170,0.3);
  border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 12px;
  animation: fadeInUp 0.3s ease;
}
.wb-content { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.wb-icon    { font-size: 1.5rem; flex-shrink: 0; }
.wb-text    { display: flex; flex-direction: column; gap: 2px; }
.wb-text strong { font-size: 0.9rem; color: var(--text); }
.wb-text span   { font-size: 0.78rem; color: var(--text-2); }
.wb-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wb-btn-save {
  background: var(--teal); color: #0D1117; border: none;
  border-radius: 8px; padding: 7px 14px; font-size: 0.82rem;
  font-weight: 700; cursor: pointer; font-family: var(--font-ui);
}
.wb-btn-skip {
  background: var(--surface2); color: var(--text-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-size: 0.82rem;
  font-weight: 600; cursor: pointer; font-family: var(--font-ui);
}
.wb-btn-disable {
  background: none; color: var(--text-3); border: none;
  cursor: pointer; font-size: 0.85rem; padding: 4px 6px; margin-left: auto;
}

/* ====== TOGGLE SWITCH ====== */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface3); border-radius: 999px;
  border: 1px solid var(--border); transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 50%; transform: translateY(-50%);
  background: var(--text-2); border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--teal); border-color: var(--teal); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px) translateY(-50%); background: #0D1117; }

/* ====== UNIT TOGGLES ====== */
.units-row {
  display: flex; gap: 16px; margin-bottom: 4px;
}
.unit-toggle-group {
  display: flex; flex-direction: column; gap: 6px; flex: 1;
}
.unit-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.unit-btn-group { gap: 4px; }
.unit-btn-group .btn-toggle {
  padding: 7px 8px; font-size: 0.82rem;
}

/* ====== FOODS PAGE — filters, origin tags, delete ====== */
.foods-filter-row {
  display: flex; gap: 8px; margin: 10px 0 8px; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  padding-bottom: 2px;
}
.foods-filter-row::-webkit-scrollbar { display: none; }

.filter-pill {
  flex-shrink: 0; padding: 6px 14px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); border-radius: 999px; cursor: pointer;
  font-size: 0.78rem; font-weight: 600; font-family: var(--font-ui);
  transition: all 0.18s; white-space: nowrap;
}
.filter-pill.active {
  background: var(--teal); border-color: var(--teal); color: #0D1117;
}
.filter-pill:not(.active):hover { background: var(--surface2); }

.foods-count {
  font-size: 0.72rem; color: var(--text-3);
  margin-bottom: 8px; padding-left: 2px;
}

.origin-tag {
  display: inline-block; margin-left: 6px;
  font-size: 0.68rem; color: var(--text-3);
  background: var(--surface3); border-radius: 4px;
  padding: 1px 5px; vertical-align: middle;
}

.food-db-del {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: 4px 6px; flex-shrink: 0;
  opacity: 0.45; transition: opacity 0.2s;
  line-height: 1;
}
.food-db-del:hover { opacity: 1; }
/* (regla .food-db-item duplicada eliminada — la definición canónica está más arriba) */

/* ====== QUANTITY MODAL ====== */
.qty-food-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 18px;
  text-align: center;
}
.qty-food-name    { font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.qty-food-portion { font-size: 0.78rem; color: var(--text-2); margin-bottom: 6px; }
.qty-food-cal-base{ font-size: 0.78rem; color: var(--text-3); font-family: var(--font-display); }

.qty-stepper {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-bottom: 16px;
}
.qty-step-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--teal); font-size: 1.4rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0;
}
.qty-step-btn:hover { background: var(--surface3); }
.qty-step-btn:active { transform: scale(0.92); }

#qty-input {
  width: 90px; text-align: center; font-size: 1.3rem; font-weight: 700;
  font-family: var(--font-display); padding: 10px 8px;
}

.qty-result {
  text-align: center; margin-bottom: 18px;
  font-family: var(--font-display);
}
#qty-preview-cal {
  font-size: 1.8rem; font-weight: 700; color: var(--orange);
}
.qty-result-unit {
  font-size: 0.8rem; color: var(--text-2); font-family: var(--font-ui);
}

/* ==========================================
   ONBOARDING — Welcome, Goal Reveal, Tour
   ========================================== */

/* ====== WELCOME SCREEN ====== */
#welcome-screen {
  background: radial-gradient(ellipse at 30% 0%, #0E2A3A 0%, var(--bg) 60%);
  align-items: center; justify-content: center; padding: 24px;
}
.welcome-container {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; min-height: 100%;
}
.welcome-skip-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.welcome-skip {
  background: none; border: none; color: var(--text-3);
  font-size: 0.82rem; cursor: pointer; padding: 8px;
}
.welcome-skip:hover { color: var(--text-2); }

.welcome-slides {
  position: relative; flex: 1; display: flex; align-items: center;
  min-height: 340px;
}
.welcome-slide {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0 8px;
  animation: welcomeFadeIn 0.4s ease;
}
.welcome-slide.active { display: flex; }
@keyframes welcomeFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.welcome-emoji { font-size: 3.5rem; margin-bottom: 20px; }
.welcome-title {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700;
  color: var(--text); margin-bottom: 14px; line-height: 1.3;
}
.welcome-text {
  font-size: 0.92rem; color: var(--text-2); line-height: 1.6;
  max-width: 340px;
}
.welcome-text strong { color: var(--teal); }

.welcome-dots { display: flex; justify-content: center; gap: 8px; margin: 20px 0; }
.welcome-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface3); transition: all 0.25s;
}
.welcome-dot.active { background: var(--teal); width: 22px; border-radius: 4px; }

/* ====== GOAL REVEAL SCREEN ====== */
#goal-reveal-screen {
  background: radial-gradient(ellipse at 70% 0%, #1A2A1E 0%, var(--bg) 60%);
  align-items: center; justify-content: center; padding: 24px; overflow-y: auto;
}
.goal-reveal-container { width: 100%; max-width: 440px; padding: 12px 0 24px; }
.goal-reveal-header { text-align: center; margin-bottom: 24px; }
.goal-reveal-emoji { font-size: 2.8rem; margin-bottom: 12px; }
.goal-reveal-title {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-bottom: 6px;
}
.goal-reveal-sub { font-size: 0.85rem; color: var(--text-2); }

.goal-calc-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.goal-calc-step {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  animation: stepSlideIn 0.4s ease backwards;
}
@keyframes stepSlideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
.gcs-icon { font-size: 1.3rem; flex-shrink: 0; width: 28px; text-align: center; }
.gcs-text { flex: 1; }
.gcs-label { font-size: 0.78rem; color: var(--text-2); }
.gcs-formula { font-size: 0.7rem; color: var(--text-3); font-family: monospace; margin-top: 1px; }
.gcs-value { font-family: var(--font-display); font-weight: 700; color: var(--teal); font-size: 0.95rem; flex-shrink: 0; }

.goal-target-card {
  background: linear-gradient(135deg, rgba(0,212,170,0.12), rgba(155,109,255,0.08));
  border: 1px solid rgba(0,212,170,0.35);
  border-radius: var(--radius); padding: 20px; text-align: center;
  margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.goal-target-label { font-size: 0.78rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.goal-target-value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; color: var(--teal); }

.goal-eta-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 18px;
  text-align: center; font-size: 0.88rem; color: var(--text-2);
}
.goal-eta-card strong { color: var(--text); font-family: var(--font-display); }

.goal-honesty-box {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 20px;
}
.goal-honesty-icon { font-size: 1.3rem; flex-shrink: 0; }
.goal-honesty-box p { font-size: 0.82rem; color: var(--text-2); line-height: 1.5; }
.goal-honesty-box strong { color: var(--text); }

.btn-text-skip {
  display: block; width: 100%; background: none; border: none;
  color: var(--text-3); font-size: 0.82rem; cursor: pointer;
  padding: 12px; margin-top: 6px; text-align: center;
  font-family: var(--font-ui);
}
.btn-text-skip:hover { color: var(--text-2); }

/* ====== APP TOUR OVERLAY ====== */
.tour-overlay {
  position: fixed; inset: 0; z-index: 5000;
  pointer-events: none;
}
.tour-overlay.hidden { display: none; }

.tour-spotlight {
  position: fixed; border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.72);
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
  border: 2px solid var(--teal);
}

.tour-tooltip {
  position: fixed; z-index: 5001;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  width: min(320px, 88vw);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: auto;
  transition: top 0.35s cubic-bezier(0.4,0,0.2,1), left 0.35s cubic-bezier(0.4,0,0.2,1);
}
.tour-tooltip-step {
  font-size: 0.68rem; color: var(--teal); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px;
}
.tour-tooltip-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.02rem;
  margin-bottom: 6px;
}
.tour-tooltip-text {
  font-size: 0.84rem; color: var(--text-2); line-height: 1.5; margin-bottom: 14px;
}
.tour-tooltip-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tour-btn-skip {
  background: none; border: none; color: var(--text-3);
  font-size: 0.8rem; cursor: pointer; padding: 6px 4px;
}
.tour-btn-next {
  background: var(--teal); color: #0D1117; border: none;
  border-radius: 999px; padding: 8px 18px; font-size: 0.85rem;
  font-weight: 700; cursor: pointer; font-family: var(--font-ui);
  transition: opacity 0.15s;
}
.tour-btn-next:disabled {
  opacity: 0.55; cursor: default;
}
.tour-dots { display: flex; gap: 4px; }
.tour-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--surface3);
  transition: background 0.2s;
}
.tour-dot.active { background: var(--teal); }

/* ====== WELCOME DISCLAIMER SLIDE ====== */
.welcome-disclaimer {
  font-size: 0.82rem; line-height: 1.6;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  text-align: left; color: var(--text-2);
}

/* ====== DISCLAIMER BOX (Informe tab) ====== */
.disclaimer-box {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  margin-top: 4px; margin-bottom: 8px;
}
.disclaimer-icon { font-size: 1.1rem; flex-shrink: 0; opacity: 0.7; }
.disclaimer-box p {
  font-size: 0.74rem; color: var(--text-3); line-height: 1.55;
}

/* ====== PACE SELECTOR (relajada / normal / rápida) ====== */
.pace-selector-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}
.pace-selector {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.pace-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; transition: all 0.18s; text-align: center;
  font-family: var(--font-ui);
}
.pace-card:hover { background: var(--surface3); }
.pace-card.active {
  background: rgba(0,212,170,0.1); border-color: var(--teal);
}
.pace-card-label {
  font-size: 0.78rem; font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.pace-card-weeks {
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  color: var(--teal);
}
.pace-card.active .pace-card-weeks { color: var(--teal); }
.pace-card-desc {
  font-size: 0.62rem; color: var(--text-3); line-height: 1.3;
}

.goal-pace-section { margin-bottom: 4px; }
.goal-pace-section.hidden { display: none; }

/* ====== PACE CARD - capped by safety floor ====== */
.pace-card.capped {
  border-color: rgba(251,191,36,0.4);
}
.pace-card.capped .pace-card-desc {
  color: var(--yellow);
}
.pace-floor-notice {
  background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.3);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 0.74rem; color: var(--text-2); line-height: 1.5;
  margin-bottom: 14px;
}