:root {
  --bg: #0a0a0d;
  --surface: #17171b;
  --surface-2: #202024;
  --surface-3: #29292f;
  --border: #2a2a30;
  --text: #f4f4f6;
  --text-dim: #98989f;
  --accent: #ff7a29;
  --accent-dark: #e8631a;
  --accent-text: #1a0d00;
  --accent-soft: rgba(255, 122, 41, 0.15);
  --accent-2: #38bdf8;
  --accent-2-soft: rgba(56, 189, 248, 0.15);
  --danger: #f87171;
  --success: #4ade80;
  --nav-height: 68px;
}

* { box-sizing: border-box; }

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

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 28px);
  min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 12px; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

p { color: var(--text-dim); line-height: 1.5; }

a { color: var(--accent-2); text-decoration: none; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  background: rgba(20, 20, 24, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.15s ease;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 6px;
  width: 20px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.bottom-nav .icon { font-size: 1.35rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 14px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--accent-text);
  margin-bottom: 10px;
  box-shadow: 0 6px 16px rgba(255, 122, 41, 0.28);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn:active { transform: scale(0.98); box-shadow: 0 3px 10px rgba(255, 122, 41, 0.22); }
.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:active { background: var(--surface-3); }
.btn.accent-2 {
  background: linear-gradient(135deg, var(--accent-2), #0ea5e9);
  color: #001b26;
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.28);
}
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  box-shadow: none;
}
.btn.small {
  width: auto;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.85rem;
}
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 10px 0 4px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { min-height: 70px; font-family: inherit; }

.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

.set-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.set-item .rest { color: var(--text-dim); font-size: 0.78rem; }

.exercise-block {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin-bottom: 16px;
}

.pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 6px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.pill.accent-2.active {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.timer {
  font-size: 2.4rem;
  font-weight: 800;
  text-align: center;
  margin: 6px 0 14px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
}

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.chart-wrap { position: relative; height: 240px; margin-bottom: 10px; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { color: var(--text-dim); font-size: 0.8rem; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.top-bar .back {
  font-size: 1.3rem;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 10px;
  color: var(--text);
}

.hint {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.stat-value {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge.success { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge.danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.badge.accent-2 { background: var(--accent-2-soft); color: var(--accent-2); }
.badge.pr { background: var(--accent-soft); color: var(--accent); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
  border: none;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.75rem;
  cursor: pointer;
  gap: 2px;
}
.cal-cell.head {
  background: transparent;
  color: var(--text-dim);
  font-weight: 700;
  aspect-ratio: auto;
  cursor: default;
  padding: 4px 0;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.today { border: 1px solid var(--accent); }
.cal-cell.selected { background: var(--accent-soft); }
.cal-day { font-weight: 600; }
.cal-dots { display: flex; gap: 2px; height: 6px; }
.dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.dot.accent { background: var(--accent); }
.dot.accent-2 { background: var(--accent-2); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 4px 0;
}
