* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f5f6f8;
  color: #222;
}

header {
  background: #2f5d7d;
  color: #fff;
  padding: 16px;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 1.2rem;
}

.tab-bar {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #ddd;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 14px 4px;
  font-size: 0.95rem;
  font-weight: bold;
  color: #888;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

.tab-btn.active {
  color: #2f5d7d;
  border-bottom-color: #2f5d7d;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

form {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.field {
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
  min-width: 0;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 6px;
  color: #444;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #2f5d7d;
}

textarea {
  resize: vertical;
}

.group {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  margin: 0 0 16px;
}

.group legend {
  font-size: 0.9rem;
  font-weight: bold;
  color: #444;
  padding: 0 6px;
}

.hint {
  font-size: 0.8rem;
  color: #888;
  margin: 0 0 12px;
}

.empty {
  text-align: center;
  color: #888;
  font-size: 0.85rem;
}

.cardio-type-row {
  margin-bottom: 12px;
}

.radio-label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: normal;
  color: #333;
  margin-bottom: 10px;
}

.radio-label input,
.checkbox-label input {
  width: auto;
  padding: 0;
}

#save-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
  background: #2f5d7d;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#save-btn:active {
  background: #234a64;
}

.save-message {
  text-align: center;
  color: #2f5d7d;
  font-weight: bold;
  font-size: 0.9rem;
  margin: 12px 0 0;
  min-height: 1.2em;
}

.secondary-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: bold;
  color: #2f5d7d;
  background: #fff;
  border: 1px solid #2f5d7d;
  border-radius: 8px;
  cursor: pointer;
}

.secondary-btn:active {
  background: #eaf1f6;
}

.delete-btn {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #c0392b;
  background: #fff;
  border: 1px solid #c0392b;
  border-radius: 8px;
  cursor: pointer;
}

.delete-btn:active {
  background: #fbeae8;
}

/* 筋トレマシン選択(今日の記録) */

.strength-row {
  border-top: 1px solid #eee;
  padding: 12px 0;
}

.strength-row:first-child {
  border-top: none;
}

.strength-check {
  margin-bottom: 8px;
  font-weight: bold;
}

.strength-inputs .field {
  margin-bottom: 0;
}

#strength-empty {
  color: #888;
  font-size: 0.85rem;
}

/* スクワット(今日の記録・固定表示) */

.squat-row {
  border-bottom: 2px solid #ddd;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.squat-row-label {
  font-weight: bold;
  margin-bottom: 8px;
}

.squat-checks {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* スクワット(プロフィール・固定カード) */

.squat-profile-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  background: #fafafa;
}

.squat-profile-name {
  font-weight: bold;
  margin-bottom: 4px;
}

/* 今日の食事(摂取カロリー実績) */

.meal-row {
  border-top: 1px solid #eee;
  padding: 12px 0;
}

.meal-row:first-child {
  border-top: none;
}

.meal-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.meal-row-label {
  font-weight: bold;
  color: #444;
}

.meal-row-total {
  font-weight: bold;
  color: #2f5d7d;
}

.meal-entries-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.meal-entries-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.85rem;
}

.meal-entry-name {
  flex: 1;
  color: #333;
}

.meal-entry-kcal {
  font-weight: bold;
  color: #2f5d7d;
}

.meal-entry-remove {
  flex: 0 0 auto;
  width: 1.8em;
  height: 1.8em;
  line-height: 1;
  padding: 0;
  font-size: 0.9rem;
  font-weight: bold;
  color: #c0392b;
  background: #fff;
  border: 1px solid #c0392b;
  border-radius: 50%;
  cursor: pointer;
}

.meal-entry-remove:active {
  background: #fbeae8;
}

.meal-select-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.meal-select-row .meal-select {
  flex: 1;
  min-width: 0;
}

.meal-qty {
  flex: 0 0 4.5em;
  width: 4.5em;
}

