/* 筋トレLAB — dark fitness theme */
:root {
  --bg: #0e1013;
  --surface: #171a1f;
  --surface2: #1e2229;
  --line: #262b33;
  --ink: #e8eaed;
  --ink-dim: #9aa3ad;
  --accent: #c8f14e;
  --accent-ink: #101400;
  --accent2: #4ed9f1;
  --warn: #f1b04e;
  --danger: #f1604e;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.6;
  padding-bottom: 76px;
  min-height: 100vh;
  -webkit-text-size-adjust: auto;
}
/* iOS WebView: ダブルタップ拡大を無効化。
   touch-action は継承されないので body だけに書いても子要素には効かない
   (カードやボタンをダブルタップすると拡大してしまう)。
   manipulation はスクロールとピンチズームを残すので、拡大したい人の手段は奪わない。 */
* { touch-action: manipulation; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 16px;
  background: var(--surface2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="range"] { padding: 0; height: 32px; accent-color: var(--accent); border: none; background: none; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }

/* ===== layout ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  /* ネイティブ(viewport-fit=cover): ステータスバー/ノッチ分を確保して時計と被らないように */
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(14, 16, 19, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 900; font-size: 18px; letter-spacing: 0.5px; }
.logo em { font-style: normal; color: var(--accent); }
.icon-btn { font-size: 20px; padding: 6px 10px; border-radius: 10px; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:active { background: var(--surface2); }

main { max-width: 560px; margin: 0 auto; padding: 14px; }
.view { display: none; }
.view.active { display: block; animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: rgba(20, 23, 28, 0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--ink-dim); font-size: 10.5px; font-weight: 600;
  padding: 4px 0; border-radius: 10px;
}
.tabbar a .ticon { display: block; font-size: 20px; line-height: 1.3; }
.tabbar a.active { color: var(--accent); }

/* ===== cards ===== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 15px; font-weight: 800; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { font-size: 11px; color: var(--ink-dim); font-weight: 600; margin-left: auto; }
.card-note { font-size: 11.5px; color: var(--ink-dim); margin-top: 8px; }

.hero-num { font-size: 40px; font-weight: 900; line-height: 1.1; color: var(--accent); }
.hero-num small { font-size: 16px; color: var(--ink); font-weight: 700; }

.stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-tile {
  flex: 1; min-width: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 12px;
}
.stat-tile .k { font-size: 11px; color: var(--ink-dim); font-weight: 700; white-space: nowrap; }
.stat-tile .v { font-size: 22px; font-weight: 900; white-space: nowrap; }
.stat-tile .v em { font-style: normal; color: var(--accent); }
.stat-tile .v small { font-size: 12px; font-weight: 700; color: var(--ink-dim); }

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 15px;
  border-radius: 12px; padding: 13px 18px; width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; }
.btn.ghost { background: var(--surface2); color: var(--ink); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 10px; flex: 0 0 auto; white-space: nowrap; }
.btn.danger { background: var(--danger); color: #fff; }
/* Sign in with Apple (HIG: 黒地・白文字・Appleロゴ) */
.btn-apple { background: #000; color: #fff; border: 1px solid #000; }

/* ===== ペイウォール ===== */
.pw-card { background: linear-gradient(135deg, var(--surface2), var(--surface)); border-color: var(--accent); }
.paywall { position: relative; text-align: center; }
.pw-close { position: absolute; top: -4px; right: -4px; font-size: 20px; width: 32px; height: 32px; border-radius: 50%; background: var(--surface2); color: var(--ink-dim); }
.pw-hero { padding: 4px 0 8px; }
.pw-badge { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 11px; letter-spacing: 2px; padding: 4px 12px; border-radius: 999px; }
.pw-title { font-size: 21px; font-weight: 900; margin-top: 8px; }
.pw-title span { color: var(--accent); }
.pw-sub { color: var(--ink-dim); font-size: 13px; margin-top: 4px; }
.pw-benefits { list-style: none; text-align: left; margin: 14px 0; display: flex; flex-direction: column; gap: 9px; }
.pw-benefits li { display: flex; gap: 12px; align-items: flex-start; }
.pw-ico { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }
.pw-benefits b { display: block; font-size: 14px; }
.pw-benefits small { color: var(--ink-dim); font-size: 12px; line-height: 1.4; }
.pw-price { background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 4px 0 14px; }
.pw-trial { color: var(--accent); font-weight: 800; font-size: 15px; }
.pw-amount { font-size: 20px; font-weight: 900; margin-top: 4px; }
.pw-amount small { display: block; font-size: 11.5px; color: var(--ink-dim); font-weight: 500; margin-top: 3px; }
.pw-cta { font-size: 16px; padding: 15px; box-shadow: 0 6px 18px rgba(200, 241, 78, 0.22); }
.pw-terms { font-size: 12px; color: var(--ink); font-weight: 600; text-align: center; margin: 8px 4px 0; line-height: 1.5; }
/* CTA+料金説明を最下部に固定。小型iPhone(375x667)でボタンが画面外に出て
   「押せるものが何も無い」状態になるのを防ぐ(入口ゲートでは×も出ないため致命的) */
.pw-foot {
  position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); z-index: 2;
  margin-top: 12px; padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); box-shadow: 0 -12px 16px 10px var(--surface);
}
.pw-legal { font-size: 11px; color: var(--ink-dim); margin: 8px 0 12px; line-height: 1.5; }
.pw-legal a { color: var(--accent2); }
/* プラン選択(月/年) */
.pw-plans { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.pw-plan { position: relative; text-align: left; background: var(--surface2); border: 2px solid var(--line); border-radius: 14px; padding: 13px 14px; width: 100%; }
.pw-plan.sel { border-color: var(--accent); background: rgba(200, 241, 78, 0.08); }
.pw-plan-badge { position: absolute; top: -9px; right: 12px; background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 800; padding: 2px 9px; border-radius: 999px; }
.pw-plan-main { display: flex; align-items: baseline; justify-content: space-between; }
.pw-plan-main b { font-size: 15px; }
.pw-plan-price { font-size: 18px; font-weight: 900; }
.pw-plan-price small { font-size: 12px; font-weight: 600; color: var(--ink-dim); }
.pw-plan-per { font-size: 12px; color: var(--accent); font-weight: 700; margin-top: 3px; }

/* segmented control */
.seg { display: flex; background: var(--surface2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 9px 4px; border-radius: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-dim);
  white-space: nowrap;
}
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 0 30%; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-dim); margin-bottom: 6px; }
.field .range-val { float: right; color: var(--accent); font-weight: 800; font-size: 13px; }

