:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #eef1f6;
  --text-dim: #9aa3b2;
  --accent: #4f8cff;
  --accent-dim: #2e4a80;
  --danger: #ff5f6d;
  --success: #4fd88a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--text-dim); font-weight: 600; }

p { color: var(--text-dim); margin: 4px 0; }

.topbar {
  position: sticky;
  top: 0;
  background: rgba(15,17,21,0.9);
  backdrop-filter: blur(8px);
  padding: 14px 16px 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

button, .btn {
  font: inherit;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

button.primary { background: var(--accent); color: white; font-weight: 600; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.ghost { background: transparent; border: 1px solid var(--border); }
button.small { padding: 6px 12px; font-size: 13px; }
button:active { opacity: 0.7; }

input, textarea, select {
  width: 100%;
  font: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

label { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 4px; }

.exercise-media {
  width: 100%;
  border-radius: 10px;
  max-height: 220px;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
  margin-bottom: 10px;
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.badge {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 8px;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(23,26,33,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tabbar button {
  flex: 1;
  background: none;
  border-radius: 0;
  padding: 10px 0 8px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tabbar button.active { color: var(--accent); }
.tabbar .icon { font-size: 20px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.modal {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.set-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 10px;
}

.toast {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
}

svg.chart { width: 100%; height: 180px; }
