@font-face {
  font-family: 'Onest';
  src: url('/fonts/onest-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #eceef1;
  --card: #ffffff;
  --ink: #14161a;
  --mute: #6b7280;
  --line: #e4e7eb;
  --fill: #f3f4f6;
  --or: #6d36e0;
  --or-2: #9b6bff;
  --or-soft: #f0e9ff;
  --slate: #3b4757;
  --good: #1f9d55;
  --bad: #d92d20;
  --grad: linear-gradient(150deg, #9b6bff 0%, #6d36e0 70%);
  --r-hero: 32px;
  --r-card: 24px;
  --r-row: 16px;
  --shadow-card: 0 1px 2px rgba(20, 22, 26, 0.04), 0 8px 24px -12px rgba(20, 22, 26, 0.12);
  --shadow-float: 0 10px 30px -8px rgba(20, 22, 26, 0.28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; border-radius: 10px; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
.screen { padding: calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 128px); display: flex; flex-direction: column; gap: 14px; }
.screen.no-nav { padding-bottom: calc(var(--safe-b) + 150px); }

/* ---------- type ---------- */
.h-page { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.h-card { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.big { font-size: 48px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.mid { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.mute { color: var(--mute); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border-radius: var(--r-card); padding: 18px; box-shadow: var(--shadow-card); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.link { color: var(--or); font-weight: 600; font-size: 14px; padding: 4px 2px; }

.hero {
  background: var(--grad);
  color: #fff;
  border-radius: var(--r-hero);
  padding: 22px 20px 20px;
  box-shadow: 0 18px 40px -18px rgba(109, 54, 224, 0.65);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute; right: -40px; top: -50px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}
.hero .mid { max-width: 16ch; }
.hero p { opacity: 0.92; margin-top: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px; border-radius: 999px;
  font-weight: 650; font-size: 16px;
  background: var(--ink); color: #fff;
  transition: transform 0.12s ease, opacity 0.12s;
}
.btn:active { transform: scale(0.97); }
.btn.orange { background: var(--grad); box-shadow: 0 10px 22px -10px rgba(109, 54, 224, 0.8); }
.btn.white { background: #fff; color: var(--ink); }
.btn.ghost { background: var(--fill); color: var(--ink); }
.btn.danger { background: #fdecea; color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { height: 40px; padding: 0 16px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow-card); }
.icon-btn.plain { background: transparent; box-shadow: none; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 16px; height: 16px; }

/* ---------- controls ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(20, 22, 26, 0.07); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { height: 38px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--mute); }
.seg button[aria-pressed='true'] { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -2px rgba(20, 22, 26, 0.18); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--mute); }
.input {
  height: 52px; border-radius: 16px; border: 1.5px solid transparent; background: var(--fill);
  padding: 0 16px; width: 100%; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--or); background: #fff; }
textarea.input { height: 84px; padding: 12px 16px; resize: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--fill); font-size: 12.5px; font-weight: 600; color: var(--mute); white-space: nowrap; }
.chip.pb { background: var(--or-soft); color: #4b21a8; }
.chip.dark { background: var(--ink); color: #fff; }
.pill-btn { height: 40px; padding: 0 16px; border-radius: 999px; background: #fff; box-shadow: var(--shadow-card); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; position: relative; }
.pill-btn input[type='date'] { position: absolute; inset: 0; opacity: 0; width: 100%; }
.err { color: var(--bad); font-size: 14px; font-weight: 550; }
.empty { text-align: center; padding: 26px 12px; color: var(--mute); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- avatars ---------- */
.av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--slate); flex: none; }
.av.me { background: var(--grad); }
.av { overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.lg { width: 48px; height: 48px; font-size: 19px; }
.av.sm { width: 24px; height: 24px; font-size: 12px; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 14px);
  width: min(452px, calc(100% - 24px)); height: 68px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 999px; box-shadow: var(--shadow-float);
  display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; padding: 0 8px; z-index: 20;
}
.nav a { display: grid; place-items: center; gap: 2px; height: 56px; color: var(--mute); text-decoration: none; font-size: 11px; font-weight: 600; }
.nav a[aria-current='page'] { color: var(--or); }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.week .day { display: grid; justify-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--mute); }
.dot {
  width: 38px; height: 38px; border-radius: 50%; background: var(--fill);
  display: grid; place-items: center; color: #fff; position: relative;
}
.dot.gym { background: var(--ink); }
.dot.today { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--or); }
.dot svg { width: 18px; height: 18px; stroke-width: 2.6; }
.week.small .dot { width: 22px; height: 22px; }
.week.small .dot svg { width: 12px; height: 12px; }
.week.small .day { gap: 3px; }
.week-row { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px; }
.week-row + .week-row { margin-top: 10px; }

/* ---------- stats ---------- */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--fill); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.stat.me { background: var(--or-soft); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--fill); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.tile b { font-size: 20px; letter-spacing: -0.02em; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; text-align: left; width: 100%; }
.item + .item { border-top: 1px solid var(--line); }
.item .t { font-weight: 600; }
.item .s { color: var(--mute); font-size: 13.5px; }
.item .end { text-align: right; flex: none; }

/* ---------- log ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entry { display: flex; flex-direction: column; gap: 14px; }
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center; }
.stepper button { height: 52px; border-radius: 16px; background: var(--fill); display: grid; place-items: center; }
.stepper button:active { background: var(--line); }
.stepper .input { text-align: center; font-size: 26px; font-weight: 700; height: 56px; letter-spacing: -0.02em; }
.lab { font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 6px; }
.setrow { display: flex; align-items: center; gap: 12px; padding: 12px 8px; margin: 0 -8px; border-radius: 14px; width: calc(100% + 16px); text-align: left; }
.setrow + .setrow { border-top: 1px solid var(--line); border-radius: 0; }
.setrow .n { width: 26px; height: 26px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--mute); flex: none; }
.setrow .v { font-weight: 650; font-size: 17px; }
.setrow.editing { background: var(--or-soft); border-radius: 14px; }
.setrow.pb-new { animation: glow 1.6s ease-out; }
@keyframes glow { 0% { background: var(--or); color: #fff; } 40% { background: var(--or-2); } 100% { background: transparent; } }
.finish-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(480px, 100%);
  padding: 12px 16px calc(var(--safe-b) + 14px); background: linear-gradient(to top, var(--bg) 70%, rgba(236, 238, 241, 0));
  display: flex; gap: 10px; z-index: 15;
}

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 22, 26, 0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease-out; }
.sheet {
  background: var(--bg); width: min(480px, 100%); max-height: 88dvh; border-radius: 28px 28px 0 0;
  padding: 10px 16px calc(var(--safe-b) + 18px); display: flex; flex-direction: column; gap: 12px; overflow: hidden;
  animation: rise 0.22s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(20, 22, 26, 0.18); margin: 0 auto 4px; flex: none; }
.sheet .scroll { overflow-y: auto; margin: 0 -16px; padding: 0 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.group-h { font-size: 13px; font-weight: 650; color: var(--mute); padding: 14px 4px 4px; }

/* ---------- toast + PB moment ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 14px); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 600; max-width: calc(100% - 32px);
  box-shadow: var(--shadow-float); animation: drop 0.25s ease-out;
}
.toast.bad { background: var(--bad); }
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }
.pb-burst {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(20, 22, 26, 0.55);
  animation: fade 0.18s ease-out;
}
.pb-burst .box {
  background: var(--grad); color: #fff; border-radius: 36px; padding: 30px 34px; text-align: center; width: min(320px, 86vw);
  box-shadow: 0 30px 60px -20px rgba(109, 54, 224, 0.9); animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.pb-burst .bolt { width: 64px; height: 64px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); display: grid; place-items: center; margin: 0 auto 12px; }
.pb-burst .bolt svg { width: 32px; height: 32px; fill: #fff; stroke: #fff; }
.pb-burst .mid { font-size: 34px; }
@keyframes pop { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px 4px; text-align: center; }
.cal .dh { font-size: 12px; font-weight: 600; color: var(--mute); padding-bottom: 4px; }
.cal .c { height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 600; position: relative; width: 38px; margin: 0 auto; color: var(--mute); }
.cal .c.gym { background: var(--ink); color: #fff; }
.cal .c.today:not(.gym) { background: var(--or-soft); color: var(--or); }

/* ---------- chart ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--mute); font-weight: 550; }

/* ---------- heatmap ---------- */
.heat { display: grid; grid-template-columns: 34px repeat(19, minmax(0, 1fr)); gap: 2px; align-items: center; }
.heat .hl { font-size: 10.5px; color: var(--mute); font-weight: 600; text-align: left; white-space: nowrap; }
.heat .hd { font-size: 10px; color: var(--mute); font-weight: 600; height: 14px; width: 0; overflow: visible; white-space: nowrap; }
.heat button.cell { aspect-ratio: 1 / 1.25; border-radius: 4px; position: relative; padding: 0; min-width: 0; }
.heat button.cell.now { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 1; }
.heat button.cell.sel { outline: 2px solid var(--or); outline-offset: 1px; z-index: 1; }
.heat .mark { position: absolute; left: 50%; width: 5px; height: 5px; border-radius: 50%; transform: translateX(-50%); border: 1px solid #fff; }
.heat .mark.me { background: var(--or); top: 2px; }
.heat .mark.you { background: var(--ink); bottom: 2px; }
.meter { height: 12px; border-radius: 6px; background: var(--fill); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 6px; background: var(--grad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--mute); font-weight: 550; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; gap: 0; background: var(--grad); position: relative; overflow: hidden; }
.logo { width: 64px; height: 64px; border-radius: 20px; box-shadow: var(--shadow-card); }
.skeleton { height: 120px; border-radius: var(--r-card); background: linear-gradient(90deg, #e3e6ea 25%, #eef0f3 50%, #e3e6ea 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

a.icon-btn { color: var(--ink); text-decoration: none; }

/* ---------- v2: pick, effort, done ---------- */
.chip.white { background: rgba(255,255,255,.95); color: #4b21a8; }
.btn.glass { background: rgba(255,255,255,.22); color: #fff; }
.hero-check { width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--or); display: grid; place-items: center; }
.hero-check svg { width: 16px; height: 16px; stroke-width: 3; }
.hero.center { text-align: center; padding: 30px 20px 26px; }
.hero.center .mid { max-width: none; font-size: 30px; }
.hero-check.big { width: 64px; height: 64px; margin: 0 auto; animation: pop .5s cubic-bezier(.2,1.4,.4,1) both; }
.hero-check.big svg { width: 32px; height: 32px; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; border-radius: 20px; background: var(--fill); font-size: 18px; font-weight: 650; text-align: left; color: var(--ink); }
.pick svg { flex: none; color: var(--mute); }
.pick.selected { background: var(--or-soft); }
.pick-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.input.big { height: 56px; font-size: 18px; border-radius: 18px; padding: 0 18px; flex: none; }
.item.big { padding: 16px 0; font-size: 17px; }
.scroll { overflow-y: auto; flex: 1; min-height: 0; }
.effort { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 14px 18px; border-radius: 18px; background: #fff; text-align: left; border: 2px solid transparent; }
.effort .t { font-weight: 700; font-size: 17px; }
.effort .s { color: var(--mute); font-size: 14px; }
.effort.on, .effort:active { border-color: var(--or); background: var(--or-soft); }
@media (prefers-reduced-motion: reduce) { .hero-check.big { animation: none; } }

.coach { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.coach .av { width: 52px; height: 52px; box-shadow: 0 0 0 3px var(--or-soft); }
.coach .say { font-weight: 600; line-height: 1.35; }

/* ---------- v3: home ---------- */
.coach-row { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.22); position: relative; z-index: 1; }
.coach-row .av { width: 46px; height: 46px; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.55); }
.coach-row p { margin: 0; font-weight: 600; font-size: 15px; line-height: 1.35; opacity: 1; }
.hero-body { position: relative; z-index: 1; }
.hero-body .mid { font-size: 28px; margin-top: 2px; }
.wk-row { display: grid; grid-template-columns: 30px repeat(7, 1fr); gap: 6px; align-items: center; justify-items: center; }
.wk-row + .wk-row { margin-top: 10px; }
.wk-head { font-size: 12px; font-weight: 600; color: var(--mute); margin-bottom: 8px; }
.wk-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; color: #fff; }
.wk-dot.on { background: var(--grad); }
.wk-dot.today { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--or); }
.wk-dot svg { width: 16px; height: 16px; stroke-width: 3; }
.mstats { display: grid; grid-template-columns: 1fr 1fr; }
.mstat { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.mstat + .mstat { border-left: 1px solid var(--line); padding-left: 18px; }
.mstat .big { font-size: 40px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.05; margin-top: 8px; }

/* ---------- v3: sign in ---------- */
.auth-hero { color: #fff; text-align: center; padding: 0 24px 28px; position: relative; }
.auth::after { content: ''; position: absolute; right: -60px; top: -70px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.3), rgba(255,255,255,0) 70%); pointer-events: none; }
.auth-hero .logo { width: 72px; height: 72px; margin: 0 auto 16px; box-shadow: 0 14px 30px -10px rgba(30, 10, 80, .55); position: relative; z-index: 1; }
.auth-hero h1 { font-size: 34px; font-weight: 750; letter-spacing: -0.03em; margin: 0; position: relative; z-index: 1; }
.auth-hero p { margin: 6px 0 0; opacity: .92; position: relative; z-index: 1; }
.pair { display: flex; justify-content: center; margin-top: 18px; position: relative; z-index: 1; }
.pair .av { width: 52px; height: 52px; box-shadow: 0 0 0 3px rgba(255,255,255,.7); }
.pair .av + .av { margin-left: -12px; }
.auth > form { margin: 0 18px; position: relative; z-index: 2; box-shadow: 0 24px 50px -24px rgba(30, 10, 80, .6); }
