/* ============================================================
   Training Tracker — 遊び心のあるファンタジーRPG風テーマ
   （明るい羊皮紙 + ネイビーのコマンドウィンドウ + 金のアクセント）
   ============================================================ */
@font-face {
  font-family: "PressStart2P";
  src: url("/fonts/PressStart2P.woff2") format("woff2");
  font-display: swap;
  /* Latin/数字だけをドット文字に。日本語は自動的に下のフォントへフォールバック */
  unicode-range: U+0000-00FF, U+2018-2019, U+201C-201D, U+2022, U+2192, U+25BA;
}

:root {
  --bg: #ece0c2;
  --surface: #fbf3df;
  --surface-2: #f1e6c9;
  --text: #3b2c1a;
  --text-muted: #8a7448;
  --border: #d8bd86;
  --border-strong: #a9843f;

  --ink: #242a4d;         /* コマンドウィンドウ/ヘッダーのネイビー */
  --ink-2: #1a1f3d;
  --parch-line: rgba(224,163,38,.35);

  --primary: #3b5dc9;     /* 王道RPGブルー（決定ボタン） */
  --primary-strong: #2b3fa0;
  --primary-edge: #1f2c72;
  --primary-soft: #dde4ff;
  --accent: #d1495b;      /* 目標ライン（クリムゾン） */
  --accent-soft: #f6dade;
  --gold: #e6a817;
  --gold-strong: #b7810f;
  --gold-soft: #f6e6b8;
  --good: #3f9d4e;
  --good-soft: #dcf0d8;
  --warn: #d5901f;
  --warn-soft: #f7e6c2;
  --danger: #c0392b;

  --shadow-sm: 0 2px 0 rgba(120,90,40,.18);
  --shadow-md: 0 4px 0 rgba(120,90,40,.20), 0 6px 16px rgba(90,60,20,.16);
  --shadow-lg: 0 10px 0 rgba(30,25,55,.25), 0 22px 48px rgba(20,15,40,.4);

  --radius: 12px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --space: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  --font-pixel: "PressStart2P", var(--font);
}

:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  /* うっすらとした方眼で「冒険の地図」風の質感 */
  background-image:
    linear-gradient(rgba(150,115,55,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150,115,55,.06) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
.hidden { display: none !important; }

h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: .01em; }

/* ---------- buttons（チャンキーなベベル） ---------- */
.btn {
  font-family: inherit;
  font-size: .92rem;
  font-weight: 700;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .12s, box-shadow .12s, transform .04s, border-color .12s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary-edge);
  border-bottom-width: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: .84rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-dashed {
  background: transparent;
  border: 2px dashed var(--border-strong);
  color: var(--primary-strong); font-weight: 700;
  width: 100%; justify-content: center;
}
.btn-dashed:hover { background: var(--gold-soft); border-color: var(--gold-strong); }
.icon { width: 16px; height: 16px; flex: 0 0 auto; }

