:root {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1b1f26;
  --border: #262b33;
  --text: #f2f3f5;
  --text-dim: #9aa1ac;
  --accent: #ff6b4a;
  --accent-dim: #7a3626;
  --good: #4ade80;
  --bad: #f87171;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f4f6;
    --surface: #ffffff;
    --surface-2: #eceef1;
    --border: #dfe2e7;
    --text: #14171c;
    --text-dim: #5b6270;
    --accent: #e85a3a;
    --accent-dim: #ffd9cd;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior-y: none;
}

.phone-frame-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

@media (min-width: 700px) {
  .phone-frame-wrap {
    background: radial-gradient(circle at 50% 20%, #1a1d23, #05060a 70%);
    padding: 40px 0;
  }
  .app {
    width: 390px;
    height: 844px;
    max-height: 92vh;
    border-radius: 44px;
    border: 10px solid #000;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px #222;
    overflow: hidden;
  }
}

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 20px) 18px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  display: none;
}

.view.active { display: block; }

h1.page-title {
  font-size: 22px;
  margin: 0 0 4px;
  font-weight: 700;
}

.page-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}

.card-today {
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
}

.today-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 6px;
}

.today-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.today-meta {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 16px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: block;
}

.btn-primary {
  background: var(--accent);
  color: #1a0f0a;
}

.btn-primary:active { opacity: 0.85; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.exercise-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.exercise.done {
  opacity: 0.55;
}

.exercise.done .exercise-name {
  text-decoration: line-through;
}

.checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 8px;
  border: 2px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
}

.exercise.done .checkbox {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0f0a;
  font-weight: 900;
}

.exercise-info { flex: 1; }

.exercise-name {
  font-size: 15px;
  font-weight: 600;
}

.exercise-sets {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 24px 0 10px;
}

.section-title:first-child { margin-top: 0; }

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.metric-row:last-child { border-bottom: none; }

.metric-name {
  font-size: 14px;
  color: var(--text-dim);
}

.metric-value {
  font-size: 16px;
  font-weight: 700;
  text-align: right;
}

.metric-delta {
  font-size: 12px;
  font-weight: 700;
  margin-left: 8px;
}

.metric-delta.up { color: var(--good); }
.metric-delta.down { color: var(--bad); }

.pr-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pr-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 14px;
}

.pr-name { font-size: 14px; font-weight: 600; }
.pr-value { font-size: 14px; font-weight: 700; color: var(--accent); }
.pr-date { font-size: 11px; color: var(--text-dim); }

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a0f0a;
  font-weight: 900;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-name { font-size: 17px; font-weight: 700; }
.profile-sub { font-size: 13px; color: var(--text-dim); }

.diag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.diag-row:last-child { border-bottom: none; }

.diag-label { color: var(--text-dim); }

.diag-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}

.dot.ok { background: var(--good); }
.dot.bad { background: var(--bad); }
.dot.warn { background: #fbbf24; }

.install-note {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 14px;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 14px;
  line-height: 1.5;
}

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(20, 23, 28, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
}

@media (prefers-color-scheme: light) {
  .tabbar { background: rgba(255, 255, 255, 0.88); }
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.tab .tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab.active { color: var(--accent); }

.toast {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}