.meal-select-add {
  flex: 0 0 auto;
  width: auto;
  padding: 0 16px;
}

.meal-custom-row {
  display: flex;
  gap: 8px;
}

.meal-custom-row input {
  flex: 1;
}

.meal-custom-add {
  flex: 0 0 auto;
  width: auto;
  padding: 0 16px;
}

/* 推定カロリー(今日の記録) */

.calorie-line[hidden] {
  display: none;
}

.calorie-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #eee;
  font-size: 0.9rem;
}

.calorie-line:first-of-type {
  border-top: none;
}

.calorie-label {
  color: #555;
}

.calorie-value {
  font-weight: bold;
  color: #2f5d7d;
}

.calorie-value.calorie-ok {
  color: #2e7d4f;
}

.calorie-value.calorie-over {
  color: #c0392b;
}

#calorie-profile-hint {
  margin: 8px 0 0;
}

/* 記録一覧 */

#records-list,
#machines-list,
#cardio-list,
#meal-items-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

#records-list li,
#machines-list li,
#cardio-list li,
#meal-items-list li {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-size: 0.9rem;
  line-height: 1.6;
}

#records-list li[data-date] {
  cursor: pointer;
}

#records-list li[data-date]:active {
  background: #eaf1f6;
}

.record-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-date {
  font-weight: bold;
  color: #2f5d7d;
}

.record-summary {
  color: #555;
  font-size: 0.85rem;
  margin-top: 2px;
}

#records-list .empty,
#machines-list .empty {
  text-align: center;
  color: #888;
  box-shadow: none;
}

#records-toggle {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #2f5d7d;
  background: #fff;
  border: 1px solid #2f5d7d;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 16px;
}

#records-toggle:active {
  background: #eaf1f6;
}

/* バックアップ */

#backup-section {
  margin-top: 24px;
}

.backup-buttons {
  display: flex;
  gap: 12px;
}

.backup-buttons .secondary-btn {
  flex: 1;
}

/* サマリー画面 */

.streak-box {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.streak-item {
  flex: 1;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.streak-label {
  display: block;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 4px;
}

.streak-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #2f5d7d;
}

.selector-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.selector-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #444;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 20px;
  cursor: pointer;
}

.selector-btn.active {
  color: #fff;
  background: #2f5d7d;
  border-color: #2f5d7d;
}

.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.nav-btn {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #2f5d7d;
  background: #fff;
  border: 1px solid #2f5d7d;
  border-radius: 20px;
  cursor: pointer;
}

.nav-btn:active {
  background: #eaf1f6;
}

.nav-btn:disabled {
  color: #aaa;
  border-color: #ccc;
  background: #fff;
  cursor: default;
}

.range-label {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  color: #444;
  font-weight: bold;
}

.summary-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 4px 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid #eee;
  font-size: 0.85rem;
}

.summary-list li:first-child {
  border-top: none;
}

.summary-label {
  color: #555;
}

.summary-value {
  font-weight: bold;
  color: #222;
  text-align: right;
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 8px;
}

.progress-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-table th,
.progress-table td {
  padding: 10px;
  font-size: 0.8rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
  line-height: 1.4;
}

.progress-table th {
  background: #f0f3f5;
  color: #444;
}

.progress-table tr:last-child td {
  border-bottom: none;
}

/* プロフィール画面 */

#view-profile h2,
#view-profile h3,
#view-summary h3 {
  font-size: 1rem;
  color: #444;
  margin: 20px 0 4px;
}

#view-profile h2:first-child {
  margin-top: 0;
}

.machine-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.machine-row-footer .checkbox-label {
  margin: 0;
}

.list-item-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

#machines-list .field,
#cardio-list .field,
#meal-items-list .field {
  margin-bottom: 10px;
}

#machines-list .field label,
#cardio-list .field label,
#meal-items-list .field label {
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.reference-hint {
  font-size: 0.72rem;
  color: #888;
  margin: 4px 0 0;
  line-height: 1.4;
}