/* ===== body map ===== */
.bodymap-wrap { display: flex; justify-content: center; gap: 8px; }
.bodymap { width: 46%; max-width: 150px; }
.bodymap svg { width: 100%; height: auto; display: block; }
.bm-region { fill: #2a2f38; stroke: #3a414c; stroke-width: 1; cursor: pointer; transition: fill 0.15s; }
.bm-region.grow { fill: var(--accent); stroke: var(--accent); }
.bm-region.tone { fill: var(--accent2); stroke: var(--accent2); }
.bm-region.exclude { fill: #1c2028; stroke: #4a515c; stroke-dasharray: 3 2; opacity: .5; }
.bm-base { fill: #1b1f26; stroke: #2c323b; stroke-width: 1; }
.bm-label { text-align: center; font-size: 11px; color: var(--ink-dim); font-weight: 700; margin-top: 4px; }
.bm-legend { display: flex; gap: 14px; justify-content: center; margin-top: 10px; font-size: 12px; font-weight: 700; }
.bm-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.focus-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-block; white-space: nowrap;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--line);
}
/* 体組成の内訳: ラベルと分離しピルを崩さず横並び */
.bc-breakdown { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }

/* 睡眠行: タップできるリスト行(HIG 44pt) */
.sleep-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 4px 10px; margin: 2px -10px;
  font-size: 13.5px; color: var(--ink-dim);
  border-radius: 10px; cursor: pointer;
}
.sleep-row:active { background: var(--surface2); }
.sleep-edit { flex-shrink: 0; color: var(--accent2); font-size: 12.5px; font-weight: 700; }

