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

:root {
  --bg: #f8f7f4; --surface: #ffffff; --surface2: #f1efe8;
  --border: rgba(0,0,0,0.10); --border-strong: rgba(0,0,0,0.20);
  --text: #1a1a18; --text2: #6b6b67; --text3: #9a9a95; --accent: #1a1a18;
  --green: #3B6D11; --green-bg: #EAF3DE;
  --blue: #185FA5; --blue-bg: #E6F1FB;
  --amber: #854F0B; --amber-bg: #FAEEDA;
  --red: #A32D2D; --red-bg: #FCEBEB;
  --purple: #534AB7; --purple-bg: #EEEDFE;
  --teal: #0F6E56; --teal-bg: #E1F5EE;
  --radius: 10px; --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181a; --surface: #242426; --surface2: #2e2e31;
    --border: rgba(255,255,255,0.09); --border-strong: rgba(255,255,255,0.18);
    --text: #f0efea; --text2: #9a9a95; --text3: #555552; --accent: #f0efea;
    --green-bg: #1a2e0a; --blue-bg: #0c1e36; --amber-bg: #2a1a06;
    --red-bg: #2a0e0e; --purple-bg: #1a1840; --teal-bg: #062820;
  }
}

html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }

/* Auth */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-box { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 36px 32px; width: 100%; max-width: 400px; }
.auth-title { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; text-align: center; }
.auth-sub { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 24px; margin-top: 4px; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface2); border-radius: var(--radius); padding: 3px; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 8px; border: none; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text2); font-family: inherit; transition: all 0.15s; }
.auth-tab.active { background: var(--surface); color: var(--text); }
.auth-error { background: var(--red-bg); color: var(--red); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }

/* Loading */
.loading-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 1000; transition: opacity 0.3s; }
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 32px; height: 32px; border: 2.5px solid var(--border); border-top-color: var(--text); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.app { max-width: 900px; margin: 0 auto; padding: 0 16px 80px; }
.app-header { padding: 24px 0 16px; border-bottom: 0.5px solid var(--border); margin-bottom: 0; }
.header-inner { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.app-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.app-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.header-meta { font-size: 13px; color: var(--text2); }
.header-meta strong { color: var(--text); }

/* Nav */
.nav { display: flex; gap: 2px; padding: 10px 0; border-bottom: 0.5px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }
.nav-btn { padding: 6px 13px; border-radius: var(--radius); border: none; background: transparent; color: var(--text2); font-size: 13px; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent); color: var(--bg); }

/* Sections */
.section { display: none; }
.section.active { display: block; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { font-size: 18px; font-weight: 500; }

/* Cards */
.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 14px; }
.card-title { font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }

/* Metrics */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric { background: var(--surface2); border-radius: var(--radius); padding: 14px 16px; }
.metric-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.metric-value { font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -0.5px; line-height: 1.1; }
.metric-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }

/* Progress bar */
.prog-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.progress-bar-wrap { background: var(--surface2); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.5s ease; }
.prog-sub { font-size: 12px; color: var(--text3); margin-top: 6px; }

/* Charts */
.chart-wrap { position: relative; width: 100%; height: 200px; }
.chart-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.legend-dash { display: inline-block; width: 18px; height: 2px; border-radius: 1px; vertical-align: middle; }

/* Forms */
.form-card { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  background: var(--surface2); border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; font-size: 14px; color: var(--text); font-family: inherit; width: 100%; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--border-strong); }
.form-group textarea { resize: vertical; min-height: 72px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }

/* Buttons */
.btn { padding: 9px 18px; border-radius: var(--radius); border: 0.5px solid var(--border-strong); background: var(--accent); color: var(--bg); font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity 0.15s; font-family: inherit; }
.btn:hover { opacity: 0.8; }
.btn:active { transform: scale(0.98); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface2); }
.btn.full-width { width: 100%; }
.icon-btn { background: var(--surface2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 6px 14px; font-size: 16px; cursor: pointer; color: var(--text2); transition: all 0.15s; font-family: inherit; }
.icon-btn:hover { background: var(--surface); color: var(--text); }

/* Tables */
.table-scroll { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th { text-align: left; padding: 8px 12px; font-weight: 500; font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 0.5px solid var(--border); white-space: nowrap; }
.log-table td { padding: 10px 12px; border-bottom: 0.5px solid var(--border); color: var(--text); }
.log-table tr:last-child td { border-bottom: none; }
.log-table tbody tr:hover td { background: var(--surface2); }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }
.badge-gray { background: var(--surface2); color: var(--text2); }

/* Meal grid */
.meal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.meal-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; transition: border-color 0.15s; }
.meal-card:hover { border-color: var(--border-strong); }
.meal-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.meal-name { font-size: 15px; font-weight: 500; color: var(--text); line-height: 1.3; }
.meal-macros { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.macro-tag { background: var(--surface2); padding: 2px 7px; border-radius: 4px; font-size: 11px; color: var(--text2); }
.macro-tag.protein { background: var(--green-bg); color: var(--green); }
.meal-notes { font-size: 11px; color: var(--text3); line-height: 1.4; }
.meal-ingredients { margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border); }
.meal-ingredient-item { font-size: 12px; color: var(--text2); padding: 2px 0; display: flex; justify-content: space-between; }

