/* ============================================================
   Health Tracker — Design System
   Fonts: Syne (headings) + DM Sans (body) — Google Fonts
   ============================================================ */

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

:root {
  /* Palette */
  --bg:         #09090f;
  --bg2:        #111118;
  --bg3:        #18181f;
  --bg4:        #1e1e28;
  --border:     rgba(255,255,255,0.06);
  --border2:    rgba(255,255,255,0.12);
  --text:       #f0f0f8;
  --muted:      rgba(240,240,248,0.45);
  --muted2:     rgba(240,240,248,0.25);

  /* Brand */
  --accent:     #7c5cff;
  --accent2:    #a78bfa;
  --warn:        #fb923c;
  --accent-glow:rgba(124,92,255,0.18);

  /* Semantic */
  --green:      #4ade80;
  --green-dim:  rgba(74,222,128,0.15);
  --red:        #f87171;
  --red-dim:    rgba(248,113,113,0.15);
  --blue:       #60a5fa;
  --blue-dim:   rgba(96,165,250,0.15);
  --orange:     #fb923c;
  --orange-dim: rgba(251,146,60,0.15);
  --cyan:       #22d3ee;
  --cyan-dim:   rgba(34,211,238,0.15);
  --purple-dim: rgba(167,139,250,0.15);

  /* Exercise type colours */
  --ex-walking:  #4ade80;
  --ex-running:  #f87171;
  --ex-gym:      #a78bfa;
  --ex-cycling:  #60a5fa;
  --ex-yoga:     #fb923c;
  --ex-swimming: #22d3ee;
  --ex-other:    #e879f9;

  /* Typography */
  --font-h: 'Plus Jakarta Sans', sans-serif;
  --font-b: 'DM Sans', sans-serif;
  --font-m: 'JetBrains Mono', 'DM Mono', monospace;

  /* Spacing */
  --radius:   14px;
  --radius-s:  8px;
  --sidebar-w: 220px;
}

/* ── Base ─────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 99px; }

/* ── Auth Overlay ─────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 2.5rem;
}
.auth-logo {
  text-align: center;
  font-family: var(--font-h);
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}
.auth-logo span { color: var(--accent2); }
.auth-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg3);
  border-radius: var(--radius-s);
  padding: 4px;
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--accent);
  color: #fff;
}
.auth-error {
  background: var(--red-dim);
  border: 1px solid rgba(248,113,113,0.25);
  color: var(--red);
  border-radius: var(--radius-s);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.auth-error.visible { display: block; }

/* ── App Shell ────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Sidebar is position:fixed — no grid needed.
   main-content just clears the fixed sidebar with margin-left. */
