:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --card: #1e2a4a;
  --text: #e0e0e0;
  --text2: #8b95a5;
  --accent: #e94560;
  --accent2: #533483;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --gray: #6b7280;
  --radius: 12px;
  --nav-height: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + 16px);
  -webkit-tap-highlight-color: transparent;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sync-ok { background: var(--green); }
.sync-pending { background: var(--yellow); }
.sync-error { background: var(--red); }

main {
  padding: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

/* Bottom nav */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg2);
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s;
}
.nav-btn svg { fill: currentColor; }
.nav-btn.active { color: var(--accent); }

/* Date picker */
.date-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 8px;
  background: var(--card);
  border-radius: var(--radius);
}
.date-bar button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.date-bar button:active { background: rgba(255,255,255,0.1); }
.date-bar .date-display {
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}
.date-bar input[type="date"] {
  position: absolute;
  opacity: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Muscle group accordion */
.muscle-group {
  margin-bottom: 8px;
}
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 15px;
}
.group-header .arrow {
  transition: transform 0.2s;
  font-size: 12px;
}
.muscle-group.open .group-header .arrow {
  transform: rotate(90deg);
}
.group-exercises {
  display: none;
  padding: 8px 0;
}
.muscle-group.open .group-exercises {
  display: block;
}

/* Exercise card */
.exercise-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.exercise-card h3 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text);
}
.exercise-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.input-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.input-group label {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
}
.input-group input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  padding: 8px 10px;
  width: 100%;
  text-align: center;
}
.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Feeling buttons */
.feeling-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.feeling-btn {
  flex: 1;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.feeling-btn.active {
  border-color: currentColor;
  background: rgba(255,255,255,0.1);
}
.feeling-btn[data-feeling="hurts"] { color: var(--red); }
.feeling-btn[data-feeling="feels"] { color: var(--yellow); }
.feeling-btn[data-feeling="pumped"] { color: var(--green); }
.feeling-btn[data-feeling="nothing"] { color: var(--gray); }

/* Plan input */
.plan-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
}
.plan-input::placeholder { color: var(--text2); }
.plan-input:focus { outline: none; border-color: var(--accent); }

/* History view */
.exercise-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 16px;
  appearance: none;
  cursor: pointer;
}

.chart-container {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.chart-container svg {
  width: 100%;
  height: 200px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 10px;
  font-size: 14px;
}
.history-item .date { color: var(--text2); min-width: 80px; }
.history-item .stats { font-weight: 500; }
.history-item .feeling-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Exercises management */
.ex-list-group {
  margin-bottom: 16px;
}
.ex-list-group h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ex-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 10px;
  margin-bottom: 4px;
  font-size: 14px;
}
.ex-item .del-btn {
  background: none;
  border: none;
  color: var(--red);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text); }
.btn-block { width: 100%; }

.add-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.add-input-row input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
}
.add-input-row input:focus { outline: none; border-color: var(--accent); }

/* Settings */
.settings-section {
  margin-bottom: 24px;
}
.settings-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.settings-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.settings-info {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}
.empty-state p { font-size: 14px; margin-top: 8px; }
