/* ============================================================
   ReForm — Component system
   ============================================================ */

/* ---------- Screen ---------- */
.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 6px var(--pad-x) 26px;
}
.screen--pad-lg { padding-bottom: 40px; }
.screen.is-push { animation: slideInRight 0.34s var(--ease); }
.screen.is-pop { animation: slideInLeft 0.3s var(--ease); }
.screen.is-fade { animation: fade 0.28s var(--ease); }

.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 18px;
}
.screen-head__title { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  height: 52px;
  margin: 0 -6px;
}
.topbar__center {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.005em;
}
.topbar__eyebrow { display: block; }
.topbar__right { display: flex; justify-content: flex-end; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: rgba(18, 53, 107, 0.06); transform: scale(0.94); }
.icon-btn--surface {
  background: var(--white);
  box-shadow: var(--shadow-card);
}

.text-btn {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s var(--ease), opacity 0.18s var(--ease);
}
.text-btn:active { opacity: 0.55; }
.text-btn--teal { color: var(--teal); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 54px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--r-btn);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
}
.btn:active { transform: scale(0.983); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn--primary {
  background: var(--teal);
  color: var(--navy-deep);
  box-shadow: 0 6px 18px rgba(32, 197, 181, 0.26);
}
.btn--primary:active { box-shadow: 0 3px 10px rgba(32, 197, 181, 0.22); }

.btn--secondary {
  background: var(--white);
  color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.btn--secondary:active { background: var(--surface-blue); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  min-height: 48px;
}

.btn--navy {
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 6px 18px rgba(11, 59, 130, 0.22);
}

.btn-row { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--r-card);
  padding: 18px;
  box-shadow: var(--shadow-card);
}
.card--tight { padding: 14px 16px; }
.card--muted { background: var(--surface-blue); box-shadow: none; }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

/* ---------- Pills / chips ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.pill--live { background: var(--teal-light); color: #0E8B7E; }
.pill--navy { background: var(--blue-soft); color: var(--navy); }
.pill--muted { background: var(--surface-muted); color: var(--text-2); }

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  animation: dotPulse 1.8s var(--ease-soft) infinite;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--white);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: all 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.chip:active { transform: scale(0.97); }
.chip.is-active {
  background: var(--teal-light);
  color: var(--navy-deep);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(32, 197, 181, 0.4);
}
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

/* ---------- Notification dot ---------- */
.unread {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 2.5px var(--white);
}
.unread--inline {
  position: static;
  width: 8px;
  height: 8px;
  box-shadow: none;
  flex: 0 0 auto;
}

/* ---------- Quick action tiles ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 12px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--white);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
  min-height: 96px;
  -webkit-tap-highlight-color: transparent;
}
.quick:active { transform: scale(0.97); box-shadow: var(--shadow-lift); }
.quick__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--teal-light);
  color: #0E8B7E;
}
.quick__icon--navy { background: var(--blue-soft); color: var(--navy); }
.quick__label { font-size: 14px; font-weight: 600; color: var(--navy); letter-spacing: -0.01em; }
.quick__sub { font-size: 12px; color: var(--text-2); }

/* ---------- Week strip ---------- */
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.week__day { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.week__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-transform: uppercase;
}
.week__dot {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  color: var(--text-3);
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.week__dot.is-done { background: var(--teal-light); color: var(--teal); }
.week__dot.is-today { box-shadow: inset 0 0 0 1.5px var(--teal); background: var(--white); color: var(--teal); }
.week__dot.is-today.is-done { background: var(--teal-light); }
.week__dot.is-rest { background: var(--surface-muted); color: #C0D2DC; }

/* ---------- Progress bar ---------- */
.bar {
  position: relative;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--teal);
  transition: width 0.55s var(--ease);
}
.bar--navy > i { background: var(--navy); }

/* ---------- Metric card ---------- */
.metric {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.metric__label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.metric__value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.metric__unit { font-size: 14px; font-weight: 500; color: var(--text-2); }
.metric__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
}
.metric__delta--up { background: var(--teal-light); color: #0E8B7E; }
.metric__delta--down { background: var(--teal-light); color: #0E8B7E; }
.metric__note { margin-top: 8px; font-size: 11.5px; color: var(--text-3); line-height: 1.35; }

/* ---------- Exercise card ---------- */
.exercise {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--white);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.exercise:active { transform: scale(0.985); box-shadow: var(--shadow-lift); }
.exercise__thumb {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: linear-gradient(180deg, #F2FBF9 0%, #E8F8F5 100%);
}
.exercise__thumb svg { width: 100%; height: 100%; }
.exercise__body { flex: 1 1 auto; min-width: 0; }
.exercise__name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--navy);
  line-height: 1.25;
}
.exercise__meta { display: block; margin-top: 3px; font-size: 13.5px; color: var(--text-2); }
.exercise__chev { flex: 0 0 auto; color: var(--text-3); }
.exercise__tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--blue-soft);
  color: var(--navy);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

/* ---------- Feedback card ---------- */
.feedback {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 84px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--teal-light);
  transition: background 0.3s var(--ease);
}
.feedback.is-change { animation: rise 0.36s var(--ease); }
.feedback__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.75);
  color: var(--teal);
}
.feedback__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--navy);
}
.feedback__msg { margin-top: 1px; font-size: 14.5px; line-height: 1.4; color: var(--text-2); }
.feedback--positive { background: var(--teal-light); }
.feedback--positive .feedback__icon { color: #0E8B7E; }
.feedback--warn { background: #FDF5E6; }
.feedback--warn .feedback__icon { color: var(--warning-ink); background: rgba(255, 255, 255, 0.8); }
.feedback--escalate { background: var(--blue-soft); }
.feedback--escalate .feedback__icon { color: var(--navy); background: rgba(255, 255, 255, 0.85); }

/* ---------- Message bubble ---------- */
.bubble-row { display: flex; margin-bottom: 10px; }
.bubble-row--me { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.45;
  animation: rise 0.34s var(--ease) backwards;
}
.bubble--them {
  background: var(--white);
  color: var(--text);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-card);
}
.bubble--me {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble__time {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-3);
}
.bubble--me .bubble__time { color: rgba(255, 255, 255, 0.62); }

.typing { display: flex; gap: 4px; padding: 13px 16px; }
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: dotPulse 1.2s var(--ease-soft) infinite;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }

