/* リセットとベース */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
    padding-bottom: 70px;
}

/* メインコンテンツ */
.main-content {
    padding: 16px;
    max-width: 480px;
    margin: 0 auto;
}

/* 下部ナビゲーション */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    border-top: 1px solid #ddd;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    padding: 4px 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.nav-item:active {
    background-color: #f0f0f0;
}

.nav-item.active {
    color: #4CAF50;
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    margin-top: 2px;
}

/* ヘッダー部分 */
.page-header {
    background: #4CAF50;
    color: #fff;
    padding: 16px;
    margin: -16px -16px 16px -16px;
    text-align: center;
}

.page-title {
    font-size: 18px;
    font-weight: bold;
}

/* 日付ナビゲーション */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    background: #4CAF50;
    color: #fff;
    margin: -16px -16px 16px -16px;
}

.date-nav button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

.date-nav button:active {
    background: rgba(255,255,255,0.3);
}

.date-display {
    font-size: 18px;
    font-weight: bold;
}

/* カード */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-title {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

/* 栄養素サマリー */
.nutrient-item {
    margin-bottom: 16px;
}

.nutrient-item:last-child {
    margin-bottom: 0;
}

.nutrient-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.nutrient-name {
    font-size: 14px;
    color: #666;
}

.nutrient-values {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.nutrient-current {
    font-size: 24px;
    font-weight: bold;
}

.nutrient-target {
    font-size: 14px;
    color: #999;
}

.nutrient-diff {
    font-size: 14px;
    font-weight: bold;
}

.nutrient-diff.positive {
    color: #4CAF50;
}

.nutrient-diff.negative {
    color: #f44336;
}

/* プログレスバー */
.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #4CAF50;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.over {
    background: #f44336;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 12px 24px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn:active {
    background: #45a049;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-secondary {
    background: #666;
}

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

.btn-danger {
    background: #f44336;
}

.btn-danger:active {
    background: #d32f2f;
}

/* フォーム */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.form-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
}

/* リスト */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 16px;
    font-weight: 500;
}

.list-item-subtitle {
    font-size: 13px;
    color: #999;
    margin-top: 2px;
}

.list-item-action {
    padding: 8px;
    cursor: pointer;
}

/* プリセットボタン群 */
.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.preset-btn {
    flex: 1;
    min-width: 60px;
    padding: 12px 8px;
    background: #f0f0f0;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
}

.preset-btn:active,
.preset-btn.selected {
    background: #e8f5e9;
    border-color: #4CAF50;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* 食事区分タブ */
.meal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.meal-tab {
    flex: 1;
    padding: 10px 16px;
    background: #f0f0f0;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.meal-tab.active {
    background: #4CAF50;
    color: #fff;
}

/* 検索バー */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

/* 食品リスト */
.food-list {
    max-height: 400px;
    overflow-y: auto;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.food-item:active {
    background: #f5f5f5;
}

.food-name {
    font-size: 15px;
}

.food-unit {
    font-size: 12px;
    color: #999;
}

.food-calories {
    font-size: 14px;
    color: #666;
}

/* ドラッグ＆ドロップ並び替え */
.drag-handle {
    font-size: 20px;
    color: #bbb;
    padding: 0 12px 0 0;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    touch-action: none; /* タッチ操作時のスクロール抑制 */
}

.drag-handle:active {
    cursor: grabbing;
}

/* ドラッグ中のアイテム（PC） */
.food-sortable.dragging {
    opacity: 0.3;
    background: #f0f8f0;
}

/* タッチドラッグ中の元アイテム（スマホ） */
.food-sortable.drag-ghost {
    opacity: 0.2;
}

/* ドロップ先を示すプレースホルダー */
.drag-placeholder {
    background: #e8f5e9;
    border: 2px dashed #4CAF50;
    border-radius: 8px;
    margin: 2px 0;
}

/* 保存完了トースト通知 */
.save-indicator {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(40, 40, 40, 0.85);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 500;
    white-space: nowrap;
}

.save-indicator.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* アラートメッセージ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
}

/* ユーティリティ */
.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.mb-16 {
    margin-bottom: 16px;
}

.hidden {
    display: none !important;
}

/* ============================================================
   トレーニング機能（2026-08-29 追加）
   ============================================================ */

/* 5タブ化に伴うナビの調整 */
.bottom-nav .nav-item {
    padding: 4px 6px;
    flex: 1;
    min-width: 0;
}

.bottom-nav .nav-icon {
    font-size: 22px;
}

/* フィルタ用チップ */
.chip-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.chip {
    flex-shrink: 0;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    white-space: nowrap;
}

.chip.active {
    background: #4CAF50;
    border-color: #4CAF50;
    color: #fff;
}

/* リスト内の部位見出し */
.group-label {
    font-size: 12px;
    font-weight: bold;
    color: #555;
    padding: 6px 8px;
    background: #f0f0f0;
    margin: 8px -16px 4px -16px;
    border-left: 3px solid #4CAF50;
}

/* バッジ */
.badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    vertical-align: middle;
    margin-left: 4px;
}