/* カードカスタマイズモーダル */
.cc-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.cc-row.off .cc-name { color: var(--ink-dim); text-decoration: line-through; }
.cc-eye { font-size: 18px; width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); flex-shrink: 0; }
.cc-name { flex: 1; font-size: 13.5px; font-weight: 700; min-width: 0; }
.cc-mv { width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); font-weight: 800; flex-shrink: 0; }
.cc-mv:disabled { opacity: 0.3; }

/* 実績バッジ */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; opacity: 0.55; }
.badge.on { opacity: 1; border-color: var(--accent); }
.badge .bi { font-size: 24px; }
.badge .bn { font-size: 11px; font-weight: 800; margin-top: 2px; }
.badge .bd { font-size: 9.5px; color: var(--ink-dim); margin-top: 1px; line-height: 1.35; }

/* 目標1RMの進捗バー */
.goal-box { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.goal-bar { height: 8px; background: var(--bg); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.goal-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

/* 種目の埋め込み動画(16:9) */
.ex-video { position: relative; width: 100%; aspect-ratio: 16 / 9; margin-bottom: 12px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.ex-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
.chip.grow { border-color: var(--accent); color: var(--accent); }
.chip.tone { border-color: var(--accent2); color: var(--accent2); }
.chip.exclude { border-color: var(--ink-dim); color: var(--ink-dim); text-decoration: line-through; opacity: .85; }

/* ===== plan ===== */
.plan-day { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.plan-day-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; background: var(--surface2);
  font-weight: 800; font-size: 14px;
}
.plan-day-head .wd {
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 900; border-radius: 7px; padding: 2px 8px;
}
.plan-day-head .mins { margin-left: auto; font-size: 12px; color: var(--ink-dim); font-weight: 700; }
.plan-ex { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.plan-ex .nm { font-size: 13.5px; font-weight: 700; }
.plan-ex .nm .pri { color: var(--accent); font-size: 11px; margin-left: 4px; }
.plan-ex .meta { font-size: 11.5px; color: var(--ink-dim); }
.plan-ex .setrep { margin-left: auto; text-align: right; font-size: 13px; font-weight: 800; white-space: nowrap; }
.plan-ex .setrep small { display: block; font-size: 10.5px; color: var(--ink-dim); font-weight: 600; }

/* volume bars */
.vol-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 12px; }
.vol-row .nm { width: 70px; font-weight: 700; color: var(--ink-dim); }
.vol-row .bar { flex: 1; height: 14px; background: var(--surface2); border-radius: 7px; overflow: hidden; position: relative; }
.vol-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 7px; }
.vol-row .val { width: 100px; font-weight: 700; text-align: right; }
.vol-row .val .tag { font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; font-weight: 800; }
.tag.good { background: rgba(200,241,78,0.15); color: var(--accent); }
.tag.low { background: rgba(78,217,241,0.15); color: var(--accent2); }
.tag.high { background: rgba(241,176,78,0.15); color: var(--warn); }
.tag.junk { background: rgba(241,96,78,0.18); color: var(--danger); }
.tag.none { background: var(--surface2); color: var(--ink-dim); }

/* ===== home ===== */
/* ホーム種目行: 2段構成(上=種目名、下=入力群)で種目名を最優先に */
.today-ex { padding: 12px 0; border-bottom: 1px solid var(--line); }
.today-ex:last-of-type { border-bottom: none; }
.today-ex .ex-top { display: flex; align-items: flex-start; gap: 9px; }
.today-ex .info { flex: 1; min-width: 0; }
.today-ex .nm { font-weight: 700; font-size: 15px; line-height: 1.35; }
.today-ex .meta { font-size: 11.5px; color: var(--ink-dim); margin-top: 1px; }
.today-ex .ex-ctrl { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; padding-left: 33px; }
.today-ex input.winp { flex: 0 0 64px; width: 64px; text-align: right; padding: 10px 8px; font-size: 15px; font-weight: 700; }
.today-ex input.rinp { flex: 0 0 54px; width: 54px; text-align: right; padding: 10px 6px; font-size: 15px; font-weight: 700; }
.today-ex .unit { font-size: 11px; color: var(--ink-dim); flex: 0 0 auto; }
.today-ex.done .nm { text-decoration: line-through; color: var(--ink-dim); }
.today-ex .setdots { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 8px; padding: 9px 0; margin-bottom: -9px; }
.today-ex .sd { position: relative; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); box-sizing: border-box; cursor: pointer; flex: 0 0 auto; transition: background 0.12s, border-color 0.12s; }
/* 見た目は26pxのまま、タップ判定だけHIGの44ptに広げる(トレ中の誤タップで記録がずれるのを防ぐ) */
.today-ex .sd::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; }
.today-ex .sd.on { background: var(--accent); border-color: var(--accent); }
.today-ex .sdlabel { font-size: 11.5px; color: var(--ink-dim); font-weight: 700; margin-left: 4px; }
/* 休憩秒数は表示そのものを押させる(行にボタンを足さずに変更できるように) */
.today-ex .rest-edit { position: relative; font: inherit; color: var(--accent2, #4ed9f1); padding: 4px 2px; margin: -4px 0;
  border-bottom: 1px dashed currentColor; cursor: pointer; }
/* 文字は小さいままタップ判定だけ広げる(トレ中の誤タップと押しにくさを避ける) */
.today-ex .rest-edit::after { content: ''; position: absolute; inset: -12px -8px; }
/* 診断結果。長い行は折り返して、狭い画面でも横スクロールさせない */
.diag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; background: var(--surface2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; margin-bottom: 12px; max-height: 46vh; overflow: auto; }

/* おまかせ(回復ベース)。曜日プランの代替案なので、主張は控えめにする */
.omakase-card { border-color: var(--accent2, #4ed9f1); }

/* 初回ガイド。押せる行として見せ、済んだものは沈ませる */
.onboard-card { border-color: var(--accent); }
.onboard-card .ob-steps { display: flex; flex-direction: column; gap: 8px; }
.onboard-card .ob-step { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px; min-height: 44px; }
.onboard-card .ob-chk { font-size: 17px; flex: 0 0 auto; }
.onboard-card .ob-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.onboard-card .ob-txt b { font-size: 13.5px; }
.onboard-card .ob-txt small { font-size: 11.5px; color: var(--ink-dim); line-height: 1.4; }
.onboard-card .ob-step.done { opacity: .5; }

/* サボり検知カード。責めすぎない色味(警告色ではなくアクセント2)で、視線は引くが不快にしない */
.slack-card { border-color: var(--accent2, #4ed9f1); }
/* 駆け込み(今日まだ間に合う)は、過去のサボりより一段強く見せる */
.slack-card.tonight { border-color: var(--warn); }
.slack-card h2 .sub { color: var(--ink-dim); font-weight: 600; }

/* セット数の増減。ドットと同じくタップ判定は44ptに広げる */
.today-ex .setadj { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.today-ex .setadj-btn { position: relative; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface2); color: var(--ink); font-size: 15px; line-height: 1; font-weight: 700; cursor: pointer; flex: 0 0 auto; }
.today-ex .setadj-btn::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; }
.today-ex .setadj-btn:active { background: var(--line); }
.today-ex .po-hint { font-size: 11.5px; color: var(--ink-dim); margin-top: 5px; line-height: 1.4; }
.today-ex .po-hint.up { color: var(--accent); font-weight: 700; }
.today-ex .rir-pick { font-size: 11.5px; color: var(--ink-dim); margin-top: 7px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.today-ex .rirb { font-size: 12px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface2); color: var(--ink); cursor: pointer; }
.today-ex .rirb:active { background: var(--accent); color: var(--accent-ink); }
.today-ex .rir-label { font-size: 11.5px; color: var(--accent); margin-top: 7px; font-weight: 700; }
.today-ex.done .sdlabel { color: var(--accent); }
.today-ex .ex-tmr {
  flex: 0 0 auto; height: 40px; padding: 0 13px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--ink);
  font-size: 13px; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.today-ex .ex-tmr:active { background: var(--accent); color: var(--accent-ink); }

.recov-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.recov-cell { background: var(--surface2); border-radius: 10px; padding: 8px 6px; text-align: center; }
.recov-cell .nm { font-size: 11px; font-weight: 700; color: var(--ink-dim); }
.recov-cell .st { font-size: 12px; font-weight: 800; }
.recov-cell.ready .st, .recov-cell.fresh .st { color: var(--accent); }
.recov-cell.almost .st { color: var(--warn); }
.recov-cell.resting .st { color: var(--danger); }
/* 筋肉痛の記録(セルタップ)。表示は回復状態より優先 */
.recov-cell { cursor: pointer; }
.recov-cell:active { transform: scale(0.96); }
.recov-cell.sore1 { border: 1px solid var(--warn); }
.recov-cell.sore1 .st { color: var(--warn); }
.recov-cell.sore2 { border: 1px solid var(--danger); background: rgba(241, 96, 78, 0.12); }
.recov-cell.sore2 .st { color: var(--danger); }

.tip-card { background: linear-gradient(135deg, rgba(200,241,78,0.08), rgba(78,217,241,0.06)); }

/* ===== log ===== */
.set-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.set-row .no { width: 26px; font-size: 12px; font-weight: 800; color: var(--ink-dim); text-align: center; }
.set-row input { text-align: center; font-weight: 700; }
.set-row .x { color: var(--ink-dim); font-size: 12px; }
.set-row button { color: var(--danger); font-size: 18px; padding: 4px 8px; }

.log-day { margin-bottom: 12px; }
.log-day-head { font-size: 13px; font-weight: 800; color: var(--ink-dim); margin-bottom: 6px; display: flex; align-items: center; }
.log-day-head .share-day { margin-left: auto; font-size: 16px; padding: 2px 8px; border-radius: 8px; }
.log-day-head .share-day:active { background: var(--surface2); }
.log-entry {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 13px; margin-bottom: 6px;
}
.log-entry .nm { font-weight: 700; font-size: 13.5px; }
.log-entry .sets { font-size: 12px; color: var(--ink-dim); }
.log-entry .del { margin-left: auto; color: var(--danger); font-size: 16px; padding: 4px 8px; }

canvas.chart { width: 100%; height: 180px; display: block; }

/* フッターの規約リンク: 文字は小さいままタップ領域だけ広げる(誤タップも防ぐ) */
.card-note a { display: inline-block; padding: 6px 8px; color: var(--ink-dim); text-decoration: underline; }

/* 食事ログの削除ボタン: .del は .log-entry 配下にしか定義が無く、素のままだと 9x19px で
   ほぼ押せなかった。トレ中の操作なので確実に押せるサイズを確保する(HIG 44pt目安) */
.meal-item .fl-del {
  flex: 0 0 auto; min-width: 40px; height: 40px; margin-left: 4px;
  background: none; border: none; color: var(--danger); font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.meal-item .fl-del:active { background: var(--surface2); border-radius: 10px; }

/* 共通の小アイコンボタン(タップ領域を確保・見た目を統一) */
.icon-btn-sm { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line); color: var(--ink); font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn-sm:active { background: var(--accent); color: var(--accent-ink); }
.tool-sec { font-size: 12px; font-weight: 800; color: var(--ink-dim); letter-spacing: 0.03em; margin: 20px 4px 8px; }
.tool-sec:first-child { margin-top: 2px; }
.wcups { display: flex; flex-wrap: wrap; gap: 3px; font-size: 20px; line-height: 1.3; }
.wcup { opacity: 0.3; }
.wcup.on { opacity: 1; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-weight: 800; font-size: 15px; }
.cal-title small { color: var(--ink-dim); font-weight: 600; font-size: 11px; margin-left: 5px; }
.cal-nav { position: relative; background: var(--surface2); border: 1px solid var(--line); color: var(--ink); width: 32px; height: 32px; border-radius: 9px; font-size: 18px; line-height: 1; cursor: pointer; }
.cal-nav::after { content: ''; position: absolute; inset: -6px; }
.cal-nav:disabled { opacity: 0.3; cursor: default; }
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 340px; margin: 0 auto; }
.cal-wd { text-align: center; font-size: 10.5px; color: var(--ink-dim); font-weight: 700; padding-bottom: 2px; min-width: 0; }
.cal-day { min-width: 0; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 12.5px; border-radius: 9px; background: var(--surface2); color: var(--ink-dim); }
.cal-day.empty { background: transparent; }
.cal-day.on { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; color: var(--ink); font-weight: 800; }
.cal-day.on.today { outline-color: var(--accent-ink); }
.cal-day.future { opacity: 0.35; }

/* ===== meals ===== */
.meal-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.meal-item:last-child { border-bottom: none; }
.meal-item .mi-info { flex: 1; min-width: 0; }
.meal-item .nm { font-size: 13.5px; font-weight: 700; }
.meal-item .nm .amt { color: var(--accent); margin-left: 4px; }
.meal-item .meta { font-size: 11px; color: var(--ink-dim); }
.meal-item .mi-macros { text-align: right; font-size: 13px; font-weight: 800; white-space: nowrap; }
.meal-item .mi-macros small { display: block; font-size: 10.5px; color: var(--ink-dim); font-weight: 600; }

/* ===== my menu ===== */
.mm-exlist {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; background: var(--surface2);
}
.mm-exlist input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 18px; }

/* ===== photos ===== */
.photo-cmp { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.photo-cmp figure { flex: 1; margin: 0; min-width: 0; }
.photo-cmp img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.photo-cmp figcaption { font-size: 11px; color: var(--ink-dim); font-weight: 700; text-align: center; margin-top: 4px; }
.photo-cmp .cmp-arrow { font-size: 20px; color: var(--accent); flex: 0 0 auto; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.photo-thumb { position: relative; margin: 0; }
.photo-thumb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.photo-thumb figcaption { font-size: 10px; color: var(--ink-dim); font-weight: 700; text-align: center; margin-top: 2px; }
.photo-del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.65); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; font-size: 12px; line-height: 1;
}
/* 見た目は小さいまま当たり判定を確保(誤タップで写真を消させない) */
.photo-del::after { content: ''; position: absolute; inset: -10px; }
label.btn input[type="file"] { display: none; }

/* ===== timer ===== */
.timer-display { font-size: 56px; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.timer-display.running { color: var(--accent); }
.timer-btns { display: flex; gap: 8px; margin-top: 10px; }
.timer-btns .btn { flex: 1; padding: 11px 4px; font-size: 14px; }

/* ===== tools ===== */
.tool-result { background: var(--surface2); border-radius: 11px; padding: 12px 14px; margin-top: 10px; }
.tool-result .big { font-size: 26px; font-weight: 900; color: var(--accent); }
.tool-result .big small { font-size: 13px; color: var(--ink); }
.rm-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.rm-table td, .rm-table th { padding: 5px 8px; text-align: center; border-bottom: 1px solid var(--line); }
.rm-table th { color: var(--ink-dim); font-size: 11px; }
.recov-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.recov-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.recov-table td:last-child { text-align: right; font-weight: 700; }

/* 比較表(有酸素のタイミングなど。項目名は左、評価は中央) */
.cmp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp-table th { font-size: 11px; color: var(--ink-dim); font-weight: 600; padding: 0 2px 5px; text-align: center; }
.cmp-table th:first-child, .cmp-table td:first-child { text-align: left; }
.cmp-table td { padding: 7px 2px; border-bottom: 1px solid var(--line); text-align: center; }
.cmp-table .best { color: var(--accent); font-weight: 700; }
.cmp-table .weak { opacity: .55; }

/* ===== modal / onboarding ===== */
.modal-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 9, 11, 0.8); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 500px) { .modal-bg { align-items: center; } }
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 500px) { .modal { border-radius: 18px; } }
.modal h2 { font-size: 17px; font-weight: 900; margin-bottom: 4px; }
.modal .modal-sub { font-size: 12.5px; color: var(--ink-dim); margin-bottom: 16px; }
.ob-progress { display: flex; gap: 5px; margin-bottom: 18px; }
.ob-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface2); }
.ob-progress i.on { background: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid2 > *, .grid3 > * { min-width: 0; }

.empty {
  text-align: center; color: var(--ink-dim); font-size: 13px;
  padding: 26px 10px;
}
.empty .big-emoji { font-size: 36px; display: block; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 14px;
  padding: 11px 18px; border-radius: 16px; z-index: 60;
  animation: toastin 0.2s ease;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  /* nowrap だと長文が画面外に突き抜けて両端が読めなくなる(購入失敗の理由が伝わらない)。
     left:50% だけだと利用可能幅が半分になり極端に細長くなるため width:max-content と併用する */
  width: max-content;
  max-width: min(calc(100vw - 32px), 420px);
  white-space: normal; text-align: center; line-height: 1.45;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; } }

