:root {
  --bg: #0f1220;
  --panel: #1a1e33;
  --panel2: #212745;
  --accent: #7c5cff;
  --accent2: #ff5c9e;
  --green: #3ddc97;
  --yellow: #ffcb47;
  --red: #ff5c5c;
  --text: #eef0fa;
  --muted: #9aa0c3;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top, #1b1f3b, #0f1220 60%);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 60px;
}
.wrap { max-width: 760px; margin: 0 auto; }

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.title-block h1 {
  margin: 0;
  font-size: 26px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title-block p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.level-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.level-badge {
  width: 44px; height: 44px; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--lvl-pct, 40%), #2a2f52 0);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.level-badge span { background: var(--panel); width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.level-meta { flex: 1; }
.level-meta .lvl-label { font-size: 12px; color: var(--muted); }
.xp-bar-track { height: 6px; background: #2a2f52; border-radius: 4px; margin-top: 4px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width .4s ease; }
.streak-pill {
  display: flex; align-items: center; gap: 4px;
  background: var(--panel2); padding: 6px 10px; border-radius: 20px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel2); padding: 6px 10px 6px 6px; border-radius: 20px;
  font-size: 12.5px; color: var(--muted);
}
.user-chip img { width: 24px; height: 24px; border-radius: 50%; }
.user-chip button {
  background: none; border: none; color: var(--red); cursor: pointer; font-size: 12px; padding: 0;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}
.card h2 { margin: 0 0 12px; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card h2 small { color: var(--muted); font-weight: 400; font-size: 12px; }

.goals-row { display: flex; gap: 10px; flex-wrap: wrap; }
.goal-input { flex: 1; min-width: 90px; }
.goal-input label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%;
  background: var(--panel2);
  border: 1px solid #333a63;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.progress-item .p-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; color: var(--muted); }
.progress-item .p-label b { color: var(--text); }
.progress-track { height: 10px; background: #2a2f52; border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.fill-cal { background: linear-gradient(90deg,#7c5cff,#ff5c9e); }
.fill-protein { background: linear-gradient(90deg,#3ddc97,#2bb77c); }
.fill-carb { background: linear-gradient(90deg,#ffcb47,#ff9d47); }

.entry-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.entry-form input { flex: 1; min-width: 80px; }
.entry-form input.name-field { min-width: 140px; flex: 2; }
.btn {
  border: none; border-radius: 8px; padding: 9px 16px; font-weight: 600;
  cursor: pointer; font-size: 13.5px; transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: white; }
.btn-ghost { background: var(--panel2); color: var(--text); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: white; color: #1f1f1f; width: 100%; padding: 12px 16px; font-size: 15px;
}
.btn-google img { width: 20px; height: 20px; }

.save-preset-row { display: flex; justify-content: flex-end; margin-bottom: 14px; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.preset-chip {
  background: var(--panel2); border: 1px solid #333a63; color: var(--text);
  padding: 6px 12px; border-radius: 20px; font-size: 12.5px; cursor: pointer;
}
.preset-chip:hover { border-color: var(--accent); }
.preset-chip .del { color: var(--red); margin-left: 6px; cursor: pointer; }

table.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.log-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; padding-bottom: 6px; }
table.log-table td { padding: 6px 0; border-top: 1px solid #2a2f52; }
table.log-table td.num { text-align: right; }
table.log-table .del-btn { color: var(--red); cursor: pointer; font-size: 12px; background: none; border: none; }
.empty-note { color: var(--muted); font-size: 13px; padding: 6px 0; }

.badges-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  width: 78px; text-align: center; font-size: 11px; color: var(--muted);
  opacity: 0.35; filter: grayscale(1);
}
.badge.unlocked { opacity: 1; filter: none; color: var(--text); }
.badge .icon { font-size: 26px; display: block; margin-bottom: 4px; }

.history-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid #2a2f52; font-size: 13px; }
.history-row .date { width: 90px; color: var(--muted); flex-shrink: 0; }
.history-row .bar-wrap { flex: 1; height: 8px; background: #2a2f52; border-radius: 5px; overflow: hidden; }
.history-row .bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.history-row .cal-val { width: 90px; text-align: right; color: var(--muted); flex-shrink: 0; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px; opacity: 0;
  transition: all .3s ease; pointer-events: none; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.section-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.section-toggle button {
  flex: 1; background: var(--panel); border: 1px solid #2a2f52; color: var(--muted);
  padding: 10px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.section-toggle button.active { background: var(--panel2); color: var(--text); border-color: var(--accent); }
.hidden { display: none; }

/* Welcome page */
.welcome-wrap {
  max-width: 420px; margin: 12vh auto 0; text-align: center;
}
.welcome-wrap h1 {
  font-size: 34px; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.welcome-wrap p.tagline { color: var(--muted); margin-bottom: 32px; font-size: 15px; }
.welcome-card { background: var(--panel); border-radius: var(--radius); padding: 28px 24px; box-shadow: 0 8px 30px rgba(0,0,0,0.35); }
.welcome-card ul { text-align: left; color: var(--muted); font-size: 13.5px; margin: 18px 0 26px; padding-left: 20px; line-height: 1.7; }
.welcome-status { margin-top: 14px; font-size: 12.5px; color: var(--muted); min-height: 16px; }

::placeholder { color: #6d75a0; }
