/* 個人トレーニングサポート（ベース）の見た目。
   社内のデザイン基準（eu-phoria Design Standard v1 のアプリ UI）に合わせる。値はこの :root に1か所で持つ。
   - 文字は rem（基準 16px）。px 換算が偶数の梯子（12/14/16/18/20/24/28/32）に乗るようにする
   - 本文 16px・最小 12px。#777777 より薄い灰色は文字に使わない
   - 文字の大きさの切り替え（自分の画面）は :root の font-size を変える（html.text-large）
   - ボクシングの減量の配色（赤・紺・金）は、その個別対応の CSS だけで使う */
:root {
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  --fs-12: 0.75rem;
  --fs-14: 0.875rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-20: 1.25rem;
  --fs-24: 1.5rem;
  --fs-32: 2rem;
  --lh-body: 1.7;
  --lh-ui: 1.3;

  --c-heading: #1a1a1a;   /* 約 17:1 */
  --c-body: #1a1a1a;
  --c-sub: #555555;       /* 約 7.5:1 */
  --c-caption: #777777;   /* 約 4.5:1。下限 */
  --c-border: #cccccc;
  --c-bg: #f3f4f6;
  --c-card: #ffffff;
  --c-sunken: #eceef1;
  --c-primary: #1f4e79;   /* 主なボタン（白い文字で約 8.7:1） */
  --c-primary-ink: #ffffff;
  --c-danger: #b42318;    /* 消す・抜ける（約 6.4:1） */
  --c-ok-bg: #e6f4ea;
  --c-ok: #1e6b3a;
  --c-warn-bg: #fff4d6;
  --c-warn: #6b4e00;
  --c-error-bg: #fdecea;
  --c-error: #9b1c13;

  --sp-8: 0.5rem;
  --sp-16: 1rem;
  --sp-24: 1.5rem;
  --sp-32: 2rem;
  --radius: 0.75rem;
  --tap: 3rem; /* 48px。指で押しやすい高さ */
  color-scheme: light;
}
html { font-size: 100%; }
html.text-large { font-size: 112.5%; } /* 18px */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-body);
  font-family: var(--font);
  font-size: var(--fs-16);
  line-height: var(--lh-body);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0; color: var(--c-heading); font-weight: 700; line-height: var(--lh-ui); }
h1 { font-size: var(--fs-20); }
h2 { font-size: var(--fs-18); }
h3 { font-size: var(--fs-16); }
p { margin: 0 0 var(--sp-16); }
p:last-child { margin-bottom: 0; }
a { color: var(--c-primary); }
.num { font-variant-numeric: tabular-nums; }

/* ===== 骨組み ===== */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-16);
  padding: var(--sp-8) var(--sp-16);
  background: var(--c-card); border-bottom: 1px solid var(--c-border);
}
.topbar .app-name { font-size: var(--fs-16); font-weight: 700; line-height: var(--lh-ui); }
.topbar .date { font-size: var(--fs-14); color: var(--c-sub); }
main { max-width: 40rem; margin: 0 auto; padding: var(--sp-16) var(--sp-16) 6rem; }
main.no-tabs { padding-bottom: var(--sp-32); }
.card {
  background: var(--c-card); border-radius: var(--radius);
  padding: var(--sp-24); margin-bottom: var(--sp-16);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.card > h2 { margin-bottom: var(--sp-16); }
.stack > * + * { margin-top: var(--sp-16); }
.sub { color: var(--c-sub); }
.caption { color: var(--c-caption); font-size: var(--fs-14); }
.hidden { display: none !important; }

/* 画面の下のタブ */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--c-card); border-top: 1px solid var(--c-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
nav.tabs ul { display: flex; max-width: 40rem; margin: 0 auto; padding: 0; list-style: none; }
nav.tabs li { flex: 1; }
nav.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 3.5rem; padding: var(--sp-8) 0;
  color: var(--c-sub); text-decoration: none; font-size: var(--fs-12); font-weight: 700; line-height: var(--lh-ui);
}
nav.tabs a[aria-current="page"] { color: var(--c-primary); }
nav.tabs svg { width: 1.5rem; height: 1.5rem; margin-bottom: 0.125rem; }

/* ===== 入力 ===== */
label { display: block; font-weight: 700; margin-bottom: var(--sp-8); line-height: var(--lh-ui); }
.field + .field { margin-top: var(--sp-16); }
.field .hint { display: block; font-weight: 400; color: var(--c-sub); font-size: var(--fs-14); margin-top: 0.25rem; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="time"], input[type="tel"], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--c-border); border-radius: 0.5rem; background: var(--c-card);
  font: inherit; color: var(--c-body); line-height: var(--lh-ui);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid #7aa7d6; outline-offset: 1px;
}
input.code { font-size: var(--fs-24); letter-spacing: 0.3em; text-align: center; }
.check { display: flex; gap: 0.75rem; align-items: flex-start; font-weight: 400; line-height: var(--lh-body); }
.check input { width: 1.5rem; height: 1.5rem; margin: 0.125rem 0 0; flex: none; }
.check + .check { margin-top: var(--sp-16); }
.radio-row { display: flex; gap: var(--sp-16); }
.radio-row label { display: flex; align-items: center; gap: var(--sp-8); font-weight: 400; margin: 0; min-height: var(--tap); }
.radio-row input { width: 1.25rem; height: 1.25rem; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-8);
  min-height: var(--tap); padding: 0.5rem 1.25rem;
  border: 1px solid var(--c-border); border-radius: 0.5rem; background: var(--c-card);
  font: inherit; font-weight: 700; color: var(--c-heading); line-height: var(--lh-ui);
  text-decoration: none; cursor: pointer;
}
button.primary, .button.primary { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-ink); }
button.danger { color: var(--c-danger); border-color: var(--c-danger); }
button.wide, .button.wide { width: 100%; }
button[disabled] { opacity: 0.6; cursor: wait; }
.actions { margin-top: var(--sp-24); display: flex; flex-direction: column; gap: var(--sp-8); }
.link-button { background: none; border: none; min-height: auto; padding: 0; color: var(--c-primary); text-decoration: underline; font-weight: 400; }