/* ---------- inputs ---------- */
select, input[type="text"], input[type="password"], input[type="number"] {
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  background: #fffaf0;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition: border-color .12s, box-shadow .12s;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--gold-strong);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; color: var(--ink);
  background: linear-gradient(155deg, #ffd766, var(--gold));
  border: 2px solid #fff3d0;
  box-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name {
  font-family: var(--font-pixel);
  font-size: .82rem; letter-spacing: .5px; line-height: 1.3;
  color: var(--gold); text-shadow: 2px 2px 0 rgba(0,0,0,.35);
}
.brand-lg .brand-mark { width: 58px; height: 58px; border-radius: 14px; }
.brand-lg .brand-mark svg { width: 32px; height: 32px; }
.brand-lg .brand-name { font-size: 1.05rem; }

/* ============================================================
   認証画面
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: inset 0 0 0 2px var(--parch-line), var(--shadow-md);
  padding: 30px 26px;
  text-align: center;
}
.auth-card .brand-lg { flex-direction: column; gap: 14px; }
.auth-card .brand-lg .brand-name { color: var(--gold-strong); text-shadow: 1px 1px 0 rgba(0,0,0,.15); }
.auth-tagline { color: var(--text-muted); margin: 12px 0 22px; font-size: .92rem; }
.auth-tabs {
  display: flex; background: var(--surface-2); border-radius: var(--radius-pill);
  padding: 4px; margin-bottom: 22px; border: 2px solid var(--border);
}
.auth-tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 9px 0; border-radius: var(--radius-pill);
  font-family: inherit; font-weight: 700; font-size: .9rem; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 0 var(--primary-edge); }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.input-label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .82rem; font-weight: 700; color: var(--text-muted);
}
.input-label input { font-size: 1rem; }
.auth-error { color: var(--danger); font-size: .85rem; margin: 2px 0 0; min-height: 1em; font-weight: 700; }
.auth-note { color: var(--text-muted); font-size: .78rem; margin: 20px 0 0; }

/* ============================================================
   アプリシェル（ヘッダー+ナビ = ネイビーのコマンドウィンドウ）
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--ink);
  border-bottom: 4px solid var(--gold);
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar .btn-ghost { color: #d9d3ee; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.08); border: 2px solid var(--gold);
  border-radius: var(--radius-pill); padding: 5px 12px 5px 10px;
  font-size: .85rem; font-weight: 700; color: #fdf6e3;
}
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: #6ee07a; box-shadow: 0 0 6px #6ee07a; }

.nav {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 16px 10px;
  background: var(--ink-2);
  border-bottom: 3px solid #0f1330;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  border: 2px solid transparent; background: transparent;
  color: #c7c2e0; font-family: inherit; font-size: .88rem; font-weight: 700;
  padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-btn.active {
  background: var(--gold); color: var(--ink);
  border-color: #fff3d0;
  box-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.nav-btn.active::before { content: "\25BA"; font-size: .7em; margin-right: -2px; }
.nav-btn .icon { color: currentColor; }

.content { max-width: 780px; margin: 0 auto; padding: 24px 20px 84px; }

.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head { margin-bottom: 18px; }
.panel-head h2 {
  font-size: 1.3rem; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.panel-head h2::before {
  content: "\25C6"; color: var(--gold); font-size: .8em;
  text-shadow: 1px 1px 0 rgba(0,0,0,.2);
}
.panel-sub { color: var(--text-muted); font-size: .88rem; margin: 6px 0 0; }

/* パーチメント製の「ウィンドウ」パネル */
.card {
  background: var(--surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px var(--parch-line), var(--shadow-sm);
  padding: 20px;
}
.form-card { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field-label {
  flex: 0 0 68px; font-size: .82rem; font-weight: 800; color: var(--gold-strong);
}
.field-block { flex-direction: column; align-items: stretch; }
.field-block .field-label { margin-bottom: 2px; }
.calorie-input { display: inline-flex; align-items: center; gap: 8px; }
.calorie-input input, .calorie-input select { max-width: 130px; }
.unit { color: var(--text-muted); font-size: .85rem; font-weight: 700; }

/* add-exercise mini form */
#add-exercise-toggle { align-self: flex-start; margin-top: 6px; }
.add-exercise-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 8px; padding: 10px; background: var(--surface-2);
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.add-exercise-form input[type="text"] { flex: 1 1 160px; min-width: 0; }
.add-exercise-form .auth-error { flex-basis: 100%; margin: 2px 0 0; }

/* set rows */
.set-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.set-row {
  display: flex; align-items: center; gap: 8px;
  background: #fffaf0; border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.set-index {
  flex: 0 0 auto; font-family: var(--font-pixel); font-size: .68rem; color: #fff;
  background: var(--primary); border: 1px solid var(--primary-edge);
  border-radius: 6px; padding: 4px 7px;
}
.set-unit { color: var(--text-muted); font-size: .85rem; font-weight: 700; }
.remove-set {
  margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.remove-set:hover { background: var(--accent-soft); color: var(--danger); }
.remove-set svg { width: 16px; height: 16px; }

.date-select { display: flex; gap: 6px; flex-wrap: wrap; }

/* lists */
.list-title {
  margin: 26px 0 12px; font-size: .98rem; color: var(--ink); font-weight: 800;
  display: flex; align-items: center; gap: 7px;
}
.list-title::before { content: "\25BA"; color: var(--gold); font-size: .72em; }
.entry-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entry-list li {
  background: var(--surface); border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.entry-main { font-weight: 800; font-size: .92rem; color: var(--ink); }
.entry-detail { color: var(--text-muted); font-size: .82rem; margin-top: 2px; font-weight: 600; }
.entry-list .del-btn {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: .82rem; padding: 4px 8px; border-radius: 6px; font-weight: 700;
}
.entry-list .del-btn:hover { background: var(--accent-soft); color: var(--danger); }
.empty {
  color: var(--text-muted); font-size: .9rem; text-align: center;
  padding: 22px; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.4);
}

/* controls / segmented */
.controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.control { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 800; color: var(--gold-strong); }
.segmented {
  display: inline-flex; background: var(--surface-2);
  border: 2px solid var(--border-strong); border-radius: var(--radius-pill); padding: 3px;
}
.segmented button {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .82rem; font-weight: 700; color: var(--text-muted);
  padding: 5px 14px; border-radius: var(--radius-pill); transition: background .12s, color .12s;
}
.segmented button.active { background: var(--primary); color: #fff; box-shadow: 0 2px 0 var(--primary-edge); }

/* charts */
.chart-title { margin: 18px 0 8px; font-size: .85rem; color: var(--gold-strong); font-weight: 800; }
.chart { border-radius: var(--radius-sm); }
.chart svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 18px; padding: 10px 4px 2px; font-size: .8rem; color: var(--text-muted); font-weight: 700; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 4px; border-radius: 2px; }

.diff-box {
  margin-top: 16px; padding: 12px 16px;
  background: var(--ink); border: 3px solid #fff;
  border-radius: var(--radius-sm); font-size: .9rem;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  color: #fdf6e3;
}
.diff-label { color: #c7c2e0; font-size: .82rem; font-weight: 700; }
.diff-value { font-family: var(--font-pixel); font-size: .95rem; }
.diff-value.pos { color: #ff8f7a; }
.diff-value.neg { color: #7fe08a; }

/* suggestions */
.suggestions-col .list-title { margin-top: 0; }
.suggestions-grid { display: grid; grid-template-columns: 1fr; gap: 8px 28px; }
@media (min-width: 720px) {
  .suggestions-grid { grid-template-columns: 1fr 1fr; }
}
.suggestion-list { display: flex; flex-direction: column; gap: 8px; }
.sug-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-sm); border-left-width: 6px; border-left-color: var(--text-muted);
  font-size: .82rem; line-height: 1.5; color: var(--text);
}
.sug-card.good { border-left-color: var(--good); }
.sug-card.warn { border-left-color: var(--warn); }
.sug-card.action { border-left-color: var(--primary); }
.sug-card.info { border-left-color: var(--gold); }
.sug-badge {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.sug-card.good .sug-badge { background: var(--good-soft); color: var(--good); }
.sug-card.warn .sug-badge { background: var(--warn-soft); color: var(--warn); }
.sug-card.action .sug-badge { background: var(--primary-soft); color: var(--primary); }
.sug-card.info .sug-badge { background: var(--gold-soft); color: var(--gold-strong); }
.sug-badge svg { width: 14px; height: 14px; }

.save-msg { color: var(--good); font-size: .85rem; font-weight: 800; margin-left: 12px; }
.hint { color: var(--text-muted); font-size: .82rem; margin: -6px 0 0; }

/* ============================================================
   種目チェックボックス（目標プラン用）
   ============================================================ */
.exercise-checks {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 280px; overflow-y: auto;
  padding: 4px 2px;
}
.exercise-check-group { display: flex; flex-direction: column; gap: 8px; }
.exercise-check-group-title {
  font-size: .78rem; font-weight: 800; color: var(--gold-strong);
}
.exercise-check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.exercise-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-pill);
  border: 2px solid var(--border-strong); background: #fffaf0;
  font-size: .85rem; font-weight: 600; cursor: pointer; user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.exercise-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.exercise-chip.checked { background: var(--primary); border-color: var(--primary-edge); color: #fff; font-weight: 800; }
.exercise-chip:hover { border-color: var(--gold-strong); }

/* 目標プレビュー/現在の目標（クエスト風バナー） */
.entry-list .entry-detail .unit-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: var(--radius-pill); background: var(--surface-2);
  font-size: .72rem; color: var(--text-muted);
}
.plan-summary-card {
  background: var(--ink); border: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 13px 16px;
  margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.plan-summary-card .plan-summary-text { font-weight: 800; color: #ffe08a; font-size: .95rem; }
.plan-summary-card .plan-summary-note { color: #c7c2e0; font-size: .78rem; margin-top: 3px; }

/* ============================================================
   チュートリアル（RPGメッセージウィンドウ）
   ============================================================ */
.tutorial-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15,12,30,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .2s ease;
}
.tutorial-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--ink); border: 4px solid #fff;
  border-radius: 16px; box-shadow: 0 0 0 3px var(--ink), var(--shadow-lg);
  padding: 28px 24px; color: #fdf6e3;
}
.tutorial-icon {
  width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; color: var(--ink);
  background: linear-gradient(155deg, #ffd766, var(--gold));
  border: 2px solid #fff3d0;
}
.tutorial-icon svg { width: 30px; height: 30px; }
.tutorial-card h3 { font-size: 1.15rem; margin-bottom: 10px; color: #ffe08a; }
.tutorial-card p { color: #e6e1f2; font-size: .92rem; margin: 0 0 20px; }
.tutorial-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 20px; }
.tutorial-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.3); transition: background .2s, width .2s; }
.tutorial-dots span.active { background: var(--gold); width: 22px; border-radius: 5px; }
.tutorial-actions { display: flex; align-items: center; justify-content: space-between; }
.tutorial-actions .btn-ghost { color: #c7c2e0; }
.tutorial-actions .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---- スポットライト方式のステップ ---- */
.tour-highlight {
  position: fixed; z-index: 61; pointer-events: none;
  border-radius: 12px;
  box-shadow: 0 0 0 4px var(--gold), 0 0 0 9999px rgba(15,12,30,.6);
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-tooltip {
  position: fixed; z-index: 62; width: min(320px, calc(100vw - 32px));
  background: var(--ink); border: 3px solid #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 15px 18px; color: #fdf6e3; animation: fade .2s ease;
}
.tour-tooltip-title { font-weight: 800; font-size: 1rem; margin-bottom: 6px; color: #ffe08a; }
.tour-tooltip-body { color: #e6e1f2; font-size: .88rem; margin: 0 0 14px; }
.tour-dots { display: flex; gap: 6px; margin-bottom: 14px; }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.3); transition: background .2s, width .2s; }
.tour-dots span.active { background: var(--gold); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; }
.tour-actions .btn-ghost { color: #c7c2e0; }
.tour-actions .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ============================================================
   アバター（画面下を歩き回る相棒）＋ RPGダイアログ風の吹き出し
   ============================================================ */
.avatar-widget {
  position: fixed; left: 0; bottom: 0; width: 100%; height: 1px;
  z-index: 40; pointer-events: none;
}
.avatar-mover {
  position: absolute; bottom: 6px; left: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  /* left は JS で更新。歩行時のみ transition が付く */
}
.avatar-figure {
  border: none; background: transparent; cursor: pointer; padding: 0;
  line-height: 0; pointer-events: auto;
  filter: drop-shadow(0 5px 6px rgba(40,30,10,.35));
  transform-origin: 50% 100%;
  animation: avatar-idle 2.4s ease-in-out infinite;
}
.avatar-sprite {
  height: min(3.9cm, 26vw);
  width: auto; display: block;
  image-rendering: pixelated;
  -webkit-user-drag: none; user-select: none;
  transition: transform .2s ease;
}
.avatar-figure.face-left .avatar-sprite { transform: scaleX(-1); }

/* 単一の立ち絵スプライトなので個々の手足は動かせないが、体全体の重心移動で
   自然な歩き（左右に踏みしめるワドル）・スクワット・腕立てを表現する */
.avatar-figure.pose-walk { animation: avatar-walk .58s ease-in-out infinite; }
.avatar-figure.pose-rest {
  animation: none;
  transform: rotate(78deg) translate(-4%, 10%);
  transition: transform .5s ease;
}
.avatar-figure.pose-squat { animation: avatar-squat 1s cubic-bezier(.5,0,.5,1) infinite; }
.avatar-figure.pose-pushup { animation: avatar-pushup .7s ease-in-out infinite; }

@keyframes avatar-idle {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-2%) scaleY(1.02); }  /* ゆっくり呼吸するように */
}
/* 歩行: 接地した足の上で体が起き上がり、踏み替えるたびに左右へ傾く */
@keyframes avatar-walk {
  0%   { transform: rotate(-3.5deg) translate(1%, 0); }
  25%  { transform: rotate(0deg) translate(0, -4%); }
  50%  { transform: rotate(3.5deg) translate(-1%, 0); }
  75%  { transform: rotate(0deg) translate(0, -4%); }
  100% { transform: rotate(-3.5deg) translate(1%, 0); }
}
/* スクワット: しゃがんで立つ */
@keyframes avatar-squat {
  0%, 100% { transform: translateY(0) scaleY(1); }
  45%, 55% { transform: translateY(12%) scaleY(.78); }
}
/* 腕立て: 伏せた姿勢で体を上下 */
@keyframes avatar-pushup {
  0%, 100% { transform: rotate(80deg) translate(-4%, 11%); }
  50%      { transform: rotate(80deg) translate(-4%, 3%); }
}

.avatar-bubble {
  max-width: 230px;
  background: var(--ink); border: 3px solid #fff;
  border-radius: 12px; padding: 9px 13px;
  box-shadow: 0 0 0 2px var(--ink), var(--shadow-md);
  font-size: .82rem; position: relative; color: #fdf6e3; font-weight: 600;
  animation: fade .15s ease; pointer-events: none;
}
.avatar-bubble p { margin: 0; }
.avatar-bubble::after {
  content: ""; position: absolute; bottom: -10px; left: 50%; margin-left: -7px;
  width: 14px; height: 14px; background: var(--ink);
  border-right: 3px solid #fff; border-bottom: 3px solid #fff;
  transform: rotate(45deg);
}

/* ============================================================
   昨日のふりかえり（RPGチェックイン）
   ============================================================ */
.checkin-overlay {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(15,12,30,.62); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade .2s ease;
}
.checkin-stage {
  width: 100%; max-width: 560px;
  display: flex; align-items: flex-end; gap: 8px;
}
.checkin-avatar { flex: 0 0 auto; }
.checkin-avatar img {
  height: 128px; width: auto; display: block; image-rendering: pixelated;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.4));
  animation: avatar-idle 2.4s ease-in-out infinite; transform-origin: 50% 100%;
}
.checkin-box {
  flex: 1 1 auto; min-width: 0;
  background: var(--ink); border: 4px solid #fff;
  border-radius: 14px; box-shadow: 0 0 0 3px var(--ink), var(--shadow-lg);
  padding: 16px 18px 18px; color: #fdf6e3; position: relative;
}
.checkin-speaker {
  position: absolute; top: -14px; left: 16px;
  background: var(--gold); color: var(--ink);
  font-weight: 800; font-size: .74rem; padding: 3px 10px; border-radius: 999px;
  border: 2px solid #fff3d0;
}
.checkin-text { margin: 4px 0 12px; font-size: .95rem; line-height: 1.55; }
.checkin-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.checkin-body:empty { display: none; }
.checkin-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.checkin-row select, .checkin-row input {
  flex: 1 1 auto; min-width: 0;
  background: #fffaf0; color: var(--text);
}
.checkin-row .checkin-sub { flex-basis: 100%; color: #c7c2e0; font-size: .78rem; }
.checkin-tally {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 128px; overflow-y: auto;
}
.checkin-tally-item {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 6px 10px; font-size: .8rem; font-weight: 600;
}
.checkin-tally-empty { color: #a7a2c0; font-size: .78rem; }
.checkin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.checkin-actions .btn { flex: 1 1 auto; justify-content: center; }
.checkin-actions .btn-ghost { color: #c7c2e0; flex: 0 0 auto; }
.checkin-actions .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.checkin-choice {
  background: rgba(255,255,255,.1); color: #fff; border: 2px solid var(--gold);
}
.checkin-choice:hover { background: var(--gold); color: var(--ink); }
@media (max-width: 500px) {
  .checkin-avatar img { height: 92px; }
}

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 560px) {
  .topbar { padding: 10px 14px; }
  .brand-name { font-size: .72rem; }
  .user-chip { display: none; }
  .nav { padding: 6px 12px 8px; }
  .content { padding: 18px 14px 72px; }
  .field-label { flex-basis: 100%; }
  .field select, .field input[type="text"] { flex: 1; min-width: 0; }
}