/* ---------- Bottom navigation ---------- */
.bottomnav {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-nav);
}
.bottomnav[hidden] { display: none; }
.navtab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.25;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s var(--ease);
  padding-top: 10px;
}
.navtab svg { transition: transform 0.24s var(--ease); }
.navtab.is-active { color: var(--teal); font-weight: 600; }
.navtab.is-active svg { transform: translateY(-1px) scale(1.06); }
.navtab:active { opacity: 0.6; }

/* ---------- Sheet ---------- */
.sheet-root {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}
.sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: auto;
}
.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 43, 99, 0.32);
  backdrop-filter: blur(2px);
  animation: backdropIn 0.26s var(--ease);
  border: 0;
  padding: 0;
  cursor: default;
}
.sheet.is-closing .sheet__backdrop { animation: backdropIn 0.22s var(--ease) reverse forwards; }
.sheet__panel {
  position: relative;
  max-height: 94%;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--white);
  border-radius: 30px 30px 0 0;
  box-shadow: var(--shadow-sheet);
  overflow-y: auto;
  animation: sheetUp 0.38s var(--ease);
  scrollbar-width: none;
}
.sheet__panel::-webkit-scrollbar { display: none; }
.sheet.is-closing .sheet__panel { animation: sheetDown 0.24s var(--ease) forwards; }
.sheet__grip {
  width: 38px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: rgba(18, 53, 107, 0.14);
}

/* ---------- Toast ---------- */
.toast-root {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 22px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 82%;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: rgba(8, 43, 99, 0.94);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-float);
  animation: toastIn 0.3s var(--ease);
}
.toast.is-out { animation: backdropIn 0.28s var(--ease) reverse forwards; }

/* ---------- List rows ---------- */
.rows { border-radius: var(--r-card); background: var(--white); box-shadow: var(--shadow-card); overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s var(--ease);
}
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row:active { background: var(--surface-blue); }
.row__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--blue-soft);
  color: var(--navy);
  flex: 0 0 auto;
}
.row__icon--teal { background: var(--teal-light); color: #0E8B7E; }
.row__label { flex: 1 1 auto; font-size: 15.5px; font-weight: 500; color: var(--navy); letter-spacing: -0.008em; }
.row__value { font-size: 14px; color: var(--text-2); }
.row__chev { color: var(--text-3); flex: 0 0 auto; }

/* ---------- Switch ---------- */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border: 0;
  border-radius: var(--r-pill);
  background: #DFE9EF;
  cursor: pointer;
  transition: background 0.24s var(--ease);
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(11, 59, 130, 0.22);
  transition: transform 0.24s var(--ease);
}
.switch.is-on { background: var(--teal); }
.switch.is-on::after { transform: translateX(20px); }

/* ---------- Avatar ---------- */
.avatar { border-radius: 50%; overflow: hidden; flex: 0 0 auto; background: var(--blue-soft); }
.avatar--sm { width: 40px; height: 40px; }
.avatar--md { width: 56px; height: 56px; }
.avatar--lg { width: 68px; height: 68px; }

/* ---------- Chart ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart__line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 700);
  stroke-dashoffset: var(--len, 700);
  animation: drawStroke 1.15s var(--ease) forwards;
}
.chart__dot { animation: popIn 0.5s var(--ease) backwards; }
.legend { display: flex; gap: 16px; }
.legend__item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.legend__swatch { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Divider / notes ---------- */
.note {
  display: flex;
  gap: 9px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-blue);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
}
.note svg { flex: 0 0 auto; margin-top: 1px; color: var(--navy); }
.note--teal { background: var(--teal-light); color: #0E7C71; }
.note--teal svg { color: #0E8B7E; }

.section {
  margin-top: 22px;
}
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section__title { font-size: 17px; font-weight: 600; color: var(--navy); letter-spacing: -0.012em; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--sm { gap: 8px; }
.stack--lg { gap: 18px; }