.app-grid { min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  z-index: 50;
  overflow-y: auto;
}
.sidebar-logo {
  font-family: var(--font-h);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  padding: 0 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sidebar-logo span { color: var(--accent2); }
.sidebar-logo small {
  display: block;
  font-family: var(--font-b);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  margin-top: 2px;
  white-space: nowrap;
}
.nav-group { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0.6rem 0.75rem;
  border: none; border-radius: var(--radius-s);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active {
  background: var(--accent-glow);
  color: var(--accent2);
  border: 1px solid rgba(124,92,255,0.2);
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 0.5rem 0.75rem;
  background: var(--bg3);
  border-radius: var(--radius-s);
  margin-bottom: 0.5rem;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  color: var(--accent2);
  font-weight: 700;
}
.user-name { font-size: 0.8rem; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  width: 100%; padding: 0.5rem;
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-logout:hover { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,0.25); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 2rem 2.5rem;
  min-height: 100vh;
  box-sizing: border-box;
  width: calc(100% - var(--sidebar-w));
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title {
  font-family: var(--font-h);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.25rem;
}
.page-title span { color: var(--accent2); }
.page-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.75rem;
}

/* ── Cards ────────────────────────────────────────────────── */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border2); }
.card-icon {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
  display: block;
}
.card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.card-value {
  font-family: var(--font-h);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.card-value sup {
  font-size: 0.55em;
  font-weight: 500;
  margin-left: 3px;
  color: var(--muted);
  font-family: var(--font-b);
  vertical-align: baseline;  /* override browser default 'super' */
  letter-spacing: 0;
}
.card-change {
  font-size: 0.78rem;
  margin-top: 0.4rem;
  font-weight: 500;
}
.card-change.up   { color: var(--green); }
.card-change.down { color: var(--red); }
.card-change.same { color: var(--muted); }

.card-accent-line {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover .card-accent-line { opacity: 1; }

/* ── Two-column grid ──────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.two-col .card { margin: 0; }

/* ── Section panels ───────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.panel-title {
  font-family: var(--font-h);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel-sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ── Range tabs (7D / 30D / 90D / All) ───────────────────── */
.range-tabs {
  display: flex; gap: 4px;
  background: var(--bg3);
  border-radius: 8px;
  padding: 3px;
}
.range-tab {
  padding: 0.3rem 0.65rem;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.range-tab.active { background: var(--accent); color: #fff; }

/* ── Forms ────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }
label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 0.9rem;
  padding: 0.65rem 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--muted2); }
select option { background: var(--bg3); }
textarea { resize: vertical; min-height: 72px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0.7rem 1.4rem;
  border: none; border-radius: var(--radius-s);
  font-family: var(--font-b);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,92,255,0.3); }
.btn-primary:active { transform: none; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--red-dim); border: 1px solid rgba(248,113,113,0.25); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,0.25); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* Submit buttons inside forms get breathing room from the last field */
form > .btn { margin-top: 1.25rem; }

/* ── Chart canvas wrapper ─────────────────────────────────── */
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100% !important; }

/* ── Exercise type chips ──────────────────────────────────── */
.type-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1rem; }
.type-chip {
  padding: 0.35rem 0.9rem;
  border-radius: 99px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-b);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.type-chip:hover { border-color: var(--accent); color: var(--accent2); }
.type-chip.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }

/* ── Sessions list ────────────────────────────────────────── */
.sessions-list { display: flex; flex-direction: column; gap: 6px; }
.session-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0.65rem 0.85rem;
  background: var(--bg3);
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  transition: border-color 0.18s;
}
.session-item:hover { border-color: var(--border2); }
.session-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.session-info { flex: 1; }
.session-type { font-size: 0.85rem; font-weight: 600; text-transform: capitalize; }
.session-meta { font-size: 0.75rem; color: var(--muted); }
.session-date { font-size: 0.75rem; color: var(--muted2); margin-left: auto; margin-right: 0.5rem; }

/* ── Hydration glasses ────────────────────────────────────── */
.glasses-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 1rem 0;
}
.glass-btn {
  width: 54px; height: 66px;
  border-radius: 8px;
  border: 2px solid var(--border2);
  background: var(--bg3);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 1.5rem;
  transition: all 0.18s;
  position: relative;
}
.glass-btn:hover { border-color: var(--blue); transform: translateY(-2px); }
.glass-btn.filled {
  background: var(--blue-dim);
  border-color: var(--blue);
  box-shadow: 0 0 12px rgba(96,165,250,0.15);
}
.glass-num {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-b);
}
.glass-btn.filled .glass-num { color: var(--blue); }

.hydration-summary {
  display: flex; align-items: baseline; gap: 0.5rem;
  margin-bottom: 1rem;
}
.hydration-count {
  font-family: var(--font-h);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--blue);
}
.hydration-target { font-size: 1rem; color: var(--muted); }

/* ── Vitals table ─────────────────────────────────────────── */
.vitals-list { display: flex; flex-direction: column; gap: 6px; }
.vital-item {
  display: flex; align-items: center; gap: 12px;
  padding: 0.7rem 0.9rem;
  background: var(--bg3);
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
}
.vital-date { font-size: 0.8rem; color: var(--muted); width: 80px; flex-shrink: 0; }
.vital-values { flex: 1; display: flex; gap: 16px; flex-wrap: wrap; }
.vital-badge {
  font-size: 0.82rem; font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--red-dim);
  color: var(--red);
}
.vital-badge.hr { background: var(--green-dim); color: var(--green); }

