:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7686;
  --line: #e4e9f0;
  --brand: #16a34a;      /* テニスコートの緑 */
  --brand-ink: #0f7a37;
  --accent: #f59e0b;     /* ボールの黄 */
  --done: #22c55e;
  --shadow: 0 2px 10px rgba(20, 40, 80, .07);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --card: #171e28; --ink: #e8edf4; --muted: #9aa7b8;
    --line: #26303d; --shadow: 0 2px 12px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 76px;
}

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--brand); color: #fff;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.who { font-size: 12px; opacity: .85; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }
.sec { font-size: 15px; color: var(--muted); margin: 22px 4px 10px; font-weight: 700; }

/* hero / streak */
.hero {
  background: linear-gradient(135deg, var(--brand), var(--brand-ink));
  color: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 18px;
}
.streak { display: flex; align-items: center; gap: 10px; }
.flame { font-size: 40px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); }
.streak-num { line-height: 1; }
.streak-num span { font-size: 44px; font-weight: 900; }
.streak-num small { display: block; font-size: 12px; opacity: .9; margin-top: 4px; }
.hero-stats { display: flex; gap: 8px; margin-left: auto; }
.stat { background: rgba(255,255,255,.18); border-radius: 12px; padding: 10px 12px; text-align: center; min-width: 58px; }
.stat b { display: block; font-size: 22px; font-weight: 800; }
.stat span { font-size: 11px; opacity: .9; }

/* calendar heatmap */
.cal {
  background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr);
  gap: 4px; overflow-x: auto;
}
.cal .cell { width: 13px; height: 13px; border-radius: 3px; background: var(--line); }
.cal .cell.l1 { background: #a7e8be; }
.cal .cell.l2 { background: #5fd08a; }
.cal .cell.l3 { background: var(--brand); }

/* per-drill bars */
.bars { background: var(--card); border-radius: var(--radius); padding: 8px 14px; box-shadow: var(--shadow); }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-row .name { width: 40%; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar-row .cnt { width: 34px; text-align: right; font-weight: 700; font-size: 13px; }

/* drill cards (today) */
.drill-list { display: flex; flex-direction: column; gap: 14px; }
.drill {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border: 2px solid transparent; transition: border-color .15s;
}
.drill.done { border-color: var(--done); }
.drill .media { background: #000; position: relative; }
.drill video { width: 100%; display: block; max-height: 60vh; }
.drill .imgwrap { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: #0b0f14; }
.drill .imgwrap img { height: 300px; scroll-snap-align: center; object-fit: contain; }
.drill .body { padding: 14px; }
.drill .title { font-size: 18px; font-weight: 800; }
.drill .cat { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drill .note { font-size: 14px; margin: 10px 0 0; white-space: pre-wrap; color: var(--ink); }
.drill .clip-badge {
  position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 12px; padding: 4px 8px; border-radius: 999px; z-index: 2;
}
.drill .actions { padding: 0 14px 14px; }

.check {
  width: 100%; border: 0; border-radius: 14px; padding: 16px; font-size: 18px; font-weight: 900;
  background: var(--line); color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.check.on { background: var(--done); color: #fff; }

/* edit list */
.edit-head { display: flex; align-items: center; justify-content: space-between; }
.edit-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.edit-row {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.edit-row .meta { flex: 1; min-width: 0; }
.edit-row .meta b { display: block; }
.edit-row .meta small { color: var(--muted); }

/* buttons */
.btn { border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: #fee2e2; color: #b91c1c; }
@media (prefers-color-scheme: dark) { .btn.danger { background: #3a1e1e; color: #fca5a5; } }

/* tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 22px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; cursor: pointer;
}
.tab span { font-size: 11px; font-weight: 700; }
.tab.active { color: var(--brand); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 720px; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 16px; overflow-y: auto; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
  background: var(--bg); color: var(--ink);
}
.field textarea { min-height: 70px; resize: vertical; }
.picker { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.pk-post { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.pk-post:last-child { border-bottom: 0; }
.pk-media { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pk-thumb { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; border: 3px solid transparent; cursor: pointer; }
.pk-thumb.sel { border-color: var(--brand); }
.pk-vid { display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 60px; border-radius: 8px; background: #111; color: #fff; font-size: 22px; border: 3px solid transparent; cursor: pointer; }
.pk-vid.sel { border-color: var(--brand); }
.empty { text-align: center; color: var(--muted); margin-top: 40px; line-height: 1.7; }
.row2 { display: flex; gap: 10px; }
.row2 .field { flex: 1; }
