/* ============================================================
   パシャカロ design system
   食事=柿色 / 体重=藍 / 筋トレ=青緑  (CVD-validated palette)
   ============================================================ */
:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-2: #EFEDE8;
  --ink: #2A2620;
  --ink-2: #6E675D;
  --ink-3: #A19A8E;
  --line: #E5E1D8;

  --meal: #ED6A18;          /* chart mark */
  --meal-text: #C24F08;     /* text-safe */
  --meal-soft: #FCEADD;
  --weight: #5560DE;
  --weight-text: #3D48C4;
  --weight-soft: #E7E9FB;
  --train: #14A085;
  --train-text: #0B7A65;
  --train-soft: #DDF2ED;

  --good: #14A085;
  --warn: #D6A400;
  --bad: #D64545;

  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 2px 12px rgba(42, 38, 32, .07);
  --shadow-fab: 0 6px 20px rgba(237, 106, 24, .38);
  --font-disp: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", sans-serif;
  --head-h: 58px;
  --tab-h: 64px;
}
html[data-theme="dark"] {
  --bg: #191713;
  --surface: #221F19;
  --surface-2: #2C2822;
  --ink: #F2EEE6;
  --ink-2: #A89F92;
  --ink-3: #7A7264;
  --line: #35302A;
  --meal: #E2600D;
  --meal-text: #FF9A55;
  --meal-soft: #3A2818;
  --weight: #5560DE;
  --weight-text: #9BA3FF;
  --weight-soft: #23244038;
  --train: #14A085;
  --train-text: #3FCCAF;
  --train-soft: #16302B;
  --warn: #E5BC3B;
  --bad: #E56A6A;
  --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  --shadow-fab: 0 6px 20px rgba(226, 96, 13, .45);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius-s); padding: 10px 12px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--meal); outline-offset: 2px;
}
svg { display: block; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; position: relative; }

/* ---------- header ---------- */
.app-head {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--head-h) + env(safe-area-inset-top));
  padding: calc(6px + env(safe-area-inset-top)) 18px 6px;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.app-head .title {
  font-family: var(--font-disp); font-weight: 900; font-size: 20px; letter-spacing: .02em;
}
.app-head .sub { font-size: 12px; color: var(--ink-2); }
.head-spacer { flex: 1; }
.streak {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-disp); font-weight: 700; font-size: 14px;
  color: var(--meal-text); background: var(--meal-soft);
  padding: 4px 10px; border-radius: 999px;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--ink-2);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- layout ---------- */
.view {
  padding: 4px 16px calc(var(--tab-h) + 88px + env(safe-area-inset-bottom));
  animation: viewin .22s ease;
}
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .view, .sheet, .needle, .fab { animation: none !important; transition: none !important; }
}

.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card h3 {
  font-family: var(--font-disp); font-size: 14px; font-weight: 700;
  color: var(--ink-2); margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.card h3 .dot { width: 8px; height: 8px; border-radius: 50%; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--ink-2); font-size: 13px; }
.tiny { color: var(--ink-3); font-size: 11.5px; }

