:root {
  --bg: #f6f3ee;
  --card: #fffcf8;
  --ink: #1c1915;
  --muted: #5e584f;
  --line: #e4ddd2;
  --green: #1f6b4a;
  --green-soft: #e7f3ec;
  --fat: #a56b12;
  --carb: #2f5f86;
  --over: #9f2d2d;
  --shadow: 0 8px 24px rgba(40, 32, 20, 0.06);
  color-scheme: light;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #e7e2d8; color: var(--ink); }
body { min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
#app {
  width: min(430px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}
.topbar, .datebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
.topbar h1, .datebar h1 {
  font-size: 20px;
  line-height: 1.3;
  margin: 0;
  font-weight: 700;
}
.brand { font-weight: 700; letter-spacing: 0.04em; }
.spacer { width: 32px; }
.iconbtn, .textbtn {
  border: 0;
  background: transparent;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  color: var(--green);
  font-weight: 700;
}
.screen { padding: 4px 16px 128px; }
.banner {
  background: #fff7e8;
  border: 1px solid #efd7a5;
  color: #6a4b12;
  border-radius: 14px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
}
.banner button { margin-top: 8px; }
.card, .hero, .meal, .empty, .live, .preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.hero { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 14px; align-items: center; }
.ring {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring, var(--green)) calc(var(--p) * 1%), #ece6dc 0);
}
.ring-in {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-in strong { font-size: 28px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring-in span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.bar { margin-bottom: 8px; }
.bar-top { display: flex; justify-content: space-between; font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.bar-top b { font-weight: 700; }
.track { height: 8px; background: #efeae2; border-radius: 99px; overflow: hidden; }
.fill { height: 100%; border-radius: 99px; width: 0; }
.fill.p { background: var(--green); }
.fill.f { background: var(--fat); }
.fill.c { background: var(--carb); }
.fill.over { background: var(--over); }
.coach { margin: 12px 0; padding: 12px 14px; background: var(--green-soft); border-radius: 14px; line-height: 1.55; font-size: 14px; }
.micros { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.micros div, .weight {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.micros span, .weight span { display: block; color: var(--muted); font-size: 12px; }
.micros strong, .weight strong { font-variant-numeric: tabular-nums; font-size: 16px; }
.bad { color: var(--over); }
.weight { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; }
.weight input { width: 110px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.split button, .seg button, .chip, .tag {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  min-height: 44px;
}
.split button { padding: 8px; }
.split button small { display: block; }
.split button small, .fine { color: var(--muted); font-size: 12px; }
.split button.on { background: var(--green); color: white; border-color: var(--green); }
.split button.on small { color: rgba(255,255,255,.85); }
.day-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.day-grid button {
  padding: 10px 8px; border: 1px solid var(--line); background: var(--card); border-radius: 14px;
  font-size: 14px; line-height: 1.3;
}
.day-grid button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.day-grid button.on { background: var(--green); color: white; border-color: var(--green); }
.day-grid button.on small { color: rgba(255,255,255,.85); }
.fine { margin: 4px 0 12px; line-height: 1.5; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; margin-top: 8px; }
.week-col {
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.week-track { height: 56px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.week-bar { width: 14px; background: var(--green); border-radius: 6px 6px 2px 2px; }
.week-bar.over { background: var(--over); }
.week-dot { width: 6px; height: 6px; border-radius: 50%; background: #ddd4c8; }
.week-dot.hit { background: var(--green); }
.week-wd { font-size: 11px; color: var(--muted); }
.week-col.on .week-wd { color: var(--ink); font-weight: 700; }
.meal { margin-top: 12px; padding: 8px; }
.meal h2 { font-size: 13px; margin: 6px 8px; color: var(--muted); font-weight: 700; }
.item, .row-main, .recipe-card {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
}
.row-main { flex-direction: column; align-items: flex-start; gap: 2px; }
.item b, .row-main b, .recipe-card b { display: block; font-size: 15px; }
.item small, .row-main small, .recipe-card small { display: block; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.item strong { font-variant-numeric: tabular-nums; font-size: 16px; }
.empty { padding: 22px 16px; text-align: left; line-height: 1.6; }
.empty p { margin: 0 0 8px; }
.search, .input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  min-height: 48px;
  font-size: 16px;
  padding: 10px 12px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 4px 0 12px; }
.cat-card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  min-height: 68px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}
.cat-card b { font-size: 15px; }
.cat-card small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.backchip { padding-left: 0; }
.seg.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.seg.cols3 button { font-size: 13px; padding: 0 4px; }
.seg button.on, .chip.on, .tag.on { background: var(--ink); color: white; border-color: var(--ink); }
.chips, .tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip, .tag { padding: 0 12px; }
.row { display: flex; align-items: center; gap: 4px; }
.star { border: 0; background: transparent; min-width: 44px; min-height: 44px; color: var(--fat); font-size: 18px; }
.group-label { margin: 16px 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.badge {
  display: inline-block;
  margin-left: 6px;
  background: #fff1d6;
  color: #8a5a10;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field small, .note, .warn { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 6px; }
.warn { color: #8a5a10; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); margin-bottom: 8px; }
.radio:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.radio input { margin-top: 3px; accent-color: var(--green); }
.radio b { display: block; }
.radio small { display: block; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.btn { border: 0; border-radius: 14px; min-height: 48px; padding: 0 14px; font-weight: 700; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.block:not(.primary):not(.ghost):not(.danger) { background: white; border: 1px solid var(--line); }
.btn.primary { background: var(--green); color: white; }
.btn.ghost { background: transparent; color: var(--green); }
.btn.danger { background: transparent; color: var(--over); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 14px; line-height: 1.45; }
.section-title { font-size: 13px; margin: 18px 0 8px; color: var(--muted); }
.kv { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.kv th, .kv td { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv th { color: var(--muted); font-weight: 600; width: 42%; }
.ing { display: grid; grid-template-columns: 1fr 96px 44px; gap: 6px; align-items: center; margin-bottom: 8px; }
.ing input { min-height: 44px; }
.live, .preview { padding: 12px 14px; margin: 10px 0; }
.live strong, .preview strong { font-variant-numeric: tabular-nums; }
.footer-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 16px; }
.fab, .tabbar { position: fixed; z-index: 5; }
.fab {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 32px;
  line-height: 1;
  box-shadow: 0 10px 20px rgba(31, 107, 74, 0.28);
  right: max(16px, calc(50% - 215px + 16px));
  bottom: calc(76px + env(safe-area-inset-bottom));
}
.tabbar {
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, 100%);
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 252, 248, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  border: 0;
  background: transparent;
  min-height: 52px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.tab.on { color: var(--green); }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.cal-day {
  border: 0;
  background: transparent;
  min-height: 46px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 700;
}
.cal-day.today { background: var(--green-soft); }
.cal-day.on { background: var(--green); color: white; }
.mark { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: block; }
.cal-day.on .mark { background: white; }
.mark.off { background: transparent; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager h1 { flex: 1; text-align: center; font-size: 16px; margin: 0; }
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.sheet th:first-child, .sheet td:first-child { text-align: left; }
.sheet tr.total td { font-weight: 700; }
.note { white-space: pre-wrap; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(380px, calc(100% - 32px));
  background: var(--ink);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 9;
  line-height: 1.45;
}
h2.block-title { font-size: 18px; margin: 8px 0 10px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 12px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.kpi > span, .kpi small { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin: 4px 0 6px; font-size: 28px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi strong.over { color: var(--over); }
.kpi-sub { font-size: 16px; color: var(--muted); letter-spacing: 0; }
.kpi .track { margin-bottom: 6px; }
.chart-card, .mix-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px 12px 10px;
  margin-bottom: 12px;
}
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart-head h2, .mix-card h2 { font-size: 15px; margin: 0 0 10px; }
.chart-head span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.vchart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; }
.vchart.month { gap: 1px; }
.vcol {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.vplot {
  position: relative;
  width: 100%;
  height: 128px;
  background:
    linear-gradient(#efeae2, #efeae2) center / 100% 1px no-repeat,
    linear-gradient(#efeae2, #efeae2) left bottom / 100% 1px no-repeat;
}
.vbar {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 0;
  z-index: 0;
  background: var(--green);
  border-radius: 5px 5px 2px 2px;
}
.vchart.month .vbar { left: 8%; right: 8%; border-radius: 2px 2px 1px 1px; }
.vbar.over { background: var(--over); }
.vtick {
  position: absolute;
  left: 6%;
  right: 6%;
  z-index: 1;
  height: 2px;
  margin-bottom: -1px;
  background: #1c1915;
  border-radius: 1px;
}
.vlab { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; }
.vchart.month .vlab { font-size: 8px; }
.mix-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: #efeae2; }
.mix-bar span { display: block; height: 100%; }
.mix-bar .p { background: var(--green); }
.mix-bar .f { background: var(--fat); }
.mix-bar .c { background: var(--carb); }
.mix-rows { margin-top: 10px; }
.mix-rows div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.swatch.p { background: var(--green); }
.swatch.f { background: var(--fat); }
.swatch.c { background: var(--carb); }
.hitrow { display: flex; flex-wrap: wrap; gap: 6px; }
.hit {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: #e4ddd2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.hit.ok { background: var(--green); color: white; }
.hit.miss { background: var(--over); color: white; }
.hitrow.week .hit { width: 36px; height: 32px; border-radius: 10px; }
.recipe-card { border: 1px solid var(--line); background: var(--card); border-radius: 16px; margin-bottom: 8px; box-shadow: var(--shadow); }
@media (max-width: 360px) {
  .hero { grid-template-columns: 1fr; justify-items: center; }
  .micros { grid-template-columns: 1fr; }
}
