/* ===========================================
   タカハシ・トレーニング 共通スタイル
   セージグリーン × アンバー、明るい・落ち着いた・モバイル第一
   =========================================== */

:root {
  /* カラーパレット */
  --sage-50:  #f3f6f2;
  --sage-100: #e2ebe0;
  --sage-200: #c4d7c0;
  --sage-300: #9fbf99;
  --sage-400: #7fa78a;  /* プライマリ */
  --sage-500: #5f8a6c;
  --sage-600: #487055;
  --sage-700: #365844;

  --amber-300: #e8b75a;
  --amber-400: #d89e3a;  /* アクセント */
  --amber-500: #b8801f;

  --bg:        #fafaf7;
  --surface:   #ffffff;
  --ink:       #2a2e2c;
  --ink-mute:  #6a6e6b;
  --line:      #e4e4de;
  --danger:    #c64b48;
  --success:   #5f8a6c;
  --warn:      #d89e3a;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(40, 50, 45, 0.06), 0 1px 3px rgba(40, 50, 45, 0.04);
  --shadow-md: 0 4px 12px rgba(40, 50, 45, 0.08), 0 2px 4px rgba(40, 50, 45, 0.04);
  --shadow-lg: 0 10px 25px rgba(40, 50, 45, 0.1),  0 4px 10px rgba(40, 50, 45, 0.05);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
               "Yu Gothic UI", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sage-500); text-decoration: none; }
a:hover { color: var(--sage-600); text-decoration: underline; }

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 var(--space-3);
}

h1 { font-size: 1.4rem; letter-spacing: 0.02em; }
h2 { font-size: 1.15rem; color: var(--sage-600); }
h3 { font-size: 1rem; color: var(--sage-500); }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ===== ヘッダー ===== */
.app-header {
  background: linear-gradient(135deg, var(--sage-400) 0%, var(--sage-500) 100%);
  color: #fff;
  padding: var(--space-5) var(--space-4) var(--space-4);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.app-header h1 {
  color: #fff;
  font-size: 1.15rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.app-header .logo {
  font-size: 1.3em;
}
.app-header .sub {
  opacity: 0.9;
  font-size: 0.85rem;
  font-weight: 400;
}

/* ===== カード ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}
.card-header h2 { margin: 0; }

/* ===== バッジ / タグ ===== */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--sage-100);
  color: var(--sage-600);
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.tag-amber { background: #fbecc9; color: var(--amber-500); }
.tag-muted { background: var(--line); color: var(--ink-mute); }

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;  /* タップしやすさ */
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-primary {
  background: var(--sage-500);
  color: #fff;
}
.btn-primary:hover { background: var(--sage-600); }
.btn-primary:active { background: var(--sage-700); }

.btn-amber {
  background: var(--amber-400);
  color: #fff;
}
.btn-amber:hover { background: var(--amber-500); }

.btn-outline {
  background: transparent;
  color: var(--sage-600);
  border-color: var(--sage-300);
}
.btn-outline:hover { background: var(--sage-50); }

.btn-ghost {
  background: transparent;
  color: var(--ink-mute);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--sage-50); color: var(--sage-600); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; min-height: auto; }
.btn-block { width: 100%; }

/* ===== 入力 ===== */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--sage-400);
  box-shadow: 0 0 0 3px rgba(127, 167, 138, 0.2);
}
label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 4px;
}
.field { margin-bottom: var(--space-3); }

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

/* ===== 種目カード（メニュー用） ===== */
.exercise {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  overflow: hidden;
  transition: all 0.2s;
}
.exercise.done {
  background: var(--sage-50);
  border-color: var(--sage-300);
}
.exercise-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
}
.exercise-head:hover { background: var(--sage-50); }
.exercise-check {
  width: 26px;
  height: 26px;
  border: 2px solid var(--sage-300);
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  cursor: pointer;
}
.exercise.done .exercise-check {
  background: var(--sage-500);
  border-color: var(--sage-500);
}
.exercise-check::after {
  content: "";
  width: 14px;
  height: 8px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) translateY(-2px);
  opacity: 0;
  transition: opacity 0.15s;
}
.exercise.done .exercise-check::after { opacity: 1; }