/* ===== みんなのメニュー: アイコン選択 & アバター ===== */
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-picker .icon-pick {
  width: 42px; height: 42px; font-size: 22px; line-height: 1;
  border-radius: 11px; background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.icon-picker .icon-pick.on { border-color: var(--accent); background: rgba(200,241,78,0.14); transform: scale(1.05); }
.gal-avatar {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1;
  overflow: hidden;
}
.gal-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-identity {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
}

/* ===== 浮遊レストタイマー(どのタブでも見える) ===== */
.rest-fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 7px 8px 7px 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  animation: toastin 0.2s ease;
}
.rest-fab[hidden] { display: none; }
.rest-fab .rt-body { text-align: left; line-height: 1.05; }
.rest-fab .rt-time { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.rest-fab .rt-label { font-size: 10px; font-weight: 800; opacity: 0.82; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rest-fab .rt-add, .rest-fab .rt-stop {
  background: rgba(0, 0, 0, 0.16); color: var(--accent-ink);
  border-radius: 999px; font-weight: 900; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
}
.rest-fab .rt-add { font-size: 12px; }
.rest-fab .rt-stop { font-size: 15px; }
@media (min-width: 960px) {
  .rest-fab { left: auto; right: 32px; transform: none; bottom: 28px; }
}

details.acc { border: 1px solid var(--line); border-radius: 11px; margin-bottom: 8px; overflow: hidden; }
details.acc summary { padding: 11px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer; background: var(--surface2); list-style: none; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc .acc-body { padding: 12px 14px; font-size: 12.5px; }
details.acc .acc-body ul { padding-left: 18px; }

/* ================= デスクトップ (≥960px): 左サイドバー + マソンリー ================= */
@media (min-width: 960px) {
  body { padding-bottom: 0; }

  /* トップバー: サイドバーより前面に出してロゴをサイドバー頭に見せる */
  .topbar { padding-left: 24px; z-index: 30; }
  .logo { font-size: 20px; }

  /* 下タブ → 左の縦型ナビ */
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto; width: 232px;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    background: var(--bg); backdrop-filter: none;
    border-top: none; border-right: 1px solid var(--line);
    padding: 72px 14px 18px;
  }
  .tabbar a {
    flex: 0 0 auto; width: 100%;
    display: flex; align-items: center; gap: 13px; text-align: left;
    font-size: 14.5px; font-weight: 700; padding: 12px 14px; border-radius: 12px;
    transition: background 0.12s, color 0.12s;
  }
  .tabbar a .ticon { display: inline-block; font-size: 21px; line-height: 1; }
  .tabbar a:hover { background: var(--surface); color: var(--ink); }
  .tabbar a.active { background: var(--surface2); color: var(--accent); }

  /* コンテンツ: サイドバーの右、幅に応じて 1〜2 カラムのマソンリー */
  main { max-width: 1240px; margin: 0; margin-left: 232px; padding: 26px 40px 40px; }
  .view.active { columns: 440px; column-gap: 22px; }
  .view.active > * { break-inside: avoid; }
  .card, .plan-day, details.acc, .stat-row { break-inside: avoid; }
  .card { margin-bottom: 22px; }
  /* stat-row をカラム内に収めても3タイルが読める幅を確保 */
  .stat-tile .v { font-size: 24px; }

  /* デスクトップの操作感: ボタン/カードにホバー */
  .btn { cursor: pointer; transition: filter 0.12s, transform 0.06s; }
  .btn:hover { filter: brightness(1.06); }
  .btn.ghost:hover { background: var(--surface); }
  .chip, .today-ex, .plan-ex, .log-entry, .meal-item { }
  .plan-ex:hover, [data-open-ex]:hover { background: var(--surface2); cursor: pointer; }

  /* モーダルは中央やや上に */
  .modal { max-width: 600px; }
  .toast { bottom: 28px; }
}

/* 超ワイド: カラムをもう少し広げて余白を締める */
@media (min-width: 1500px) {
  main { max-width: 1400px; }
  .view.active { columns: 460px; }
}