.badge-off  { background: #eee;    color: #888; }
.badge-done { background: #e8f5e9; color: #2e7d32; }
.badge-warn { background: #fff3e0; color: #e65100; }
.badge-ai   { background: #e3f2fd; color: #1565c0; }

/* 施設タグ */
.venue-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.venue-tag {
    font-size: 10px;
    padding: 2px 8px;
    background: #f0f4f8;
    color: #4a6572;
    border-radius: 8px;
}

.venue-tag-none {
    background: #ffebee;
    color: #c62828;
}

/* 施設選択ボタン */
.venue-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
}

.venue-btn:active {
    background: #f5f5f5;
    border-color: #4CAF50;
}

.venue-btn-name {
    display: block;
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.venue-btn-note {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* 補足ボックス */
.note-box {
    background: #f7f9fa;
    border-left: 3px solid #90a4ae;
    padding: 10px 12px;
    font-size: 12px;
    color: #555;
    border-radius: 4px;
    line-height: 1.6;
}

/* 種目ごとのセット表示 */
.ex-block {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.ex-block:last-child {
    border-bottom: none;
}

.ex-block-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.ex-block-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    text-decoration: none;
}

.ex-block-mg {
    font-size: 11px;
    color: #999;
    text-align: right;
    flex-shrink: 0;
}

.set-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.set-no {
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    font-size: 11px;
    color: #888;
    background: #f0f0f0;
    border-radius: 50%;
    flex-shrink: 0;
}

.set-value {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.set-warmup {
    color: #aaa;
}

.set-rpe {
    font-size: 11px;
    color: #999;
}

.set-delete {
    margin-left: auto;
    background: none;
    border: none;
    color: #ccc;
    font-size: 20px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
}

.set-delete:active {
    color: #f44336;
}

.set-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.set-chip {
    font-size: 12px;
    padding: 3px 8px;
    background: #f5f5f5;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}

/* 小さめボタン */
.btn-mini {
    display: block;
    width: 100%;
    padding: 8px;
    background: #f0f0f0;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    color: #555;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}

.btn-mini:active {
    background: #e0e0e0;
}

/* 数値ステッパー */
.stepper-row {
    margin-bottom: 12px;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    font-size: 22px;
    color: #555;
    cursor: pointer;
}

.stepper-btn:active {
    background: #e0e0e0;
}

.stepper-input {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

/* チェックボックス行 */
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    font-size: 14px;
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.check-note {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}

.form-hint {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    line-height: 1.5;
}

/* 前回実績 */
.last-perf {
    background: #f7f9fa;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.last-perf-title {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.last-perf-sets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.last-perf-set {
    font-size: 13px;
    padding: 2px 8px;
    background: #fff;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}

/* 統計の横並び */
.stat-row {
    display: flex;
    gap: 8px;
}

.stat {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stat-label {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
    line-height: 1.4;
}

/* 差分表示 */
.diff-up   { color: #4CAF50; }
.diff-down { color: #f44336; }
.diff-flat { color: #999; }
.diff-none { color: #ccc; }

/* 部位別サマリー */
.mg-days {
    font-size: 11px;
    color: #999;
    margin-left: 4px;
}

.mg-exercises {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

.progress-fill.short {
    background: #FFB74D;
}

/* 成長サマリーの行 */
.prog-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
}

.prog-row:last-child {
    border-bottom: none;
}

.prog-main {
    flex: 1;
    min-width: 0;
}

.prog-name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prog-sub {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.prog-spark {
    flex-shrink: 0;
    line-height: 0;
}

.prog-nums {
    flex-shrink: 0;
    text-align: right;
    min-width: 74px;
}

.prog-best {
    font-size: 15px;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.prog-diffs {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.prog-sep {
    color: #ddd;
    margin: 0 2px;
}

.legend {
    font-size: 11px;
    color: #aaa;
    margin-top: 12px;
    line-height: 1.6;
}

/* 目標セット数の編集 */
.target-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.target-name {
    flex: 1;
    font-size: 15px;
}

.target-actual {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.target-input {
    width: 80px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* グラフ */
.line-chart {
    display: block;
    max-width: 100%;
}

.chart-empty {
    text-align: center;
    color: #bbb;
    font-size: 13px;
    padding: 40px 0;
}

.sparkline {
    display: block;
}

/* ホームのトレーニングカード */
.home-workout-empty {
    font-size: 13px;
    color: #888;
    line-height: 1.7;
}

.home-short-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.home-short {
    font-size: 12px;
    padding: 3px 10px;
    background: #fff3e0;
    color: #e65100;
    border-radius: 10px;
}