/* ── Goals progress ───────────────────────────────────────── */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.goal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.goal-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.5rem; }
.goal-values { display: flex; align-items: baseline; gap: 6px; margin-bottom: 0.75rem; }
.goal-current { font-family: var(--font-h); font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.goal-target { font-size: 0.85rem; color: var(--muted); }
.progress-bar-bg {
  height: 6px; border-radius: 99px;
  background: var(--bg4);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.progress-bar-fill.good { background: linear-gradient(90deg, var(--green), #86efac); }
.progress-bar-fill.warn { background: linear-gradient(90deg, var(--orange), #fcd34d); }

/* ── Stat pills ───────────────────────────────────────────── */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
}
.stat-pill strong { color: var(--text); font-weight: 700; }
.stat-pill span { color: var(--muted); margin-left: 4px; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Toast notification ───────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  padding: 0.75rem 1.1rem;
  font-size: 0.85rem;
  z-index: 200;
  transform: translateY(10px); opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
}
#toast.show { transform: none; opacity: 1; }
#toast.success { border-color: rgba(74,222,128,0.3); color: var(--green); }
#toast.error { border-color: rgba(248,113,113,0.3); color: var(--red); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .nav-btn .nav-label { display: none; }
  .nav-btn { justify-content: center; }
  .sidebar-logo small,
  .sidebar-logo .logo-text,
  .user-name,
  .btn-logout { display: none; }
  .sidebar-logo { padding-bottom: 1rem; text-align: center; }
  .sidebar-footer { padding-top: 0.5rem; }
  .user-chip { justify-content: center; }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    position: fixed; bottom: 0; top: auto;
    width: 100%; height: 60px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0.5rem 0.5rem;
    overflow: visible;
  }
  .sidebar-logo, .sidebar-footer, .user-chip, .btn-logout { display: none; }
  .nav-group { flex-direction: row; align-items: center; justify-content: space-around; width: 100%; gap: 0; }
  .nav-btn { flex-direction: column; gap: 2px; padding: 0.3rem 0.5rem; font-size: 0.65rem; }
  .nav-btn .nav-label { display: block !important; font-size: 0.6rem; }
  .nav-icon { font-size: 1.1rem; }
  .main-content { margin-left: 0; width: 100%; padding: 1.25rem 1rem 80px; }
  .two-col { grid-template-columns: 1fr; }
  .form-row  { grid-template-columns: 1fr; }
}

/* ── Page header row (title + export btn) ────────────────── */
.page-header-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.page-header-row .page-title { margin-bottom: 0.25rem; }
.page-header-row .page-sub   { margin-bottom: 0; }
.export-row { display: flex; align-items: center; gap: 8px; padding-top: 0.5rem; }

/* ── BMI badge on dashboard weight card ──────────────────── */
.card-bmi {
  font-size: 0.75rem;
  margin-top: 4px;
  color: var(--muted);
}
.card-bmi strong { color: var(--text); }
.card-bmi a { color: var(--accent2); text-decoration: none; font-size: 0.72rem; }
.bmi-cat { padding: 1px 7px; border-radius: 99px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; }
.bmi-normal      { background: rgba(74,222,128,0.15);  color: #4ade80; }
.bmi-underweight { background: rgba(96,165,250,0.15);  color: #60a5fa; }
.bmi-overweight  { background: rgba(251,146,60,0.15);  color: #fb923c; }
.bmi-obese       { background: rgba(248,113,113,0.15); color: #f87171; }

/* -- Calendar heatmap (compact GitHub-style) ---------------- */
.heatmap-outer {
  display: flex;
  gap: 4px;
  width: 100%;
  padding: 0.25rem 0 0.5rem;
}
.heatmap-dow {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  height: 80px;
  gap: 3px;
  flex-shrink: 0;
}
.heatmap-dow-label {
  height: auto;
  line-height: 1;
  font-size: 8.5px;
  color: var(--muted);
  text-align: right;
  padding-right: 3px;
  width: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  flex: 1;
  height: 80px;
}
.heat-cell {
  border-radius: 2px;
  transition: transform 0.1s;
  cursor: default;
  min-width: 8px;
}
.heat-cell:hover { transform: scale(1.15); }
.heat-empty { background: transparent; }
.heat-0 { background: var(--bg3); }
.heat-1 { background: rgba(124,92,255,0.28); }
.heat-2 { background: rgba(124,92,255,0.58); }
.heat-3 { background: rgba(124,92,255,0.92); }
.heatmap-legend {
  display: flex; align-items: center; gap: 4px; justify-content: flex-end;
  margin-top: 8px;
  font-size: 0.68rem; color: var(--muted);
}
.heatmap-legend .heat-cell { width: 10px; height: 10px; min-width: 10px; }

/* Compact heatmap panel */
.panel--heatmap { padding: 1rem 1.25rem 0.75rem; }

/* Clickable goal cards */
.goal-card--link { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.goal-card--link:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.goal-card--link:active { transform: none; }
.goal-card-icon { font-size: 1.25rem; margin-bottom: 0.25rem; }
.goal-note { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }


/* -- Inline edit form (exercise rows) ----------------------- */
.inline-edit-form {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  padding: 0.9rem 1rem;
  margin-bottom: 4px;
}
.inline-edit-form .form-row { grid-template-columns: repeat(3,1fr); gap: 0.5rem; }
.inline-edit-form .form-group { margin-bottom: 0.4rem; }
/* Ensure inline-edit inputs look identical to normal form inputs */
.inline-edit-form input,
.inline-edit-form select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.75rem;
  font-family: var(--font-b), sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}
.inline-edit-form input:focus,
.inline-edit-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.15);
}
.inline-edit-form label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

/* -- BMI panel in settings ---------------------------------- */
/* Inline inside the Body Settings panel — no extra card */
.settings-body-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-top: 0.25rem;
}
.settings-body-form {
  flex-shrink: 0;
  width: 180px;
}
.settings-bmi-col {
  flex: 1;
  min-width: 0;
  border-left: 1px solid var(--border2);
  padding-left: 1.5rem;
}
.bmi-panel {          /* no extra card chrome — inherits from parent panel */
  padding: 0;
  margin-top: 0;
}
.bmi-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.bmi-big-val {
  font-family: var(--font-h), sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.bmi-meta { font-size: 0.73rem; color: var(--muted); margin-top: 3px; }
.bmi-scale { position: relative; padding-bottom: 1.4rem; margin-bottom: 0.6rem; }
.bmi-bar {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
}
.bmi-bar > div { height: 100%; transition: opacity 0.2s; }
.bmi-bar > div:hover { opacity: 0.85; }
.bmi-needle {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  pointer-events: none;
}
.bmi-needle-pin {
  width: 2px;
  height: 13px;
  background: var(--text);
  margin: 0 auto;
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.bmi-needle-val {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-top: 2px;
  white-space: nowrap;
}
.bmi-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.bmi-legend-item { display: flex; flex-direction: column; gap: 2px; }
.bmi-legend-dot  { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.bmi-legend-range { font-size: 0.68rem; color: var(--muted); }
.bmi-legend-name  { font-size: 0.73rem; color: var(--text); font-weight: 500; }
.bmi-hint { font-size: 0.8rem; color: var(--muted); padding-top: 0.6rem; border-top: 1px solid var(--border); }
.bmi-hint.good { color: var(--green); }
.settings-hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.75rem; }

/* ── Token management UI ─────────────────────────────────── */

.token-reveal {
  background: rgba(251,146,60,0.08);
  border: 1px solid rgba(251,146,60,0.25);
  border-radius: var(--radius-s);
  padding: 1rem;
  margin-bottom: 1rem;
}
.token-reveal-label {
  font-size: 0.8rem; font-weight: 600; color: #fb923c;
  margin-bottom: 0.6rem;
}
.token-code {
  background: var(--bg); color: #a78bfa;
  font-family: var(--font-m); font-size: 0.75rem;
  padding: 6px 10px; border-radius: 6px;
  word-break: break-all; flex: 1;
  border: 1px solid var(--border2);
}

/* ── Export buttons grid ─────────────────────────────────── */
.export-buttons {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.export-buttons .btn { flex: 0 0 auto; }

/* ── Code block (settings) ───────────────────────────────── */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  font-family: var(--font-m);
  font-size: 0.78rem;
  color: #a78bfa;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.7;
}


/* ══════════════════════════════════════════════════════════════
   Welcome / Onboarding overlay
   ══════════════════════════════════════════════════════════════ */
@keyframes welcomeCardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(9,9,15,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: overlayIn 0.25s ease;
}
.welcome-overlay.hidden { display: none !important; }

.welcome-card {
  background: var(--bg2);
  border: 1px solid rgba(124,92,255,0.35);
  border-radius: 20px;
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
  box-shadow:
    0 0 0 1px rgba(124,92,255,0.1),
    0 0 60px rgba(124,92,255,0.12),
    0 32px 64px rgba(0,0,0,0.55);
  animation: welcomeCardIn 0.4s cubic-bezier(0.16,1,0.3,1);
}

/* Hero */
.welcome-hero { text-align: center; margin-bottom: 2rem; }
.welcome-emoji { font-size: 3rem; line-height: 1; margin-bottom: 0.6rem; }
.welcome-title {
  font-family: var(--font-h), sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}
.welcome-title span { color: var(--accent2); }
.welcome-sub {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

/* Sections */
.welcome-section { margin-bottom: 1.5rem; }
.welcome-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* Optional badge */
.welcome-optional {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 3px;
}

/* Input + unit */
.welcome-input-unit {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--bg);
}
.welcome-input-unit input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-family: var(--font-b), sans-serif;
  font-size: 0.9rem;
  outline: none;
  min-width: 0;
}
.welcome-input-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.15);
}
.welcome-input-unit span {
  background: var(--bg3);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0 0.75rem;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border2);
  white-space: nowrap;
}

/* Hint text */
.welcome-hint { font-size: 0.72rem; color: var(--muted); margin-top: 5px; }

/* Actions */
.welcome-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════
   Confirm dialog (replaces browser confirm())
   ══════════════════════════════════════════════════════════════ */
@keyframes confirmIn {
  from { opacity: 0; transform: scale(0.93) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(9,9,15,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: overlayIn 0.18s ease;
}
.confirm-backdrop.hidden { display: none !important; }

.confirm-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 2rem 2rem 1.5rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  animation: confirmIn 0.22s cubic-bezier(0.16,1,0.3,1);
}

.confirm-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.confirm-title {
  font-family: var(--font-h);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.confirm-msg {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

.confirm-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

/* Danger variant */
.confirm-card.danger .confirm-icon { filter: grayscale(0); }
.confirm-card.danger #confirm-ok {
  background: rgba(248,113,113,0.15);
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.3);
}
.confirm-card.danger #confirm-ok:hover {
  background: rgba(248,113,113,0.25);
}

/* ── Empty state CTA (inside chart containers) ───────────────── */
.empty-state-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  height: 100%;
  min-height: 120px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

/* ── v3: Tag chips ───────────────────────────────────────────── */
.tag-chip {
  display: inline-block;
  padding: 1px 8px;
  background: rgba(124,92,255,0.15);
  border: 1px solid rgba(124,92,255,0.3);
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--accent2);
  margin: 2px 2px 0 2px;
  font-family: var(--font-m);
  letter-spacing: 0.02em;
}

/* Editable chip variant (inside TagInput widget) */
.tag-chip--rm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  cursor: default;
  user-select: none;
}
.tag-chip-rm {
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.7;
  transition: opacity 0.12s;
}
.tag-chip-rm:hover { opacity: 1; }

