/* 筋トレログ — 片手で速く押せることを最優先にした見た目 */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #eeeee9;
  --line: #deded7;
  --ink: #1c1d21;
  --ink-2: #55585f;
  --ink-3: #8b8e95;
  --accent: #2a6fd6;
  --accent-ink: #ffffff;
  --done: #1f8a5b;
  --done-bg: #e3f3ea;
  --warn: #b3541e;
  --p-chest: #d4523f;
  --p-back: #2a6fd6;
  --p-shoulder: #c08a12;
  --p-legs: #1f8a5b;
  --p-arms: #8a4fc7;
  --p-abs: #5d6570;
  --radius: 12px;
  --tap: 46px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181d; --surface: #1f2228; --surface-2: #2a2e35; --line: #363a42;
    --ink: #eceef2; --ink-2: #b4b8c0; --ink-3: #80858e;
    --accent: #5b9bff; --accent-ink: #0d1117; --done: #4cc38a; --done-bg: #1c3a2c; --warn: #f0965a;
    --p-chest: #f07a68; --p-back: #5b9bff; --p-shoulder: #e0b04a; --p-legs: #4cc38a; --p-arms: #b88cf0; --p-abs: #9aa3ad;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181d; --surface: #1f2228; --surface-2: #2a2e35; --line: #363a42;
  --ink: #eceef2; --ink-2: #b4b8c0; --ink-3: #80858e;
  --accent: #5b9bff; --accent-ink: #0d1117; --done: #4cc38a; --done-bg: #1c3a2c; --warn: #f0965a;
  --p-chest: #f07a68; --p-back: #5b9bff; --p-shoulder: #e0b04a; --p-legs: #4cc38a; --p-arms: #b88cf0; --p-abs: #9aa3ad;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.view { max-width: 640px; margin: 0 auto; padding: calc(8px + env(safe-area-inset-top)) 16px 24px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 20px 0 8px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }

/* 下のタブ */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; align-items: center; justify-content: center; height: 56px;
  color: var(--ink-3); text-decoration: none; font-size: 14px; font-weight: 600;
}
.tabs a.on { color: var(--accent); }

/* ボタン */
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--warn); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.iconbtn {
  width: var(--tap); height: var(--tap); border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 20px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}

/* 日付の見出し */
.dayhead { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.dayhead .date { flex: 1; text-align: center; background: none; border: 0; padding: 6px 0; }
.dayhead .date b { display: block; font-size: 20px; }
.dayhead .date span { font-size: 13px; color: var(--ink-3); }
.syncline { font-size: 12px; color: var(--ink-3); text-align: center; margin: -6px 0 10px; }
.syncline.bad { color: var(--warn); }

/* 種目のまとまり */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.exhead { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.exhead .name { font-weight: 700; font-size: 17px; }
.exhead .meta { font-size: 12px; color: var(--ink-3); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.p-胸 { background: var(--p-chest); } .p-背中 { background: var(--p-back); } .p-肩 { background: var(--p-shoulder); }
.p-脚 { background: var(--p-legs); } .p-腕 { background: var(--p-arms); } .p-腹 { background: var(--p-abs); }

/* セットの見出し */
.sethead { display: grid; grid-template-columns: 24px minmax(0, 1.15fr) minmax(0, 1fr) var(--tap); gap: 6px; padding: 0 4px; font-size: 11px; color: var(--ink-3); text-align: center; }
/* セットの行：[番号][重さ −/＋][回数 −/＋][完了]、その下に前回の値とメモ */
.set { display: grid; grid-template-columns: 24px minmax(0, 1.15fr) minmax(0, 1fr) var(--tap); align-items: center; gap: 6px; padding: 6px 4px; border-top: 1px solid var(--line); }
.set:first-of-type { border-top: 0; }
.set .no { font-weight: 700; color: var(--ink-3); text-align: center; background: none; border: 0; padding: 0; height: var(--tap); }
.set .sub { grid-column: 2 / -1; font-size: 12px; color: var(--ink-3); margin-top: -2px; display: flex; gap: 10px; flex-wrap: wrap; }
.set .sub .memo { color: var(--ink-2); font-weight: 600; }
.set .sub .pr { color: var(--done); font-weight: 700; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 32px; flex: none; height: var(--tap); border: 0; background: var(--surface-2); font-size: 20px; font-weight: 600; }
.stepper label { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; }
.stepper input {
  width: 0; flex: 1; min-width: 0; height: var(--tap); border: 0; text-align: center; background: transparent; padding: 0;
  font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { flex: none; font-size: 11px; color: var(--ink-3); padding-right: 2px; }
.stepper.static { justify-content: center; height: var(--tap); color: var(--ink-3); font-size: 14px; }
.check {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: var(--line);
}
.check.on { background: var(--done); border-color: var(--done); color: #fff; }
.set.done { background: var(--done-bg); border-radius: 8px; }
.addset { margin-top: 6px; }

/* コピー候補 */
.suggest { display: grid; gap: 8px; }
.suggest button { text-align: left; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.suggest b { display: block; }
.suggest .list { font-size: 13px; color: var(--ink-2); }

/* カレンダー */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--ink-3); padding: 4px 0; }
.cal a {
  min-height: 56px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding-top: 6px; gap: 4px; text-decoration: none; color: var(--ink);
}
.cal a.out { visibility: hidden; }
.cal a.today { border-color: var(--accent); border-width: 2px; }
.cal .dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 36px; }
.cal .dots .dot { width: 8px; height: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 10px 0; }
.since { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.since div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.since b { font-size: 18px; }

/* 一覧 */
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; width: 100%; text-align: left; }
.list-item .sub { font-size: 12px; color: var(--ink-3); }

/* 下から出る画面 */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet .panel {
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet .panel h3 { margin: 0 0 12px; font-size: 17px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select, .field textarea, .search {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 40px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }
.seg button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1; }

/* 休憩タイマー */
.timer {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 16px 6px; background: var(--ink); color: var(--bg);
}
.timer[hidden] { display: none; }
.timer .t { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; flex: 1; }
.timer button { min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid currentColor; background: transparent; color: inherit; font-weight: 600; }
.timer.end { background: var(--done); color: #fff; }

.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; }
.toast[hidden] { display: none; }
textarea.note { width: 100%; min-height: 60px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 8px 12px; }
.empty { text-align: center; color: var(--ink-3); padding: 24px 0 8px; }
.hist { font-size: 13px; color: var(--ink-2); }
.hist div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
