
:root {
  --red: #e53935;
  --gray: #f3f3f3;
  --text: #181818;
  --muted: #858585;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", sans-serif;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: white;
}

main {
  padding: max(16px, env(safe-area-inset-top)) 20px 110px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

h1 {
  margin: 0 0 26px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

/* ===== カレンダー ===== */

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.calendar-header h2 {
  margin: 0;
  font-size: 19px;
}

.calendar-header button {
  border: 0;
  background: none;
  font-size: 32px;
  padding: 0 12px;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
}

.weekdays {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.calendar-grid {
  row-gap: 12px;
}

.calendar-grid button,
.calendar-grid .blank {
  width: 38px;
  height: 38px;
  margin: auto;
}

.calendar-grid button {
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.calendar-grid button.trained {
  background: var(--red);
  color: white;
}

.calendar-grid button.today:not(.trained) {
  outline: 1px solid var(--red);
}

.calendar-stats {
  margin-top: 36px;
}

.calendar-stats p {
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  margin: 0;
  border-bottom: 1px solid #eee;
  font-size: 15px;
}

/* ===== 身体データ ===== */

.chart-section {
  margin-bottom: 16px;
}

.chart-section h2 {
  margin: 0 0 5px;
  font-size: 15px;
}

.chart {
  height: 130px;
  width: 100%;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #999;
  font-size: 13px;
}

.primary-button {
  display: block;
  width: 100%;
  padding: 15px 18px;
  margin-top: 18px;
  border: 0;
  border-radius: 28px;
  background: var(--red);
  color: white;
  font-size: 16px;
  font-weight: 700;
}

/* ===== ルーティン共通 ===== */

.routine-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  margin-bottom: 22px;
}

.routine-header h1 {
  flex: 1;
  margin: 0;
  padding: 0 8px;
  font-size: 20px;
}

.back-button {
  flex: 0 0 34px;
  width: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 34px;
  line-height: 1;
}

.header-add {
  flex: 0 0 46px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 15px;
  font-weight: 600;
}

.header-spacer {
  flex: 0 0 34px;
}

/* ===== ① 部位一覧 ===== */

.muscle-group-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.muscle-group-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 94px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--gray);
  text-align: left;
}

.muscle-group-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 68px;
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.muscle-group-icon svg {
  display: block;
  width: 54px;
  height: 62px;
}

.muscle-group-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.muscle-group-name {
  font-size: 17px;
  font-weight: 700;
}

.muscle-group-count {
  color: var(--muted);
  font-size: 12px;
}

.muscle-group-arrow {
  color: #999;
  font-size: 24px;
}

/* ===== ② 部位別ルーティン ===== */

.muscle-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  margin-bottom: 22px;
  border-radius: 16px;
  background: #f7f7f7;
}

.muscle-hero svg {
  display: block;
  height: 195px;
  max-width: 100%;
}

.routine-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding: 14px;
  border-radius: 12px;
  background: var(--gray);
}

.exercise-name {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
}

.exercise-summary {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.exercise-remove {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #999;
  font-size: 20px;
}

.exercise-empty {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

/* ===== ③ 種目詳細・セット記録 ===== */

.sets-page-form {
  padding-top: 10px;
}

.sets-column-headings,
.set-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.sets-column-headings {
  margin-bottom: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}

.set-row {
  margin-bottom: 22px;
}

.set-number {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.set-row input {
  width: 100%;
  min-width: 0;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid #ccc;
  border-radius: 0;
  background: transparent;
  outline: none;
  text-align: center;
  font-size: 16px;
}

.set-row input:focus {
  border-bottom: 2px solid var(--red);
}

.add-set-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--gray);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.add-set-plus {
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
}

.sets-page-form > .primary-button {
  margin-top: 36px;
}

/* ===== BIG3 ===== */

.big3-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 18px;
}

.big3-tabs button {
  flex: 1;
  min-width: 0;
  padding: 12px 2px;
  border: 0;
  border-radius: 9px;
  background: var(--gray);
  font-size: 11px;
}

.big3-tabs button.selected {
  background: var(--red);
  color: white;
}

.record-card {
  width: 52%;
  padding: 12px;
  margin: 0 auto 18px;
  border-radius: 12px;
  background: var(--gray);
  text-align: center;
}

.record-card span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.record-card strong {
  font-size: 23px;
}

.big3-chart {
  height: 250px;
}

/* ===== 設定 ===== */

.settings-heading {
  margin-top: 36px;
  color: var(--muted);
  font-size: 14px;
}

.settings-item {
  display: block;
  width: 100%;
  padding: 18px;
  margin-bottom: 10px;
  border: 0;
  border-radius: 12px;
  background: var(--gray);
  text-align: left;
}

.danger-button {
  display: block;
  margin-top: 36px;
  padding: 12px 0;
  border: 0;
  background: none;
  color: var(--red);
  font-weight: 600;
}

/* ===== ボトムナビ ===== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  width: 100%;
  max-width: 430px;
  padding: 10px 4px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid #eee;
  background: white;
  z-index: 10;
}

.bottom-nav button {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  color: #999;
  font-size: 10px;
}

.bottom-nav button.active {
  color: var(--red);
}

.nav-icon {
  font-size: 23px;
  line-height: 1.2;
}

/* ===== 入力ダイアログ ===== */

.sheet {
  position: fixed;
  top: auto;
  bottom: 0;
  width: 100%;
  max-width: 430px;
  max-height: 85dvh;
  margin: 0 auto;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 22px 22px 0 0;
  overflow-y: auto;
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.sheet h2 {
  margin: 0 0 22px;
  text-align: center;
  font-size: 19px;
}

.sheet label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}

.sheet input {
  display: block;
  width: 100%;
  padding: 12px 4px;
  margin-top: 6px;
  border: 0;
  border-bottom: 1px solid #ccc;
  border-radius: 0;
  background: white;
  font-size: 16px;
}

.cancel-button {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 0;
  background: none;
  color: var(--muted);
}

/* ===== 小画面対応 ===== */

@media (max-width: 360px) {
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .muscle-group-card {
    gap: 12px;
    padding: 10px 12px;
  }

  .sets-column-headings,
  .set-row {
    grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }
}