/* ---------- tabbar & fab ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10.5px; color: var(--ink-3); font-weight: 500;
}
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab.active { color: var(--ink); }
.tab[data-view="home"].active { color: var(--meal-text); }
.tab[data-view="meals"].active { color: var(--meal-text); }
.tab[data-view="trends"].active { color: var(--weight-text); }
.tab[data-view="workout"].active { color: var(--train-text); }
.tab-spacer { flex: 0 0 76px; }
.fab {
  position: fixed; z-index: 41;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) - 34px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(145deg, var(--meal), #D4540A);
  color: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-fab);
  transition: transform .15s ease;
}
.fab:active { transform: translateX(-50%) scale(.92); }
.fab svg { width: 30px; height: 30px; }

/* ---------- bottom sheet ---------- */
.sheet-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 16, 10, .45);
  animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 51; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 560px;
  max-height: 88dvh; overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheetup .24s cubic-bezier(.2, .9, .3, 1);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
}
@keyframes sheetup { from { transform: translate(-50%, 40%); opacity: .4; } }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 12px; }
.sheet h2 { font-family: var(--font-disp); font-size: 17px; font-weight: 700; margin-bottom: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 84px);
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 500;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); max-width: 86%;
  animation: fadein .15s ease;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-disp); font-weight: 700; font-size: 15px;
  border-radius: 14px; padding: 12px 18px; width: 100%;
  background: var(--meal); color: #fff;
  transition: filter .12s ease;
}
.btn:active { filter: brightness(.9); }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: none; color: var(--ink-2); font-weight: 500; }
.btn.danger { background: none; color: var(--bad); font-weight: 500; }
.btn.small { padding: 8px 14px; font-size: 13px; width: auto; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* segmented control */
.seg {
  display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px;
}
.seg button {
  flex: 1; padding: 7px 4px; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.seg button.active {
  background: var(--surface); color: var(--ink); font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
}

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  background: var(--surface-2); color: var(--ink-2);
  border: 1.5px solid transparent;
}
.chip.on { background: var(--train-soft); color: var(--train-text); border-color: var(--train); font-weight: 700; }
.chip.meal-on { background: var(--meal-soft); color: var(--meal-text); border-color: var(--meal); font-weight: 700; }

/* ---------- home: dial gauge ---------- */
.dial-wrap { text-align: center; padding-top: 4px; }
.dial-kcal {
  font-family: var(--font-disp); font-weight: 900; font-size: 44px; line-height: 1.05;
  letter-spacing: .01em; font-variant-numeric: tabular-nums;
}
.dial-kcal .unit { font-size: 16px; font-weight: 700; color: var(--ink-2); margin-left: 2px; }
.dial-label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.dial-svg { width: 100%; max-width: 320px; margin: 0 auto; }
.dial-sub { display: flex; justify-content: space-between; max-width: 300px; margin: -6px auto 0; }
.dial-sub div { text-align: center; }
.dial-sub .v { font-family: var(--font-disp); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.dial-sub .k { font-size: 11px; color: var(--ink-3); }
.needle { transition: transform .8s cubic-bezier(.3, 1.4, .4, 1); }

/* PFC bars */
.pfc-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pfc-cell .k { font-size: 11.5px; color: var(--ink-2); display: flex; justify-content: space-between; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.pfc-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pfc-bar i { display: block; height: 100%; border-radius: 4px; }

/* meal timeline (home) */
.mealstrip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.mealstrip::-webkit-scrollbar { display: none; }
.mealcard-s {
  flex: 0 0 108px; border-radius: 14px; overflow: hidden; background: var(--surface-2);
  text-align: left; position: relative;
}
.mealcard-s img, .mealcard-s .noimg { width: 108px; height: 82px; object-fit: cover; display: block; }
.mealcard-s .noimg { display: grid; place-items: center; color: var(--ink-3); font-size: 24px; }
.mealcard-s .cap { padding: 6px 8px 8px; }
.mealcard-s .cap b { font-family: var(--font-disp); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.mealcard-s .cap span { display: block; font-size: 10.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mealtype-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(20, 16, 10, .6); color: #fff;
  font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700;
}

/* quick cards on home */
.quick2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.quick2 .card { margin-bottom: 0; }
.bigv { font-family: var(--font-disp); font-weight: 900; font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.bigv .unit { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.delta-up { color: var(--bad); font-weight: 700; font-size: 12.5px; }
.delta-down { color: var(--good); font-weight: 700; font-size: 12.5px; }

/* empty state */
.empty { text-align: center; padding: 26px 10px; color: var(--ink-2); }
.empty img { width: 100%; max-width: 380px; border-radius: 14px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ---------- meals view ---------- */
.daynav { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.daynav .dtitle { flex: 1; text-align: center; font-family: var(--font-disp); font-weight: 700; font-size: 16px; }
.daynav .dtitle small { display: block; font-size: 11px; color: var(--ink-2); font-weight: 500; }
.meal-section { margin-bottom: 16px; }
.meal-section > h4 {
  font-family: var(--font-disp); font-size: 13.5px; color: var(--ink-2);
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
}
.meal-section > h4 b { color: var(--meal-text); font-variant-numeric: tabular-nums; }
.mealcard {
  display: flex; gap: 12px; background: var(--surface); border-radius: var(--radius-s);
  box-shadow: var(--shadow); padding: 10px; margin-bottom: 8px; width: 100%; text-align: left;
}
.mealcard img, .mealcard .noimg {
  width: 86px; height: 86px; border-radius: 10px; object-fit: cover; flex: 0 0 86px;
}
.mealcard .noimg { background: var(--surface-2); display: grid; place-items: center; font-size: 28px; color: var(--ink-3); }
.mealcard .mc-body { flex: 1; min-width: 0; }
.mealcard .mc-kcal { font-family: var(--font-disp); font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.mealcard .mc-kcal .unit { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.mealcard .mc-items { font-size: 12px; color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mealcard .mc-pfc { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* calendar */
.cal { width: 100%; }
.cal-head { display: flex; align-items: center; margin-bottom: 8px; }
.cal-head b { flex: 1; text-align: center; font-family: var(--font-disp); font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .wd { text-align: center; font-size: 11px; color: var(--ink-3); padding: 3px 0; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-variant-numeric: tabular-nums; position: relative;
}
.cal-cell:active { background: var(--surface-2); }
.cal-cell.dim { color: var(--ink-3); opacity: .45; }
.cal-cell.today { outline: 2px solid var(--meal); outline-offset: -2px; font-weight: 700; }
.cal-cell.sel { background: var(--meal-soft); font-weight: 700; }
.cal-cell .dots { display: flex; gap: 2px; height: 4px; }
.cal-cell .dots i { width: 4px; height: 4px; border-radius: 50%; }
.cal-cell.done { background: var(--train-soft); color: var(--train-text); font-weight: 700; }

/* ---------- capture / edit sheet ---------- */
.cap-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; margin-bottom: 12px; }
.analyzing { text-align: center; padding: 30px 0; }
.analyzing .spin {
  width: 46px; height: 46px; margin: 0 auto 14px;
  border: 4px solid var(--meal-soft); border-top-color: var(--meal);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.items-edit { margin-bottom: 12px; }
.item-row {
  display: grid; grid-template-columns: 1fr 64px 30px; gap: 6px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.item-row .nm { min-width: 0; }
.item-row .nm input { padding: 7px 9px; font-size: 14px; }
.item-row .nm .amt { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.item-row .kc input { padding: 7px 6px; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.item-row .rm { color: var(--ink-3); font-size: 18px; text-align: center; }
.item-block { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.item-block .item-row { border-bottom: none; padding-bottom: 4px; }
.item-ctl { display: flex; align-items: center; gap: 8px; }
.mini-seg { flex: 1; padding: 2px; }
.mini-seg button { padding: 5px 2px; font-size: 11.5px; min-width: 0; }
.stepper {
  display: flex; align-items: center; gap: 2px; flex: 0 0 auto;
  background: var(--surface-2); border-radius: 10px; padding: 2px;
}
.step-btn {
  width: 32px; height: 30px; border-radius: 8px; font-size: 17px; font-weight: 700;
  color: var(--meal-text); display: grid; place-items: center;
}
.step-btn:active { background: var(--meal-soft); }
.step-val { font-family: var(--font-disp); font-weight: 700; font-size: 13px; min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.sum-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-disp); padding: 10px 2px;
}
.sum-line b { font-size: 24px; font-variant-numeric: tabular-nums; }
.advice {
  background: var(--meal-soft); color: var(--meal-text);
  font-size: 13px; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
}
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; margin-bottom: 5px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ---------- trends ---------- */
.range-chips { display: flex; gap: 8px; margin: 10px 0 14px; }
.range-chips .chip.on { background: var(--weight-soft); color: var(--weight-text); border-color: var(--weight); }
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--bg);
  font-size: 12px; padding: 5px 9px; border-radius: 8px;
  transform: translate(-50%, -110%); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stat3 .v { font-family: var(--font-disp); font-weight: 900; font-size: 19px; font-variant-numeric: tabular-nums; }
.stat3 .v .unit { font-size: 11px; font-weight: 700; color: var(--ink-2); }
.stat3 .k { font-size: 11px; color: var(--ink-3); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* period compare */
.period-pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 10px; }
.period-pick span { text-align: center; color: var(--ink-3); }
.period-result { text-align: center; padding: 8px 0 2px; }
.period-result .big { font-family: var(--font-disp); font-weight: 900; font-size: 34px; font-variant-numeric: tabular-nums; }
.period-result .big.minus { color: var(--good); }
.period-result .big.plus { color: var(--bad); }

/* ---------- settings ---------- */
.set-group { margin-bottom: 20px; }
.set-group > h4 { font-family: var(--font-disp); font-size: 13px; color: var(--ink-2); margin-bottom: 8px; padding-left: 4px; }
.goal-preview {
  background: var(--meal-soft); border-radius: var(--radius-s);
  padding: 12px 14px; text-align: center; margin-top: 10px;
}
.goal-preview b { font-family: var(--font-disp); font-size: 22px; color: var(--meal-text); font-variant-numeric: tabular-nums; }
.goal-preview .muted { font-size: 12px; }
.keyrow { display: flex; gap: 8px; }
.keyrow input { flex: 1; }
.keyrow .btn { width: auto; }

/* ---------- login ---------- */
body.logged-out .tabbar, body.logged-out .fab, body.logged-out .app-head { display: none; }
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; padding: 24px 6px calc(24px + env(safe-area-inset-bottom));
}
.login-hero { width: 100%; max-width: 400px; margin: 0 auto 4px; border-radius: 16px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand h1 { font-family: var(--font-disp); font-weight: 900; font-size: 30px; letter-spacing: .04em; }
.login-brand p { color: var(--ink-2); font-size: 13px; }
.login-card { max-width: 400px; margin: 0 auto; width: 100%; }

/* ---------- onboarding ---------- */
.ob-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: all .2s; }
.ob-dots i.on { background: var(--meal); width: 22px; border-radius: 4px; }
.ob-dots i.past { background: var(--meal); opacity: .45; }
.ob-choice {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%;
  padding: 12px 14px; margin-bottom: 8px; border-radius: var(--radius-s);
  background: var(--surface-2); border: 1.5px solid transparent; text-align: left;
}
.ob-choice b { font-family: var(--font-disp); font-size: 15px; }
.ob-choice span { font-size: 12px; color: var(--ink-2); }
.ob-choice.on { background: var(--meal-soft); border-color: var(--meal); }
.ob-choice.on b { color: var(--meal-text); }
.ob-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 14px; z-index: 2;
  width: 38px; height: 38px; border-radius: 12px; font-size: 18px;
  color: var(--ink-2); background: var(--surface-2);
}
.icon-btn.disabled { opacity: .3; pointer-events: none; }

/* ---------- coach ---------- */
.coach-bar {
  position: relative; height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden;
}
.coach-bar i {
  display: block; height: 100%; border-radius: 7px;
  background: linear-gradient(90deg, var(--train), var(--meal));
  transition: width .6s ease;
}
.coach-bar-label {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.coach-tip {
  font-size: 13px; line-height: 1.5; color: var(--ink);
  background: var(--surface-2); border-radius: 10px; padding: 8px 11px;
}
.coach-save {
  display: flex; align-items: baseline; gap: 8px; justify-content: center;
  margin-top: 10px; font-size: 12.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.coach-save b { font-family: var(--font-disp); font-size: 15px; }

/* ---------- mascot カロちゃん ---------- */
.mascot { animation: kalo-bob 3.2s ease-in-out infinite; flex: 0 0 auto; }
.mascot svg { width: 100%; height: 100%; }
.mascot .k-line { fill: none; stroke: #3A2A1A; stroke-width: 3; stroke-linecap: round; }
.mascot .k-arm { fill: none; stroke: #D8560C; stroke-width: 7; stroke-linecap: round; }
.mascot .k-eye { animation: kalo-blink 4.6s infinite; transform-origin: center 61px; }
.mascot .k-sweat { animation: kalo-sweat 1.4s ease-in-out infinite; }
.mascot .k-zzz { animation: kalo-zzz 2.2s ease-in-out infinite; }
.mascot .k-spark, .mascot .k-spark2 { animation: kalo-spark 1s ease-in-out infinite; }
.mascot .k-spark2 { animation-delay: .4s; }
.mascot.m-cheer, .mascot.m-party { animation: kalo-hop .7s ease-in-out infinite; }
.mascot.m-muscle { animation: kalo-flex 1.4s ease-in-out infinite; }
@keyframes kalo-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes kalo-hop { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes kalo-flex { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes kalo-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
@keyframes kalo-sweat { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(4px); opacity: .5; } }
@keyframes kalo-zzz { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes kalo-spark { 0%, 100% { opacity: .4; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.15); } }

.mascot-card { background: linear-gradient(135deg, var(--surface) 60%, var(--meal-soft)); }
.mascot-row { display: flex; align-items: center; gap: 10px; }
.bubble {
  position: relative; flex: 1; background: var(--surface-2);
  border-radius: 14px; padding: 10px 13px; font-size: 13.5px; line-height: 1.55;
}
.bubble::before {
  content: ""; position: absolute; left: -7px; top: 42%;
  border: 7px solid transparent; border-right-color: var(--surface-2); border-left: 0;
}

/* ---------- daily quests ---------- */
.quests { margin-top: 12px; }
.quests-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.quests-head b { font-family: var(--font-disp); font-size: 13.5px; color: var(--ink-2); }
.quest {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 4px; border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.quest:last-of-type { border-bottom: none; }
.quest-check {
  width: 20px; height: 20px; border-radius: 7px; flex: 0 0 20px;
  border: 2px solid var(--line); display: grid; place-items: center;
  font-size: 12px; color: #fff; transition: all .25s;
}
.quest.done .quest-check { background: var(--train); border-color: var(--train); }
.quest-label { flex: 1; }
.quest.done .quest-label { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--train); }
.quest-xp { font-family: var(--font-disp); font-size: 11.5px; font-weight: 700; color: var(--meal-text); }
.quest-complete {
  text-align: center; font-family: var(--font-disp); font-weight: 700; font-size: 13.5px;
  color: var(--train-text); padding-top: 8px;
}

/* ---------- avatar / mypage ---------- */
.avatar-btn {
  position: relative; width: 46px; height: 44px; border-radius: 14px;
  display: grid; place-items: center; background: var(--surface);
  box-shadow: var(--shadow);
}
.avatar-btn:active { transform: scale(.94); }
.avatar-face { width: 34px; height: 32px; display: block; }
.avatar-face svg { width: 100%; height: 100%; }
.avatar-lv {
  position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  background: var(--meal); color: #fff; font-family: var(--font-disp);
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 999px; white-space: nowrap;
}
.mypage-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.mypage-id b { font-family: var(--font-disp); font-size: 20px; display: block; }
.mypage-title { color: var(--meal-text); font-size: 13px; font-weight: 700; }
.level-box { background: var(--surface-2); border-radius: var(--radius-s); padding: 12px 14px; margin-bottom: 16px; }
.level-lv { font-family: var(--font-disp); font-size: 18px; }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--surface-2); border-radius: 12px; padding: 9px 3px 7px;
  opacity: .45; filter: grayscale(.6);
}
.badge.earned { opacity: 1; filter: none; background: var(--meal-soft); }
.badge-emoji { font-size: 21px; }
.badge-name { font-size: 9.5px; color: var(--ink-2); font-weight: 500; text-align: center; line-height: 1.2; }
.badge.earned .badge-name { color: var(--meal-text); font-weight: 700; }
.mypage-link {
  display: block; width: 100%; text-align: left;
  padding: 13px 14px; border-radius: var(--radius-s); background: var(--surface-2);
  font-size: 14.5px; font-weight: 500; margin-bottom: 8px;
}
.mypage-link:active { filter: brightness(.94); }

/* ---------- character pick & evolution ---------- */
.char-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.char-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface-2); border-radius: 14px; padding: 10px 4px 8px;
  border: 2px solid transparent; transition: all .15s;
}
.char-cell b { font-family: var(--font-disp); font-size: 12.5px; }
.char-cell.on { background: var(--meal-soft); border-color: var(--meal); }
.char-cell.on b { color: var(--meal-text); }
.char-cell:active { transform: scale(.95); }
.char-cell .mascot { animation: none; }
.char-cell.on .mascot { animation: kalo-hop .7s ease-in-out infinite; }
.mypage-partner { display: block; font-size: 12px; color: var(--ink-2); }
.evolve-note {
  text-align: center; font-size: 12.5px; font-weight: 700; color: var(--weight-text);
  background: var(--weight-soft); border-radius: 10px; padding: 8px 10px; margin-bottom: 14px;
}
.m-stage3 .k-aura { animation: aura-pulse 2.4s ease-in-out infinite; }
@keyframes aura-pulse { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }
.evolve-holder { min-height: 130px; display: grid; place-items: center; }
.evolve-flash { animation: evo-flash .35s steps(2) infinite; }
@keyframes evo-flash {
  0% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(0) invert(1) drop-shadow(0 0 12px #fff); transform: scale(1.06); }
  100% { filter: brightness(0); transform: scale(.96); }
}
.evolve-pop { animation: evo-pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes evo-pop { from { transform: scale(.4); filter: brightness(3); } to { transform: scale(1); filter: brightness(1); } }

/* ---------- confetti & level up ---------- */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti-layer i {
  position: absolute; top: -12px; width: 9px; height: 9px; display: block;
  animation: confetti-fall 1.4s ease-in forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: .2; }
}
.levelup-back {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(20, 16, 10, .55); animation: fadein .2s ease;
}
.levelup-card {
  background: var(--surface); border-radius: 22px; padding: 26px 30px;
  display: flex; flex-direction: column; align-items: center;
  animation: levelup-pop .4s cubic-bezier(.2, 1.4, .4, 1);
  max-width: 320px; text-align: center;
}
@keyframes levelup-pop { from { transform: scale(.6); opacity: 0; } }
.levelup-title { font-family: var(--font-disp); font-weight: 900; font-size: 21px; margin-top: 8px; }
.levelup-sub { color: var(--meal-text); font-weight: 700; font-size: 14px; margin-top: 2px; }

/* ---------- body photo compare ---------- */
.bodycell.picked { outline: 3px solid var(--train); outline-offset: -3px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare-cell img { width: 100%; border-radius: 12px; display: block; }
.compare-cap { text-align: center; font-size: 12px; color: var(--ink-2); padding-top: 4px; font-variant-numeric: tabular-nums; }
.compare-cap b { font-family: var(--font-disp); color: var(--ink); }

/* card entrance stagger */
.view > .card { animation: cardin .35s ease backwards; }
.view > .card:nth-child(2) { animation-delay: .05s; }
.view > .card:nth-child(3) { animation-delay: .1s; }
.view > .card:nth-child(4) { animation-delay: .15s; }
.view > .card:nth-child(5) { animation-delay: .2s; }
@keyframes cardin { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  .mascot, .mascot *, .view > .card, .confetti-layer i, .levelup-card { animation: none !important; }
}

/* ---------- usability pass ---------- */
/* 親指で押しやすい高さ */
.btn.small { min-height: 44px; }
.seg button, .chip { min-height: 40px; }
.item-row { grid-template-columns: 1fr 64px 44px; }
.item-row .rm { height: 44px; display: grid; place-items: center; }
textarea { resize: vertical; line-height: 1.5; }

/* 記録メニュー */
.opt-row { align-items: center; box-shadow: none; background: var(--surface-2); margin-bottom: 8px; min-height: 60px; }
.opt-emoji { font-size: 28px; flex: 0 0 46px; text-align: center; }
.opt-title { font-family: var(--font-disp); font-weight: 700; font-size: 15px; }

/* 食事フォーム */
.cap-preview-sm { max-height: 150px; cursor: zoom-in; }
.advice.warn { background: #FFF1E6; color: #A34A0C; }
html[data-theme="dark"] .advice.warn { background: #3A2410; color: #FFB37A; }
.sheet-foot {
  position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); z-index: 3;
  background: var(--surface); margin: 8px -18px 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, .25);
}
.sheet-foot .btn.ghost { margin-top: 2px; min-height: 40px; }
.form-details { margin: 4px 0 10px; }
.form-details summary {
  list-style: none; cursor: pointer; font-size: 13px; color: var(--ink-2);
  padding: 8px 10px; background: var(--surface-2); border-radius: 10px;
}
.form-details summary::-webkit-details-marker { display: none; }
.pfc-toggle {
  font-size: 11px; color: var(--ink-3); padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); min-height: 26px;
}
.pfc-row-edit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.pfc-row-edit input { padding: 6px 8px; font-size: 13px; margin-top: 2px; }

/* ざっくり記録 */
.quick-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-size {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 6px 10px; border-radius: 14px; background: var(--surface-2);
  border: 2px solid transparent;
}
.quick-size b { font-family: var(--font-disp); font-size: 18px; }
.quick-size span { font-size: 12.5px; color: var(--meal-text); font-weight: 700; }
.quick-size:active { border-color: var(--meal); background: var(--meal-soft); }

/* クエスト行をボタン化 */
button.quest { width: 100%; text-align: left; font-family: inherit; }
button.quest:not([disabled]):active { background: var(--surface-2); }
.quest.bonus .quest-label { color: var(--weight-text); font-weight: 700; }

/* 写真の全画面表示 */
.lightbox {
  position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .92);
  display: grid; place-items: center; animation: fadein .15s ease;
}
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; }

/* 保存後の再描画ではカードの入場アニメを再生しない */
.view.no-anim, .view.no-anim > .card { animation: none !important; }

/* misc */
.hr { height: 1px; background: var(--line); margin: 14px 0; border: none; }
a { color: var(--weight-text); }
