/* FitLife styles — v2 "Fresh Green" theme.
   Type: Space Grotesk for headlines and numbers, DM Sans for everything else.
   Colour: paper white/green with a deep-green + lime brand, amber/orange kept for streaks and "today".
   Layout is fluid (clamp()) AND has explicit desktop / tablet / mobile tiers — see the
   responsive section near the bottom for the three breakpoints: 1024px (tablet), 860px
   (tablet portrait / phablet) and 640px (phone). */

:root {
  --bg: #f4f9f5;
  --paper: #f4f9f5;
  --card: #ffffff;
  --ink: #16231d;
  --ink-2: #12332a;
  --muted: #66766d;
  --line: #e2ece5;
  --brand: #1a7554; /* was #1f8a63 (4.31:1 on white — fails WCAG AA for text); this hits 5.65:1 */
  --brand-deep: #12654a;
  --brand-soft: #dcf3e6;
  --lime: #c7ed63;
  --amber: #ff985c;
  --amber-deep: #8a3f1c;
  --amber-soft: #ffe6d5;
  --gold: #ffd166;
  --purple: #8067e8;
  --danger: #c0463c;
  --ok: #1f8a63;
  /* Fonts: if Google Fonts cannot load (offline, blocked), each stack falls back to something close. */
  --display: 'Space Grotesk', 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', 'Nirmala UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Noto Sans Devanagari', sans-serif;
  --sidebar-w: 250px;
  --radius: 18px;
  --radius-lg: 22px;
  --shadow: 0 14px 36px rgba(18, 51, 42, .09);
  --shadow-lg: 0 26px 64px rgba(15, 40, 27, .18);

  /* Fluid type scale: sizes grow smoothly with the screen instead of jumping at breakpoints. */
  --fs-xs: .8125rem;
  --fs-sm: .875rem;
  --fs-md: 1rem;
  --fs-lg: clamp(1.0625rem, 1.03rem + .15vw, 1.1875rem);
  --fs-h4: clamp(1.05rem, 1rem + .2vw, 1.15rem);
  --fs-h3-sm: clamp(1.2rem, 1.1rem + .4vw, 1.4rem);
  --fs-h3: clamp(1.35rem, 1.2rem + .6vw, 1.65rem);
  --fs-h2: clamp(2.1rem, 1.5rem + 2.2vw, 3rem);
  --fs-hero: clamp(2.3rem, 1.6rem + 2.8vw, 3.4rem);
  --fs-display: clamp(2.6rem, 1.4rem + 5.6vw, 5.2rem);
  --fs-num: clamp(2.3rem, 1.9rem + 1.4vw, 3rem);
  --fs-num-lg: clamp(3.2rem, 2.4rem + 3.4vw, 5.4rem);
  --space-page: clamp(16px, 2.4vw, 32px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 1rem; /* follows the browser's font-size setting */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  color: var(--ink);
  background: var(--paper);
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; }
h2, h3, h4 { font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
ul, ol { margin: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.gap-top { margin-top: 16px; }
.gap-bottom { margin-bottom: 16px; }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: .72rem 1.2rem; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; line-height: 1.2; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { padding: .5rem .9rem; font-size: var(--fs-sm); border-radius: 10px; }
.btn-wide { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(31, 138, 99, .22); }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); }
.btn-accent { background: var(--amber); color: #fff; box-shadow: 0 8px 18px rgba(255, 152, 92, .25); }
.btn-accent:hover:not(:disabled) { background: #f0803c; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-deep); }
.btn-danger { background: transparent; border-color: #f0c7c2; color: var(--danger); box-shadow: none; }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }

input, select, textarea {
  width: 100%; padding: .68rem .85rem; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfb;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 138, 99, .12); }
input:disabled { background: var(--paper); color: var(--muted); }
textarea { resize: vertical; }

.form-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.form-stack label, .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: var(--fs-sm);
}
.form-stack label.check { flex-direction: row; align-items: center; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { min-height: 1.3em; color: var(--danger); font-size: var(--fs-sm); }

/* ---------- auth ---------- */
.auth-view { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 100vh; min-height: 100dvh; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 44px 56px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  background: linear-gradient(155deg, #123a2c 0%, #1f8a63 130%);
}
.auth-hero-copy { position: relative; z-index: 1; max-width: 560px; }
.auth-hero h1 {
  font-weight: 700;
  font-size: var(--fs-display);
  line-height: .98;
  letter-spacing: -.02em;
  margin-bottom: 22px;
}
.auth-hero h1 span { color: var(--lime); }
.auth-hero p { color: #cfe9db; font-size: var(--fs-lg); max-width: 46ch; }
.hero-stat-row {
  display: flex;
  gap: 40px;
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, .18);
}
.hero-stat-row strong {
  display: block;
  font-family: var(--display);
  font-size: var(--fs-num);
  line-height: 1;
  color: var(--lime);
}
.hero-stat-row small { color: #a9d6c1; }
.pulse {
  position: absolute;
  left: 0;
  right: 0;
  top: 132px;
  width: 100%;
  height: 110px;
  pointer-events: none;
  opacity: .9;
}
.pulse polyline {
  fill: none; stroke: var(--lime); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke; stroke-dasharray: 2000; stroke-dashoffset: 2000;
  animation: draw 2.6s ease-out .3s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.auth-panel {
  background: var(--card);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-panel > * { width: 100%; max-width: 440px; margin-inline: auto; }
.auth-panel h2 { font-size: var(--fs-h2); line-height: 1; margin-bottom: 8px; }
.auth-tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
  background: none;
  border-radius: 0;
  padding: 0;
}
.auth-tab {
  flex: none;
  padding: 0 0 15px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 600;
  color: var(--muted);
  position: relative;
}
.auth-tab.active { color: var(--ink); }
.auth-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: var(--brand);
  border-radius: 3px;
}
.auth-footnote { margin-top: 18px; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- shell ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.01em;
}
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px;
  background: var(--lime); border-radius: 9px; color: var(--brand-deep); font-size: 1.1rem;
}
.brand-light { color: #fff; }
.brand-light .brand-mark { background: var(--lime); color: var(--brand-deep); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50;
  display: flex; flex-direction: column; padding: 24px 14px 18px; overflow-y: auto;
  background: #fff; color: var(--muted); border-right: 1px solid var(--line);
}
.sidebar .brand { color: var(--ink); padding: 0 12px 20px; }
.sidebar-label { margin: 20px 12px 6px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; color: #9caea3; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 12px;
  background: transparent; color: inherit; text-align: left; font-weight: 600; transition: .15s;
}
.nav-item span { width: 20px; text-align: center; opacity: .9; }
.nav-item:hover { background: #eef8f2; color: var(--brand-deep); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-deep); }
.sidebar-bottom { margin-top: auto; padding-top: 20px; }
.mini-motivation {
  background: #f6fadb;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  font-size: var(--fs-sm);
  color: #5c6a2f;
}
.logout-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 600;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.main-content { margin-left: var(--sidebar-w); min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 14px var(--space-page);
  background: rgba(244, 249, 245, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.breadcrumb b { font-weight: 400; opacity: .5; }
.breadcrumb strong { color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.1rem;
  line-height: 1;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand-deep); }
.icon-btn.active { background: var(--amber-soft); border-color: var(--amber); color: var(--amber-deep); }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  text-align: left;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.profile-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.profile-chip-text b { font-size: var(--fs-sm); }
.profile-chip-text small { color: var(--muted); font-size: var(--fs-xs); }
.top-logout, .mobile-only { display: none; }
.top-logout { padding: 8px 12px; font-size: .75rem; }
.scrim { display: none; }

.page-content { padding: 26px var(--space-page) 72px; max-width: 1320px; }
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
.page-heading h2 {
  font-size: var(--fs-h2);
  line-height: 1;
  letter-spacing: -.01em;
}
.page-heading p { margin-top: 6px; max-width: 60ch; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 30px 0 14px;
}
.section-title h3 { font-size: var(--fs-h3); line-height: 1.1; }
.card .section-title { margin: 0 0 14px; }
.card .section-title h3 { font-size: var(--fs-h3-sm); }
.link-btn { color: var(--brand); font-weight: 700; background: none; font-size: .82rem; }

/* ---------- grids and cards ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card.empty {
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.metric-card { border-radius: var(--radius); border-top: 3px solid var(--brand); padding: 18px 20px; }
.kicker { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; }
.metric {
  font-family: var(--display);
  font-size: var(--fs-num);
  font-weight: 700;
  line-height: 1;
  margin-top: 8px;
}
.metric small { font-family: var(--body); font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.lead-sm { font-size: var(--fs-lg); font-weight: 600; margin-bottom: 10px; }

.chips, .chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: .38rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.chip:hover { border-color: var(--brand); color: var(--brand-deep); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-sm { padding: .2rem .65rem; font-size: var(--fs-xs); }
.chip.done { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* ---------- home ---------- */
.home-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 18px; padding: 32px 36px;
  border-radius: var(--radius-lg); color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, #174e39 0%, #257c59 100%);
}
.home-hero::after {
  content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  border: 1px solid rgba(199, 237, 99, .3); right: 4%; top: -30%;
  box-shadow: 0 0 0 24px rgba(199, 237, 99, .05), 0 0 0 54px rgba(199, 237, 99, .04);
}
.home-hero > * { position: relative; z-index: 1; }
.home-hero h2 { font-size: var(--fs-hero); line-height: 1; margin-bottom: 8px; }
.lead { color: #cfe9db; max-width: 48ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.home-hero .btn-ghost { border-color: rgba(255, 255, 255, .4); color: #fff; }
.home-hero .btn-ghost:hover { border-color: #fff; background: rgba(255, 255, 255, .08); }
.streak-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
  color: #cfe9db;
}
.streak-num {
  font-family: var(--display);
  font-size: var(--fs-num-lg);
  font-weight: 700;
  line-height: .85;
  color: var(--lime);
}
.tip-card { margin-top: 18px; border-left: 4px solid var(--amber); }
.tip-card h4 { margin-bottom: 4px; }

/* ---------- exercises ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 14px; }
.filter-group { display: flex; align-items: center; gap: 10px; }
.filter-label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.search { margin-left: auto; min-width: 220px; }
#ex-count { margin-bottom: 12px; }
.ex-card { display: flex; flex-direction: column; gap: 8px; border-radius: var(--radius); transition: .18s; }
.ex-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #bfe6d3; }
.ex-card h4 { font-size: var(--fs-h4); }
.ex-card .btn { align-self: flex-start; margin-top: auto; }
.ex-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ex-icon { font-size: 1.8rem; line-height: 1; color: var(--brand); }
.ex-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-bottom: 6px;
}

/* ---------- dashboard ---------- */
.goal-card { display: flex; align-items: center; gap: 22px; }
.goal-card h3 { font-size: var(--fs-h3-sm); margin-bottom: 4px; }
.ring {
  --p: 0; position: relative; flex: none; width: 128px; height: 128px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0);
}
.ring::before { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: var(--card); }
.ring > * { position: relative; }
.ring strong { font-family: var(--display); font-size: 2.2rem; line-height: 1; }
.ring small { color: var(--muted); font-size: var(--fs-xs); }
.level-bar, .mini-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin: 14px 0 6px;
}
.level-bar i, .mini-bar i { display: block; height: 100%; background: var(--amber); border-radius: inherit; }
.mini-bar { height: 6px; width: 100%; margin: 4px 0 0; }
.mini-bar i { background: var(--brand); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.cups { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.cup { width: 26px; height: 34px; border: 2px solid #b9d6c5; border-radius: 4px 4px 11px 11px; }
.cup.on { background: var(--brand); border-color: var(--brand); }

.activity-list, .saved-list { list-style: none; }
.activity-list li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.activity-list li:last-child, .saved-list li:last-child { border-bottom: 0; }
.activity-list small, .saved-list small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.activity-list li > span:last-child { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.ex-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.cat-cardio { background: var(--amber); }
.cat-desk { background: var(--gold); }
.cat-yoga { background: var(--purple); }
.cat-stretch { background: var(--brand); }

/* ---------- plans ---------- */
.plan-active { margin-bottom: 8px; }
.week-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.day-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.day-cell b { font-size: var(--fs-h3-sm); }
.day-cell > span { font-size: var(--fs-sm); font-weight: 600; }
.day-cell.today { border-color: var(--brand); background: var(--brand-soft); }
.plan-card { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.plan-card .ex-top { width: 100%; }
.plan-card h4 { font-size: var(--fs-h3-sm); }

/* ---------- nutrition ---------- */
.macro-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 12px; }
.macro-row strong { display: block; font-family: var(--display); font-size: var(--fs-num); line-height: 1; }
.macro-row small { color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 4px 0 16px; }
.field-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
}
.field-inline select { min-width: 200px; color: var(--ink); font-weight: 400; }
.meal-card h4 { margin: 6px 0 4px; font-size: var(--fs-h4); }
.saved-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

/* ---------- progress ---------- */
.chart-area { display: flex; align-items: stretch; gap: 10px; height: 230px; margin-top: 16px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-col span { font-size: var(--fs-xs); color: var(--muted); }
.chart-col b { font-size: var(--fs-sm); }
.chart-col.today b { color: var(--amber-deep); }
.bar-slot {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 2px solid var(--line);
}
.bar-slot i {
  display: block;
  width: min(44px, 80%);
  background: linear-gradient(var(--lime), var(--brand));
  border-radius: 7px 7px 0 0;
  transform-origin: bottom;
  animation: grow .6s ease-out;
}
.chart-col.today .bar-slot i { background: linear-gradient(var(--gold), var(--amber)); }
@keyframes grow { from { transform: scaleY(0); } }
.bar-list { margin-top: 8px; }
.bar-line {
  display: grid;
  grid-template-columns: 84px 1fr 52px;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  font-size: var(--fs-sm);
}
.bar-line b { text-align: right; }
.bar-track { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-track i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
  transform-origin: left;
  animation: growx .6s ease-out;
}
@keyframes growx { from { transform: scaleX(0); } }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 17px 12px;
  text-align: center;
  border: 1px dashed #c8dccf;
  border-radius: 14px;
  color: var(--muted);
}
.badge-card small { font-size: var(--fs-xs); }
.badge-card strong { color: var(--ink); }
.badge-icon { font-size: 2.1rem; line-height: 1; filter: grayscale(1); opacity: .4; }
.badge-card.unlocked {
  border: 1px solid #dfeeb3;
  background: #fbffef;
  color: var(--brand-deep);
}
.badge-card.unlocked .badge-icon { filter: none; opacity: 1; }

/* ---------- leaderboard, profile, admin ---------- */
.lb-list { list-style: none; margin: 16px 0; padding: 8px 8px; }
.lb-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: 12px;
}
.lb-row + .lb-row { border-top: 1px solid var(--line); }
.lb-row.me { background: var(--brand-soft); border-top-color: transparent; }
.lb-rank { font-family: var(--display); font-size: var(--fs-h3-sm); text-align: center; color: var(--brand); }
.lb-name em {
  margin-left: 6px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--brand-deep);
  font-size: .75rem;
  font-style: normal;
  font-weight: 700;
}
.tag-muted { background: var(--line); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  text-align: left;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }

/* ---------- modal and toasts ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(15, 37, 27, .58);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: clamp(20px, 3vw, 28px);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}
.modal:focus { outline: none; }
.modal h3 {
  font-size: var(--fs-h2);
  line-height: 1;
  margin: 10px 0 6px;
  padding-right: 36px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2f6f3;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
}
.modal-close:hover { background: var(--brand-soft); color: var(--brand-deep); }
.timer { display: grid; place-items: center; margin: 18px 0; }
.timer .ring { width: 150px; height: 150px; }
.timer .ring strong { font-size: var(--fs-num); }
.steps { padding-left: 1.25rem; line-height: 1.6; }
.steps li + li { margin-top: 4px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 12px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink-2);
  color: #fff;
  border-left: 4px solid var(--brand);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: slide .25s ease-out;
  transition: opacity .25s;
}
.toast-ok { border-left-color: var(--lime); }
.toast-gold { border-left-color: var(--gold); }
.toast-warn { border-left-color: var(--amber); }
.toast.out { opacity: 0; }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } }

/* ============================================================
   RESPONSIVE — three explicit tiers, on top of the fluid clamp()
   sizes above:
     • Desktop / windowed  : > 1024px  (default styles above)
     • Tablet               : 641px – 1024px
     • Mobile / phone       : ≤ 640px
   ============================================================ */

/* ---- Tablet: landscape tablets and small laptop windows ---- */
@media (max-width: 1180px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 216px; }
  .sidebar { padding: 20px 10px 16px; }
  .sidebar .brand { padding: 0 8px 16px; font-size: 1.3rem; }
  .nav-item { padding: 10px; font-size: .92rem; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Tablet portrait / phablet: sidebar becomes an off-canvas drawer ---- */
@media (max-width: 860px) {
  :root { --sidebar-w: 260px; }
  .auth-view { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 24px 40px; }
  .pulse { display: none; }
  .auth-panel { padding: 32px 24px 48px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease, visibility 0s linear .22s;
    box-shadow: 18px 0 40px rgba(18, 51, 42, .18);
  }
  body.menu-open .sidebar { transform: none; transition-delay: 0s; }
  body.menu-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 37, 27, .5);
  }
  .main-content { margin-left: 0; }
  .topbar { padding: 10px var(--space-page); }
  .page-content { padding: 20px var(--space-page) 64px; }
  .mobile-only { display: inline-block; }
  .top-logout { display: inline-flex; }
  .breadcrumb .app-name, .breadcrumb b, .profile-chip-text { display: none; }
  .profile-chip { padding: 4px; }
  .home-hero { flex-direction: column; align-items: flex-start; padding: 26px; }
  .streak-block { flex-direction: row; gap: 10px; align-items: baseline; }
}

/* ---- Mobile / phone ---- */
@media (max-width: 640px) {
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .goal-card { flex-direction: column; align-items: flex-start; }
  .search { margin-left: 0; width: 100%; }
  .macro-row { grid-template-columns: repeat(2, 1fr); }
  .saved-list li { flex-direction: column; align-items: flex-start; }
  .badge-grid { grid-template-columns: repeat(2, 1fr); }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .quick-actions { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 420px) {
  .grid-4 { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .modal { padding: 22px 18px; }
  .chart-area { gap: 6px; }
  .badge-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto !important; }
  .pulse polyline { stroke-dashoffset: 0; }
}
.grid + p.small { margin-top: 10px; }

/* ---------- exercise videos ---------- */
.modal-wide { max-width: 680px; }
.video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 14px 0 6px;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
  display: grid;
  place-items: center;
}
.video-wrap video, .video-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
.video-msg {
  padding: 20px;
  color: #cfe9db;
  font-size: var(--fs-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.video-msg a { color: var(--lime); font-weight: 600; }
.video-overlay {
  position: absolute;
  inset: 0;
  justify-content: center;
  background: #000;
  margin: 0;
}
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: var(--lime);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.tag-video { background: var(--amber-soft); color: var(--amber-deep); }
input[type=file] { padding: .5rem; }
.or { margin: -4px 0; text-align: center; font-size: var(--fs-sm); color: var(--muted); }
.table-wrap.tall { max-height: 440px; overflow: auto; }
.table-wrap.tall th { position: sticky; top: 0; background: var(--card); }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- login type ---------- */
.login-type-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.login-type-field legend { margin-bottom: 6px; padding: 0; font-weight: 600; font-size: var(--fs-sm); }
.login-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--paper);
}
.login-type label { position: relative; display: block; }
.login-type input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.login-type span {
  display: block;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
}
.login-type input:checked + span { background: #fff; border-color: var(--line); color: var(--brand-deep); }
.login-type input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- typography polish ---------- */
h1, h2, h3, h4 { text-wrap: balance; overflow-wrap: break-word; }
p, li { text-wrap: pretty; }
.page-heading p { max-width: 62ch; }

/* Numbers that change (timer, points, streak, charts) keep a fixed width so nothing jitters. */
.metric, .metric small, .ring strong, .streak-num, .lb-rank, .lb-row strong, .chart-col span, .bar-line b,
.macro-row strong, .hero-stat-row strong, .activity-list li > span:last-child, .section-title b, #pl-time, td, th {
  font-variant-numeric: tabular-nums lining-nums;
}
.metric, .streak-num, .ring strong, .hero-stat-row strong, .macro-row strong { letter-spacing: 0; }
.ring strong, #pl-time { white-space: nowrap; }

/* Long names and emails never push the layout sideways. */
.lb-name, td { overflow-wrap: anywhere; }
.profile-chip-text { min-width: 0; max-width: 200px; }
.profile-chip-text b, .profile-chip-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inputs stay at 16px or more so iOS does not zoom into a field on focus. */
input, select, textarea { font-size: max(1rem, 16px); }
::placeholder { color: #8a988f; opacity: 1; }

@media print { .sidebar, .topbar, .toast-region { display: none !important; } .main-content { margin: 0; } }

/* ---------- large text and narrow screens ---------- */
.grid > *, .page-heading > *, .home-hero > *, .topbar > *, .goal-card > * { min-width: 0; }
.breadcrumb { flex: 1 1 auto; min-width: 0; }
.breadcrumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { flex: none; }
.ex-top { flex-wrap: wrap; }
@media (max-width: 860px) {
  .home-hero > div { max-width: 100%; }
  .home-hero h2 { overflow-wrap: anywhere; }
}

/* ---------- routines, history, backup ---------- */
.routine-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.routine-card .ex-top { width: 100%; }
.routine-card h4 { font-size: var(--fs-h4); }
.routine-card .btn { margin-top: auto; }
.routine-steps { padding-left: 1.15rem; font-size: var(--fs-sm); color: var(--muted); }
.tag-step { background: var(--amber-soft); color: var(--amber-deep); }
.modal .tag { margin-right: 6px; }
.section-title > div p { margin-top: 2px; }
.activity-list.history li { grid-template-columns: 12px 1fr auto auto; }
.file-btn { position: relative; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.day-cell .btn { align-self: flex-start; margin-top: 4px; }

/* The closed mobile drawer is invisible to keyboards and screen readers too, not just off-screen. */
@media (max-width: 860px) {
  .sidebar { visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  body.menu-open .sidebar { visibility: visible; transition-delay: 0s; }
}
