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

:root {
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --danger: #e53935;
  --success: #43a047;
  --bg: #f5f5f5;
  --card: #fff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --nav-height: 64px;
  --header-height: 56px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 20px;
  font-weight: 600;
  z-index: 10;
}
header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 80px;
  -webkit-overflow-scrolling: touch;
}

nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--card);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 10;
}
nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  gap: 4px;
  transition: color 0.2s;
}
nav .nav-item .nav-icon {
  font-size: 24px;
  line-height: 1;
}
nav .nav-item.active { color: var(--primary); }

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

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: none; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* Forms */
.input, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}
.input:focus, .select:focus { border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.form-group { margin-bottom: 12px; }

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }
.list-item .item-content { flex: 1; min-width: 0; }
.list-item .item-title { font-weight: 500; font-size: 15px; }
.list-item .item-sub { font-size: 13px; color: var(--text-secondary); }

/* Chips */
.chip {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px;
}
.chip .chip-close {
  margin-left: 4px;
  cursor: pointer;
  font-weight: bold;
}

/* Tags / Badges */
.badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  gap: 8px;
  transition: background 0.2s;
}
.quick-action:active { background: var(--primary-light); }
.quick-action .qa-icon { font-size: 32px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title .close {
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* Timer */
.timer {
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* Chart container */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

/* Set row in workout */
.set-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.set-row .set-label { font-size: 13px; color: var(--text-secondary); }

/* Period tabs */
.period-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.period-tabs button {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.period-tabs button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
