:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #111827;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #6366f1;
  --secondary: #14b8a6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --line: rgba(148, 163, 184, .2);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, .24), transparent 28rem),
    linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 22px 16px 96px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 1.65rem; font-weight: 800; letter-spacing: 0; }
.eyebrow { margin: 0 0 3px; color: var(--secondary); font-size: .78rem; text-transform: uppercase; font-weight: 800; }
.top-icon { color: var(--secondary); font-size: 1.8rem; }

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 41, 59, .9);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  font-size: 1.2rem;
}

.hero-panel, .app-panel, .timer-panel {
  background: rgba(30, 41, 59, .88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .22);
}
.hero-panel { display: grid; gap: 12px; margin-bottom: 16px; }
.hero-panel h2 { margin: 0; font-size: 1.45rem; font-weight: 800; }
.hero-panel p { margin: 0; color: var(--muted); }
.hero-panel.compact { gap: 14px; }
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
}
.status-dot.offline { background: var(--warning); }

.btn { border-radius: 8px; font-weight: 800; min-height: 44px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); }
.btn-success { --bs-btn-bg: var(--success); --bs-btn-border-color: var(--success); color: #06230f; }
.btn-outline-light { --bs-btn-color: var(--text); --bs-btn-border-color: var(--line); }
.form-control, .form-select {
  min-height: 46px;
  border-radius: 8px;
  border-color: rgba(148, 163, 184, .24);
  background: rgba(15, 23, 42, .72);
  color: var(--text);
}
.form-control:focus {
  background: rgba(15, 23, 42, .95);
  color: var(--text);
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .18);
}
.form-control::placeholder { color: #64748b; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric-card {
  background: rgba(17, 24, 39, .75);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.metric-card span, .muted { color: var(--muted); }
.metric-card strong { display: block; margin-top: 6px; font-size: 1.15rem; }
.app-panel { margin-bottom: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-title h2, .app-panel h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.section-title i { color: var(--secondary); }
.pain-row { margin-bottom: 12px; }
.pain-row label { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 4px; }
.form-range::-webkit-slider-thumb { background: var(--primary); }
.warning-copy { color: #fed7aa; background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .28); padding: 10px; border-radius: 8px; margin: 12px 0 0; }
.soft-list { display: grid; gap: 10px; }
.soft-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, .55);
  border: 1px solid var(--line);
}
.soft-item span { color: var(--muted); }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(15, 23, 42, .96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 7px 6px max(7px, env(safe-area-inset-bottom));
}
.bottom-nav a {
  min-height: 52px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .72rem;
  border-radius: 8px;
}
.bottom-nav i { font-size: 1.2rem; line-height: 1; }
.bottom-nav span { display: block; margin-top: 2px; }
.bottom-nav a.active { color: var(--text); background: rgba(99, 102, 241, .18); }

.login-body { display: grid; place-items: center; padding: 16px; }
.login-shell { width: min(100%, 430px); display: grid; gap: 16px; }
.brand-panel { text-align: center; padding: 20px 12px; }
.brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  font-size: 2rem;
}
.brand-panel h1 { font-size: 2.2rem; font-weight: 900; }
.brand-panel p, .small-note { color: var(--muted); }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.login-card h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 16px; }
.small-note { font-size: .85rem; margin: 14px 0 0; }

.workout-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); }
.exercise-list { display: grid; gap: 14px; }
.exercise-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 41, 59, .9);
  padding: 14px;
}
.exercise-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.exercise-head h2 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 850; }
.exercise-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.set-row { display: grid; grid-template-columns: 74px 1fr 1fr 44px; gap: 8px; align-items: center; margin-top: 8px; }
.set-row span { color: var(--muted); font-weight: 800; font-size: .86rem; }
.set-row .form-control { min-height: 40px; padding: 7px 9px; }
.check-btn { width: 42px; height: 40px; padding: 0; }
.exercise-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.timer-panel { position: sticky; top: 8px; z-index: 10; display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.timer-panel strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.timer-actions { display: flex; gap: 6px; }
.finish-btn { margin-top: 16px; }

.measure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.measure-grid .full { grid-column: 1 / -1; }
.chart-panel canvas { width: 100% !important; min-height: 220px; }
.profile-form { display: grid; gap: 8px; }
.profile-form label { color: var(--muted); font-weight: 700; }

.coach-shell { min-height: 100vh; display: flex; flex-direction: column; }
.coach-suggestions { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 8px; }
.coach-suggestions button {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 41, 59, .95);
  color: var(--text);
  padding: 9px 12px;
}
.chat-window { flex: 1; display: grid; align-content: start; gap: 10px; margin-bottom: 12px; }
.message {
  max-width: 88%;
  padding: 12px 13px;
  border-radius: 8px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.message.user { justify-self: end; background: var(--primary); }
.message.assistant { justify-self: start; background: var(--panel); border: 1px solid var(--line); }
.chat-form {
  position: sticky;
  bottom: 72px;
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 8px;
  background: rgba(15, 23, 42, .86);
  padding-top: 8px;
}

@media (min-width: 720px) {
  .app-shell { padding-top: 30px; }
  .bottom-nav { width: min(100%, 760px); left: 50%; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