/* ── v3: TagInput widget wrapper ─────────────────────────────── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  cursor: text;
  min-height: 42px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124,92,255,0.15);
}

/* The live text input inside the widget */
.tag-text-input {
  flex: 1;
  min-width: 80px;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-b);
  padding: 2px 0;
  line-height: 1.4;
}
.tag-text-input::placeholder { color: var(--muted2); }

/* Dropdown */
.tag-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 100;
  overflow: hidden;
  animation: fadeIn 0.1s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tag-dropdown-item {
  padding: 8px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-m);
  transition: background 0.1s;
}
.tag-dropdown-item:hover { background: rgba(124,92,255,0.15); color: var(--accent2); }

/* ── v3: Search overlay ──────────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9,9,15,0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.search-panel {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-s);
  padding: 0 12px;
}
.search-icon { font-size: 1rem; opacity: 0.6; }
.search-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 0;
  font-family: var(--font-b);
}
/* Filters row: type pills + tag chips */
.search-filters-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px 4px;
  border-bottom: 1px solid var(--border2);
}
.search-type-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.search-type-pill {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 20px;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--font-m);
  padding: 3px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.search-type-pill:hover { border-color: var(--accent); color: var(--accent2); }
.search-type-pill.active {
  background: rgba(124,92,255,0.18);
  border-color: var(--accent);
  color: var(--accent2);
  font-weight: 600;
}
/* Tag chip filters in search */
.search-tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
}
.search-tag-chip {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 20px;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-m);
  padding: 2px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.search-tag-chip:hover { border-color: var(--accent); color: var(--accent2); }