/* Food database */
.food-search-bar { margin-bottom: 12px; }
.food-search-bar input { width: 100%; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; color: var(--text); font-family: inherit; }
.food-search-bar input:focus { outline: none; border-color: var(--border-strong); }
.food-item { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; transition: border-color 0.15s; }
.food-item:hover { border-color: var(--border-strong); }
.food-item-left { flex: 1; min-width: 0; }
.food-item-name { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.food-item-serving { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.food-item-macros { display: flex; gap: 6px; flex-wrap: wrap; }

/* Ingredient builder */
.add-ingredient-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.add-ingredient-row input { background: var(--surface2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; color: var(--text); font-family: inherit; }
.ingredient-list-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface2); border-radius: var(--radius); margin-bottom: 6px; font-size: 13px; }
.ingredient-list-item-macros { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Macro preview */
.macro-preview { background: var(--surface2); border-radius: var(--radius); padding: 12px 14px; }
.preview-title { font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.preview-macros { display: flex; gap: 10px; flex-wrap: wrap; }
.preview-macro { display: flex; flex-direction: column; }
.preview-macro-value { font-size: 18px; font-weight: 600; color: var(--text); line-height: 1.1; }
.preview-macro-label { font-size: 11px; color: var(--text3); }

/* Date nav */
.date-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.date-display { font-size: 15px; font-weight: 500; color: var(--text); min-width: 140px; text-align: center; }

/* Food log */
.meal-type-block { margin-bottom: 14px; }
.meal-type-header { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 0 6px; border-bottom: 0.5px solid var(--border); margin-bottom: 8px; }
.food-log-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; gap: 12px; }
.food-log-item-left { flex: 1; min-width: 0; }
.food-log-item-name { font-size: 14px; font-weight: 500; color: var(--text); }
.food-log-item-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.food-log-item-cals { font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; }
.daily-macro-row { display: flex; gap: 20px; flex-wrap: wrap; }
.daily-macro { display: flex; flex-direction: column; }
.daily-macro-value { font-size: 22px; font-weight: 600; color: var(--text); line-height: 1.1; }
.daily-macro-label { font-size: 11px; color: var(--text3); }

/* Delete btn */
.delete-btn { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; flex-shrink: 0; transition: color 0.15s; }
.delete-btn:hover { color: var(--red); }

/* Empty state */
.empty-state { text-align: center; padding: 36px 16px; color: var(--text3); font-size: 14px; }

/* Category tabs */
.category-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.category-tab { padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 500; border: 0.5px solid var(--border); background: var(--surface); color: var(--text2); cursor: pointer; transition: all 0.15s; font-family: inherit; }
.category-tab:hover { border-color: var(--border-strong); color: var(--text); }
.category-tab.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.food-category-group { margin-bottom: 20px; }
.food-category-heading { font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 0.5px solid var(--border); }

/* Searchable dropdown */
.search-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 0.5px solid var(--border-strong); border-radius: var(--radius); z-index: 100; max-height: 220px; overflow-y: auto; box-shadow: 0 4px 16px rgba(0,0,0,0.10); margin-top: 2px; }
.search-dropdown.open { display: block; }
.dropdown-item { padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--text); border-bottom: 0.5px solid var(--border); line-height: 1.3; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.dropdown-empty { padding: 12px 14px; font-size: 13px; color: var(--text3); }

/* Leaderboard */
.lb-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 10px; display: flex; align-items: center; gap: 16px; }
.lb-rank { font-size: 22px; font-weight: 700; color: var(--text3); min-width: 36px; }
.lb-rank.gold   { color: #B8860B; }
.lb-rank.silver { color: #888; }
.lb-rank.bronze { color: #8B5E3C; }
.lb-info { flex: 1; }
.lb-name { font-size: 15px; font-weight: 600; color: var(--text); }
.lb-detail { font-size: 12px; color: var(--text2); margin-top: 2px; }
.lb-stat { text-align: right; }
.lb-stat-value { font-size: 20px; font-weight: 700; color: var(--text); }
.lb-stat-label { font-size: 11px; color: var(--text3); }
.lb-progress-wrap { background: var(--surface2); border-radius: 99px; height: 5px; margin-top: 8px; overflow: hidden; }
.lb-progress-fill { height: 100%; border-radius: 99px; background: var(--green); }

/* Goals / Phase */
.phase-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.phase-title { font-size: 18px; font-weight: 600; color: var(--text); }
.phase-dates { font-size: 12px; color: var(--text3); margin-top: 3px; }
.phase-badge { padding: 4px 14px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.phase-badge.active   { background: var(--green-bg); color: var(--green); }
.phase-badge.upcoming { background: var(--surface2);  color: var(--text2); }
.phase-badge.complete { background: var(--blue-bg);   color: var(--blue);  }
.phase-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 12px; }
.phase-card.is-active   { border-color: var(--green); border-width: 1.5px; }
.phase-card.is-complete { opacity: 0.75; }
.phase-progress-wrap { background: var(--surface2); border-radius: 99px; height: 6px; margin: 10px 0 6px; overflow: hidden; }
.phase-progress-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.phase-progress-fill.green { background: var(--green); }
.phase-progress-fill.blue  { background: var(--blue);  }
.phase-progress-fill.amber { background: #EF9F27;       }
.phase-meta { font-size: 12px; color: var(--text3); display: flex; justify-content: space-between; }
.targets-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.target-cell { background: var(--surface2); border-radius: var(--radius); padding: 10px 12px; }
.target-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.target-range { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.1; }
.target-unit  { font-size: 11px; color: var(--text3); }
.target-actual { font-size: 11px; margin-top: 4px; padding-top: 4px; border-top: 0.5px solid var(--border); }
.target-actual.on-track  { color: var(--green); }
.target-actual.off-track { color: var(--red); }
.target-actual.no-data   { color: var(--text3); }
.week-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.week-cell { background: var(--surface2); border-radius: var(--radius); padding: 10px 12px; }
.week-cell-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.week-cell-value { font-size: 18px; font-weight: 600; color: var(--text); }
.week-cell-sub   { font-size: 11px; color: var(--text3); margin-top: 1px; }
.milestone-list { display: flex; flex-direction: column; gap: 8px; }
.milestone-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius); border: 0.5px solid var(--border); background: var(--surface); font-size: 13px; }
.milestone-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.milestone-icon.hit      { background: var(--green-bg); }
.milestone-icon.upcoming { background: var(--surface2); }
.milestone-text { flex: 1; color: var(--text); }
.milestone-sub  { font-size: 11px; color: var(--text3); margin-top: 1px; }
.milestone-date { font-size: 11px; color: var(--text3); white-space: nowrap; }
.workout-plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.workout-day-card { background: var(--surface2); border-radius: var(--radius); padding: 12px 14px; }
.workout-day-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.workout-day-list  { font-size: 12px; color: var(--text2); line-height: 1.8; }
.day-dot { width: 28px; height: 28px; border-radius: 50%; font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; border: 0.5px solid var(--border); }
.day-dot.logged { background: var(--green); color: #fff; border-color: var(--green); }
.day-dot.today  { background: var(--surface); color: var(--text); border-color: var(--text); border-width: 1.5px; }
.day-dot.future { background: var(--surface2); color: var(--text3); }
.day-dot.missed { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.day-tracker-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 10px; }

.stay-signed-in-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; font-size: 13px; color: var(--text2); }
.stay-signed-in-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Daily goals checklist */
.card-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; }
.card-date { font-size: 12px; color: var(--text3); }

.goal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 0.5px solid var(--border);
}
.goal-item:last-child { border-bottom: none; }
.goal-check {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); background: transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; position: relative;
}
.goal-check.checked { background: var(--green); border-color: var(--green); }
.goal-check.checked::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 700; }
.goal-check.auto-checked { background: var(--green); border-color: var(--green); cursor: default; }
.goal-check.auto-checked::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 700; }
.goal-check.partial { background: var(--amber-bg); border-color: var(--amber); cursor: default; }
.goal-check.partial::after { content: '~'; color: var(--amber); font-size: 14px; font-weight: 700; }
.goal-item-text { flex: 1; }
.goal-item-label { font-size: 14px; color: var(--text); font-weight: 500; }
.goal-item-label.done { color: var(--text3); text-decoration: line-through; }
.goal-item-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.goal-item-sub.on-track  { color: var(--green); }
.goal-item-sub.off-track { color: var(--red); }
.goal-progress-mini { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.goal-progress-mini-bar { flex: 1; height: 4px; background: var(--surface2); border-radius: 99px; overflow: hidden; max-width: 120px; }
.goal-progress-mini-fill { height: 100%; border-radius: 99px; background: var(--green); transition: width 0.3s; }
.goals-summary { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--border); }
.goals-summary-pct { font-size: 22px; font-weight: 700; color: var(--text); }
.goals-summary-label { font-size: 12px; color: var(--text3); }