.exercise-info { flex: 1; min-width: 0; }
.exercise-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 2px;
}
.exercise.done .exercise-name {
  color: var(--sage-700);
  text-decoration: line-through;
  text-decoration-color: var(--sage-300);
}
.exercise-meta {
  font-size: 0.85rem;
  color: var(--ink-mute);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.exercise-sets {
  font-weight: 700;
  color: var(--amber-500);
  font-size: 0.95rem;
}
.exercise-expand {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-mute);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.exercise.open .exercise-expand { transform: rotate(180deg); }

.exercise-body {
  display: none;
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
  background: #fcfcf9;
}
.exercise.open .exercise-body { display: block; }
.exercise-target {
  font-size: 0.85rem;
  color: var(--sage-600);
  margin-bottom: var(--space-2);
  font-weight: 600;
}
.exercise-hint {
  font-size: 0.9rem;
  color: var(--ink);
  background: #fff;
  padding: var(--space-3);
  border-left: 3px solid var(--amber-300);
  border-radius: 4px;
  margin-bottom: var(--space-3);
  line-height: 1.7;
}
.exercise-steps {
  margin: 0;
  padding-left: var(--space-5);
  font-size: 0.9rem;
  line-height: 1.7;
}
.exercise-steps li { margin-bottom: 4px; }
.exercise-coach-note {
  background: #fbecc9;
  color: var(--amber-500);
  padding: var(--space-2) var(--space-3);
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: var(--space-2);
  font-weight: 600;
}

/* ===== ストリーク / 統計 ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--sage-500);
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat-value.amber { color: var(--amber-400); }
.stat-label {
  font-size: 0.75rem;
  color: var(--ink-mute);
  letter-spacing: 0.03em;
}

/* ===== カレンダー（月間ヒートマップ） ===== */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: var(--space-3);
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--sage-50);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--ink-mute);
  position: relative;
}
.cal-day.done {
  background: var(--sage-300);
  color: #fff;
  border-color: var(--sage-400);
  font-weight: 700;
}
.cal-day.today {
  box-shadow: 0 0 0 2px var(--amber-400);
  font-weight: 700;
}
.cal-day.empty { visibility: hidden; }
.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  font-size: 0.7rem;
  color: var(--ink-mute);
  text-align: center;
  font-weight: 600;
}

/* ===== モーダル ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30, 35, 32, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: var(--space-5);
}
.modal h3 { margin-top: 0; color: var(--sage-600); }

/* ===== 管理画面 ===== */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
@media (max-width: 640px) {
  .admin-layout { grid-template-columns: 1fr; }
}

.cust-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  box-shadow: var(--shadow-sm);
}
.cust-item {
  padding: var(--space-2) var(--space-3);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 2px;
}
.cust-item > :last-child { white-space: nowrap; flex-shrink: 0; }
.cust-item:hover { background: var(--sage-50); }
.cust-item.active { background: var(--sage-100); color: var(--sage-700); font-weight: 700; }
.cust-item .cust-meta { font-size: 0.75rem; color: var(--ink-mute); font-weight: 400; }

/* ===== メニュー履歴 ===== */
.menu-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  background: #fff;
  flex-wrap: wrap;
}
.menu-history-item.editing {
  border-color: var(--sage-400);
  background: var(--sage-50);
}
.menu-history-info { flex: 1; min-width: 180px; }
.menu-history-title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.menu-history-title .tag { font-size: 0.7rem; padding: 2px 6px; }
.menu-history-meta { font-size: 0.8rem; color: var(--ink-mute); margin-top: 2px; }
.menu-history-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.day-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  background: #fcfcf9;
}
.day-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.menu-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.menu-item:last-child { border-bottom: none; }
.menu-item input[type=text], .menu-item input[type=number] {
  padding: 6px 8px;
  font-size: 0.9rem;
}
.menu-item .item-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.menu-item .item-weight { width: 90px; }
.menu-item .item-reps { width: 90px; }

/* モバイルでは 2 行レイアウト：1 行目に種目名、2 行目に重さ/回数/セット/操作 */
@media (max-width: 640px) {
  .menu-item[data-i] {
    grid-template-columns: 1fr 1fr auto auto;
    row-gap: 6px;
  }
  .menu-item[data-i] .item-name {
    grid-column: 1 / -1;
  }
  .menu-item[data-i] .item-weight { width: 100%; }
  .menu-item[data-i] .item-reps { width: 100%; }
}

/* ===== ユーティリティ ===== */
.flex { display: flex; gap: var(--space-2); align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.flex-col { display: flex; flex-direction: column; gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.text-mute { color: var(--ink-mute); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ===== トースト ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 200;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== フッター ===== */
.app-footer {
  text-align: center;
  padding: var(--space-5) var(--space-4);
  color: var(--ink-mute);
  font-size: 0.8rem;
}
.app-footer .mark {
  color: var(--amber-400);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ===== ランディング ===== */
.hero {
  text-align: center;
  padding: var(--space-7) var(--space-4) var(--space-6);
  background: linear-gradient(135deg, var(--sage-50), #fff);
}
.hero h1 {
  font-size: 2rem;
  color: var(--sage-600);
  margin-bottom: var(--space-3);
}
.hero p { color: var(--ink-mute); font-size: 1rem; }

/* ===== レスポンシブ調整 ===== */
@media (max-width: 480px) {
  .container { padding: 0 var(--space-3); }
  .stats-row { gap: var(--space-2); }
  .stat-value { font-size: 1.35rem; }
  h1 { font-size: 1.2rem; }
  .exercise-head { padding: var(--space-3); }
}

/* ===== アクセシビリティ ===== */
:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
