@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/space-grotesk-var.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope-var.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #0a0a0d;
  --card: #131419;
  --card-2: #1a1b22;
  --line: rgba(255, 255, 255, 0.07);
  --line-soft: rgba(255, 255, 255, 0.05);
  --text: #f4f5f8;
  --dim: #9aa3b2;
  --primary: #ff6b3d;
  --primary-2: #ff3d68;
  --primary-ink: #2b0d04;
  --blue: #4d9dff;
  --teal: #2dd4f0;
  --ant: #2dd4f0;
  --sarit: #ff6fa5;
  --danger: #f87171;
  --r-lg: 22px;
  --r-md: 16px;
  --display: 'Space Grotesk', -apple-system, system-ui, sans-serif;
  --body: 'Manrope', -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(55% 30% at 20% -2%, rgba(255, 107, 61, 0.09), transparent 70%),
    radial-gradient(45% 26% at 95% 4%, rgba(77, 157, 255, 0.07), transparent 70%),
    var(--bg);
}

/* ---------- splash ---------- */
.splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  z-index: 50;
}
.splash.out { animation: splashOut 0.4s ease forwards; }
@keyframes splashOut { to { opacity: 0; visibility: hidden; } }
.splash svg { width: 72px; height: 72px; color: var(--primary); animation: splashPump 1.1s ease-in-out infinite; }
@keyframes splashPump { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.14) rotate(-4deg); } }
.splash .splash-name {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.26em;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.splash .splash-sub { font-size: 13px; font-weight: 600; color: var(--dim); letter-spacing: 0.05em; }

/* ---------- header ---------- */
header {
  flex: none;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.brand em {
  font-style: normal;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.user-switch {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.user-switch button {
  border: 0;
  background: transparent;
  color: var(--dim);
  font-family: var(--body);
  font-size: 14px;
  font-weight: 800;
  padding: 8px 17px;
  border-radius: 999px;
  min-height: 38px;
  transition: color 0.2s;
}
.user-switch button.active { color: #08131a; }

/* ---------- scroll area ---------- */
#scroller {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  position: relative;
}
.ptr {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: height 0.25s ease;
  color: var(--dim);
}
.ptr.dragging { transition: none; }
.ptr svg { width: 22px; height: 22px; margin-bottom: 14px; transition: color 0.15s; }
.ptr.armed svg { color: var(--primary); }
.ptr.refreshing svg { animation: spin 0.8s linear infinite; color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

main {
  padding: 4px 18px 30px;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
main.slide-left { animation: slideLeft 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
main.slide-right { animation: slideRight 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes slideLeft { from { opacity: 0; transform: translateX(9%); } to { opacity: 1; transform: none; } }
@keyframes slideRight { from { opacity: 0; transform: translateX(-9%); } to { opacity: 1; transform: none; } }

h1.page {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 10px 0 4px;
}
.page-sub { font-size: 14px; font-weight: 600; color: var(--dim); margin: 0 0 18px; }

/* ---------- home ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat-chip {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 13px 8px 11px;
  text-align: center;
}
.stat-chip svg { width: 17px; height: 17px; color: var(--primary); margin-bottom: 6px; }
.stat-chip .v {
  font-family: var(--display);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}
.stat-chip .v small { font-size: 12px; color: var(--dim); font-weight: 600; }
.stat-chip .k { font-size: 10.5px; font-weight: 800; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 6px; }

.workout-card {
  display: block;
  width: 100%;
  text-align: left;
  background:
    linear-gradient(125deg, rgba(255, 107, 61, 0.16), rgba(255, 61, 104, 0.05) 52%, transparent 75%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 20px;
  margin-bottom: 14px;
  color: var(--text);
  font-family: var(--body);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s;
}
.workout-card:active { transform: scale(0.98); }
.workout-card.b {
  background:
    linear-gradient(125deg, rgba(77, 157, 255, 0.15), rgba(45, 212, 240, 0.05) 52%, transparent 75%),
    var(--card);
}
.workout-card .big { font-family: var(--display); font-size: 23px; font-weight: 700; letter-spacing: -0.01em; }
.workout-card .sub { color: var(--dim); font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.workout-card .muscles { display: flex; gap: 6px; margin-top: 15px; flex-wrap: wrap; }
.workout-card .muscles span {
  font-size: 11px;
  font-weight: 800;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-soft);
  padding: 4px 10px;
  border-radius: 999px;
}
.workout-card .letter {
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--display);
  font-size: 120px;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.09);
  pointer-events: none;
}

/* ---------- workout view ---------- */
.back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0 4px;
}
.back-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-family: var(--body);
  font-size: 15px;
  font-weight: 800;
  padding: 8px 10px 8px 0;
}
.back-btn svg { width: 19px; height: 19px; }
.ring-wrap { display: flex; align-items: center; gap: 9px; }
.ring-wrap .ring-label { font-size: 13px; font-weight: 800; color: var(--dim); }
.ring-bg { stroke: rgba(255, 255, 255, 0.1); }
.ring-fg { stroke: url(#ringGrad); transition: stroke-dashoffset 0.5s cubic-bezier(0.22, 1, 0.36, 1); }

.ex-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  margin-bottom: 11px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.ex-card.open { border-color: rgba(255, 107, 61, 0.4); }
.ex-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px 12px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--body);
  text-align: left;
}
.ex-thumb {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 14px;
  object-fit: cover;
  background: #fff;
  position: relative;
}
.thumb-wrap { position: relative; flex: none; width: 52px; height: 52px; }
.thumb-wrap .badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 21px;
  height: 21px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3ddc7d, #19b864);
  border: 2.5px solid var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-wrap .badge svg { width: 10px; height: 10px; color: #03140a; }
.ex-title { flex: 1; min-width: 0; }
.ex-title .name { font-size: 16.5px; font-weight: 800; letter-spacing: -0.01em; }
.ex-title .meta { font-size: 12.5px; color: var(--dim); font-weight: 700; margin-top: 3px; }
.ex-last {
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--dim);
  white-space: nowrap;
}

.ex-body { padding: 2px 16px 18px; }

/* ---------- demo player ---------- */
.demo {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #fff;
  margin: 6px 0 4px;
}
.demo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.demo .demo-tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(10, 10, 13, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 5px 10px;
  border-radius: 999px;
}

.today-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 107, 61, 0.1);
  border: 1px solid rgba(255, 107, 61, 0.28);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 8px 8px 13px;
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 700;
  animation: chipIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes chipIn { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
.chip .x {
  border: 0;
  background: rgba(255, 255, 255, 0.09);
  color: var(--dim);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chip .x svg { width: 11px; height: 11px; }

.stepper-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 16px 0 8px;
  text-align: center;
}
.stepper { display: flex; align-items: center; justify-content: center; gap: 9px; }
.stepper .val {
  flex: 1;
  text-align: center;
  font-family: var(--display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stepper .val small { font-size: 16px; color: var(--dim); font-weight: 600; margin-left: 4px; }
.stepper .val.sm { font-size: 30px; }
.step-btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 700;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 999px;
  transition: transform 0.1s, background 0.15s;
}
.step-btn:active { transform: scale(0.88); background: rgba(255, 255, 255, 0.13); }

.log-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 20px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(115deg, var(--primary), var(--primary-2));
  color: #fff;
  font-family: var(--body);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.01em;
  min-height: 58px;
  box-shadow: 0 10px 28px rgba(255, 85, 80, 0.28);
  transition: transform 0.12s, filter 0.15s;
}
.log-btn:active { transform: scale(0.97); filter: brightness(0.9); }
.log-btn.flash { background: linear-gradient(115deg, #3ddc7d, #19b864); box-shadow: 0 10px 28px rgba(40, 200, 110, 0.3); }

.form-toggle {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
  color: var(--dim);
  font-family: var(--body);
  font-size: 14.5px;
  font-weight: 800;
  min-height: 46px;
  border-radius: 15px;
}
.cues { margin: 12px 0 0; padding: 0; list-style: none; }
.cues li {
  position: relative;
  padding: 7px 0 7px 28px;
  font-size: 14.5px;
  line-height: 1.55;
  font-weight: 600;
  color: #d6dbe4;
}
.cues li svg {
  position: absolute;
  left: 0;
  top: 9px;
  width: 15px;
  height: 15px;
  color: var(--primary);
}

/* ---------- progress ---------- */
.ex-picker {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9'><path d='M1 1l6 6 6-6' stroke='%239aa3b2' stroke-width='2' fill='none' stroke-linecap='round'/></svg>") no-repeat right 18px center;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  font-weight: 800;
  padding: 15px 46px 15px 17px;
  margin-bottom: 13px;
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 18px 10px 8px;
  margin-bottom: 13px;
}
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-line { stroke-dasharray: 600; stroke-dashoffset: 600; animation: drawIn 1.1s cubic-bezier(0.5, 0, 0.3, 1) forwards; }
@keyframes drawIn { to { stroke-dashoffset: 0; } }
.legend { display: flex; gap: 18px; padding: 8px 10px 10px; }
.legend span { font-size: 12.5px; font-weight: 800; color: var(--dim); display: flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 99px; display: inline-block; }
.legend i.dash { width: 16px; height: 0; border-top: 2px dashed var(--dim); border-radius: 0; background: none !important; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--uc, var(--primary));
}
.stat-card .who { font-size: 11.5px; font-weight: 800; letter-spacing: 0.09em; }
.stat-card .now { font-family: var(--display); font-size: 29px; font-weight: 700; margin-top: 7px; letter-spacing: -0.02em; }
.stat-card .now small { font-size: 14px; color: var(--dim); font-weight: 600; }
.stat-card .delta { font-size: 12.5px; font-weight: 700; color: var(--dim); margin-top: 5px; }
.stat-card .delta.up { color: #3ddc7d; }

.empty {
  color: var(--dim);
  text-align: center;
  padding: 36px 18px;
  font-size: 15px;
  line-height: 1.6;
  font-weight: 600;
}
.empty svg { width: 34px; height: 34px; color: var(--dim); opacity: 0.6; margin-bottom: 10px; }

/* ---------- history ---------- */
.day-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 11px;
}
.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.day-head .date { font-family: var(--display); font-size: 16.5px; font-weight: 700; }
.day-head .tag {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: rgba(255, 107, 61, 0.1);
  border: 1px solid rgba(255, 107, 61, 0.22);
  padding: 4px 10px;
  border-radius: 999px;
}
.day-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; font-size: 14.5px; border-top: 1px solid var(--line-soft); }
.day-row .n { font-weight: 700; }
.day-row .v { color: var(--dim); font-weight: 700; font-family: var(--display); font-size: 13px; }
.day-foot { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 12.5px; font-weight: 800; color: var(--dim); }

/* ---------- tab bar ---------- */
nav.tabbar {
  flex: none;
  display: flex;
  background: rgba(13, 13, 17, 0.92);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  border-top: 1px solid var(--line-soft);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
}
nav.tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-family: var(--body);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  transition: color 0.2s;
}
nav.tabbar button.active { color: var(--primary); }
.tab-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  transition: background 0.25s;
}
nav.tabbar button.active .tab-pill { background: rgba(255, 107, 61, 0.13); }
nav.tabbar svg { width: 22px; height: 22px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  transform: translateX(-50%);
  background: var(--danger);
  color: #1b0606;
  font-weight: 800;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