/* Habit management */
.habit-list { display: flex; flex-direction: column; gap: 0; }
.habit-manage-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 0.5px solid var(--border); font-size: 14px;
}
.habit-manage-item:last-child { border-bottom: none; }
.habit-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.habit-manage-name { flex: 1; font-weight: 500; color: var(--text); }
.habit-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.habit-add-row input {
  background: var(--surface2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  font-size: 13px; color: var(--text); font-family: inherit;
}

/* Competition banner */
.comp-banner {
  border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--purple-bg), var(--blue-bg));
  border: 1px solid var(--purple);
}
.comp-banner.comp-banner-upcoming {
  background: linear-gradient(135deg, var(--amber-bg), var(--surface2));
  border-color: var(--amber);
}
.comp-banner-icon { font-size: 28px; flex-shrink: 0; }
.comp-banner-info { flex: 1; min-width: 0; }
.comp-banner-title { font-size: 15px; font-weight: 600; color: var(--text); }
.comp-banner-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.comp-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Competition cards */
.comp-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 14px;
}
.comp-card.active-comp { border-color: var(--purple); border-width: 1.5px; }
.comp-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.comp-title { font-size: 16px; font-weight: 600; color: var(--text); }
.comp-meta { font-size: 12px; color: var(--text3); margin-top: 3px; }
.comp-desc { font-size: 13px; color: var(--text2); margin-bottom: 14px; line-height: 1.5; }
.comp-status-badge { padding: 4px 12px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.comp-status-badge.active   { background: var(--purple-bg); color: var(--purple); }
.comp-status-badge.upcoming { background: var(--surface2); color: var(--text2); }
.comp-status-badge.ended    { background: var(--blue-bg);   color: var(--blue); }

/* Competition leaderboard */
.comp-lb-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}
.comp-lb-row:last-child { border-bottom: none; }
.comp-lb-rank { font-size: 16px; font-weight: 700; min-width: 28px; color: var(--text3); }
.comp-lb-rank.gold   { color: #B8860B; }
.comp-lb-rank.silver { color: #888; }
.comp-lb-rank.bronze { color: #8B5E3C; }
.comp-lb-name  { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }
.comp-lb-value { font-size: 16px; font-weight: 700; color: var(--text); text-align: right; }
.comp-lb-unit  { font-size: 11px; color: var(--text3); text-align: right; }
.comp-progress-wrap { height: 5px; background: var(--surface2); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.comp-progress-fill { height: 100%; background: var(--purple); border-radius: 99px; transition: width 0.4s; }
.comp-section-label { font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin: 14px 0 8px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: flex; align-items: flex-start;
  justify-content: center; padding: 20px; overflow-y: auto;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 0.5px solid var(--border); padding: 24px 24px 20px;
  width: 100%; max-width: 700px; margin: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.modal-header h3 { font-size: 17px; font-weight: 600; color: var(--text); }
.pm-add-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; align-items: flex-start;
}
.pm-add-row input {
  background: var(--surface2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px;
  font-size: 13px; color: var(--text); font-family: inherit; min-width: 80px;
}
.pm-list-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 12px; background: var(--surface2);
  border-radius: var(--radius); margin-bottom: 6px; gap: 10px; font-size: 13px;
}
.pm-list-item-text { flex: 1; line-height: 1.4; }
.pm-list-item-sub  { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Goals section header row */
.goals-section-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.goals-section-header h2 { font-size: 18px; font-weight: 500; }
.phase-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.phase-edit-btn {
  background: none; border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 4px 10px; font-size: 12px; color: var(--text2); cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.phase-edit-btn:hover { background: var(--surface2); color: var(--text); }
.phase-edit-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* Settings / Privacy */
.privacy-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.privacy-info { flex: 1; }
.privacy-label { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.privacy-sub { font-size: 12px; color: var(--text3); line-height: 1.5; }
.toggle-btn {
  position: relative; width: 48px; height: 28px; border-radius: 99px;
  border: none; cursor: pointer; flex-shrink: 0;
  background: var(--surface2); border: 0.5px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}
.toggle-btn.on { background: var(--green); border-color: var(--green); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text3); transition: transform 0.2s, background 0.2s;
  display: block;
}
.toggle-btn.on .toggle-knob { transform: translateX(20px); background: #fff; }

@media (max-width: 600px) {
  .app { padding: 0 12px 80px; }
  .app-title { font-size: 20px; }
  .metric-value { font-size: 22px; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .nav-btn { padding: 5px 9px; font-size: 12px; }
  .meal-grid { grid-template-columns: 1fr; }
  .workout-plan-grid { grid-template-columns: 1fr; }
  .auth-box { padding: 24px 20px; }
}