/* ===== お知らせ ===== */
.notice { border-radius: 0.5rem; padding: var(--sp-16); margin-bottom: var(--sp-16); }
.notice.ok { background: var(--c-ok-bg); color: var(--c-ok); }
.notice.warn { background: var(--c-warn-bg); color: var(--c-warn); }
.notice.error { background: var(--c-error-bg); color: var(--c-error); }
.notice:empty { display: none; }

dl.pairs { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-8) var(--sp-16); margin: 0; }
dl.pairs dt { color: var(--c-sub); }
dl.pairs dd { margin: 0; }

ol.steps { padding-left: 1.25rem; margin: 0; }
ol.steps li + li { margin-top: var(--sp-8); }
[data-gap], .gap-top { margin-top: var(--sp-16); }
h2.gap-top { margin-top: var(--sp-32); margin-bottom: var(--sp-16); }
.label-like { display: block; margin-bottom: var(--sp-8); line-height: var(--lh-ui); }

/* ===== 記録 ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-16); }
.grid2 .field + .field { margin-top: 0; }
details > summary { cursor: pointer; font-weight: 700; min-height: var(--tap); display: flex; align-items: center; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
table.list th, table.list td { padding: 0.5rem 0.375rem; border-bottom: 1px solid var(--c-border); text-align: right; white-space: nowrap; }
table.list th:first-child, table.list td:first-child { text-align: left; }
table.list th { color: var(--c-sub); font-weight: 700; }
table.list tr[aria-current="true"] td { background: var(--c-sunken); }
table.list a { display: inline-block; min-height: 2.25rem; line-height: 2.25rem; }

/* ===== 食事 ===== */
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-16); }
@media (min-width: 30rem) { .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
.grid3 .field + .field { margin-top: 0; }
.photo-preview { display: block; max-width: 100%; max-height: 15rem; margin-top: var(--sp-8); border-radius: 0.5rem; }
ul.meal-list, ul.pick-list { list-style: none; margin: 0; padding: 0; }
ul.meal-list li + li, ul.pick-list li + li { border-top: 1px solid var(--c-border); }
ul.meal-list li { padding: var(--sp-16) 0; }
ul.meal-list li:first-child { padding-top: 0; }
.meal-head { display: flex; justify-content: space-between; gap: var(--sp-16); align-items: baseline; }
.meal-name { overflow-wrap: anywhere; }
.meal-actions { display: flex; gap: var(--sp-8); margin-top: var(--sp-8); }
ul.pick-list button { width: 100%; justify-content: space-between; border: none; border-radius: 0; padding: var(--sp-16) 0; text-align: left; font-weight: 400; }

/* ===== コーチ ===== */
ul.roster { list-style: none; margin: 0; padding: 0; }
ul.roster li + li { border-top: 1px solid var(--c-border); }
ul.roster a { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-16); min-height: var(--tap); padding: var(--sp-16) 0; color: inherit; text-decoration: none; }
.roster-main { display: flex; flex-direction: column; min-width: 0; }
.roster-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex: none; }
.stage { font-size: var(--fs-12); font-weight: 700; padding: 0.125rem 0.5rem; border-radius: 0.25rem; line-height: var(--lh-ui); }
.stage-missing { background: var(--c-warn-bg); color: var(--c-warn); }
.stage-ok { background: var(--c-ok-bg); color: var(--c-ok); }
/* 個別対応が足す段階（減量の要対応・要確認） */
.stage-red { background: var(--c-error-bg); color: var(--c-error); }
.stage-amber { background: var(--c-warn-bg); color: var(--c-warn); border: 1px solid var(--c-warn); }
.stage-missing { background: var(--c-sunken); color: var(--c-body); }
ul.memo-list { margin: var(--sp-8) 0 0; padding-left: 1.25rem; }

/* 処理中の覆い（app.js の overlay）。画面全体を覆い、ほかのボタンを押せなくする */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-24);
  background: rgba(26, 26, 26, 0.45);
}
.overlay-box {
  width: 100%;
  max-width: 20rem;
  padding: var(--sp-24);
  border-radius: var(--radius);
  background: var(--c-card);
  text-align: center;
}
.overlay-label { margin: var(--sp-16) 0 0; font-size: var(--fs-16); font-weight: 700; color: var(--c-heading); }
.overlay-elapsed { margin: var(--sp-8) 0 0; font-size: var(--fs-14); color: var(--c-sub); }
.overlay-elapsed:empty { display: none; }
.spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto;
  border: 0.25rem solid var(--c-sunken);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* 動きを減らす設定の人には回さない（覆いと文言だけで伝わる） */
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--c-primary); } }
body.is-busy { overflow: hidden; }