.search-tag-chip.active {
  background: rgba(124,92,255,0.25);
  border-color: var(--accent);
  color: var(--accent2);
  font-weight: 600;
}
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.search-result-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg4); }
.search-result-icon { font-size: 1.2rem; padding-top: 2px; }
.search-result-body { flex: 1; min-width: 0; }
.search-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.search-result-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent2);
  background: rgba(124,92,255,0.12);
  padding: 1px 7px;
  border-radius: 20px;
}
.search-result-date { font-size: 0.8rem; color: var(--muted); }
.search-result-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.search-meta-kv {
  background: var(--bg4);
  padding: 1px 7px;
  border-radius: 4px;
  font-family: var(--font-m);
  font-size: 0.75rem;
}
.search-result-snippet {
  font-size: 0.85rem;
  color: rgba(240,240,248,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-tags { margin-top: 4px; }
.search-empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem;
}
mark {
  background: rgba(124,92,255,0.35);
  color: var(--accent2);
  border-radius: 2px;
  padding: 0 1px;
}

/* ── v3: Monthly calendar ────────────────────────────────────── */
.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 0;
}
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--bg4);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 4px;
  position: relative;
}
.cal-cell:hover { background: var(--bg3); border-color: var(--border2); transform: scale(1.04); }
.cal-cell--empty { background: transparent; border-color: transparent; cursor: default; pointer-events: none; }
.cal-cell--l1 { background: rgba(124,92,255,0.08); }
.cal-cell--l2 { background: rgba(124,92,255,0.18); }
.cal-cell--l3 { background: rgba(124,92,255,0.32); border-color: rgba(124,92,255,0.35); }
.cal-cell--today { border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent); }
.cal-day-num { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.cal-dots {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: 3px;
}
.cal-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }

/* Calendar drawer */
.cal-drawer {
  margin-bottom: 1rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cal-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.cal-drawer-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.cal-drawer-entry {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.88rem;
}
.cal-drawer-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ── v3: Danger zone ─────────────────────────────────────────── */
/* ── Tag Manager ─────────────────────────────────────────────── */
.tag-manager-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tag-manager-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: var(--radius-s);
  transition: background 0.12s;
}
.tag-manager-row:hover { background: var(--bg4); }
.tag-manager-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--font-m);
  min-width: 52px;
}
.tag-manager-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.tag-rename-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
}
.tag-rename-input {
  flex: 1;
  max-width: 220px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-b);
  padding: 5px 10px;
  outline: none;
}

.danger-zone {
  background: rgba(248,113,113,0.04);
  border: 1px solid rgba(248,113,113,0.15);
  border-radius: var(--radius-s);
  padding: 1rem;
}
.danger-zone-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--red);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── v3: Search btn in sidebar footer ───────────────────────── */
.btn-icon {
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--accent-glow); color: var(--text); border-color: var(--border2); }
