/* 食事ログ — やわらかい丸ゴシック × クリーム × コーラル */
:root {
  --bg: #fbf6ef;
  --bg2: #f4ece1;
  --card: #ffffff;
  --ink: #3a2f2a;
  --sub: #8c7f76;
  --line: #efe5d8;
  --accent: #f0745a;        /* コーラル */
  --accent-ink: #d9583e;
  --accent-soft: #fde8e1;
  --mint: #3fb489;
  --mint-soft: #dcf4e9;
  --green: #3fb489;
  --green-soft: #dcf4e9;
  --yellow: #f2a516;
  --yellow-soft: #fff1cf;
  --red: #e5484d;
  --red-soft: #fde2e2;
  --none: #f1ebe2;
  --shadow: 0 1px 2px rgba(120, 80, 50, .06), 0 6px 18px rgba(120, 80, 50, .07);
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1715; --bg2: #241f1c; --card: #2a2420; --ink: #f3ebe4; --sub: #b0a397; --line: #3b332d;
    --accent: #ff8d73; --accent-ink: #ff9f88; --accent-soft: #42261f;
    --mint: #5fd0a4; --mint-soft: #1e3a2f; --green: #5fd0a4; --green-soft: #1e3a2f;
    --yellow: #ffbe3d; --yellow-soft: #3d3016; --red: #ff6b6f; --red-soft: #43211f; --none: #332c27;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 500 16px/1.6 "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
b, strong, h1, h2 { font-weight: 700; }
.boot { padding: 40vh 16px; text-align: center; color: var(--sub); }
.wrap { max-width: 600px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--sub); font-size: 13px; }
.tiny { font-size: 12px; margin: 8px 0 0; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrapy { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ヘッダー */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
header.top h1 { font-size: 19px; margin: 0; flex: 1; letter-spacing: .02em; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px; font-size: 14px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; white-space: nowrap; }
.saving { font-size: 12px; color: var(--mint); white-space: nowrap; }
.saving.busy { color: var(--sub); }

/* 下のタブ */
nav.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  width: min(560px, calc(100% - 24px));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 8px 28px rgba(120, 80, 50, .16);
  display: flex; padding: 6px;
}
nav.tabs button { flex: 1; background: none; border: 0; padding: 6px 0 4px; border-radius: 18px; font-size: 11px; color: var(--sub); display: flex; flex-direction: column; align-items: center; gap: 1px; transition: background .15s; }
nav.tabs button .ic { font-size: 21px; line-height: 1.1; filter: grayscale(.6); opacity: .8; transition: transform .15s; }
nav.tabs button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
nav.tabs button.on .ic { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }

/* カード */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.card h2 .r { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--sub); }
.card.empty { background: transparent; box-shadow: none; border: 2px dashed var(--line); padding: 12px 16px; }
.card.empty h2 { margin: 0; color: var(--sub); }
.card.alert { background: var(--red-soft); }

/* 日付ナビ */
.daynav { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.daynav .d { flex: 1; text-align: center; font-weight: 700; font-size: 18px; line-height: 1.3; }
.daynav .d small { display: block; font-weight: 500; font-size: 12px; color: var(--sub); }
.cal-nav { margin: 0 0 10px; }

/* ボタン */
.btn { border: 0; background: var(--bg2); border-radius: 14px; padding: 9px 16px; min-height: 42px; font-weight: 700; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.96); }
.btn.pri { background: var(--accent); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.sm { padding: 5px 12px; min-height: 34px; font-size: 14px; border-radius: 11px; }
.btn.icon { width: 42px; padding: 0; font-size: 22px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); }
.btn.danger { color: var(--red); background: var(--red-soft); }
.btn:disabled { opacity: .35; box-shadow: none; }
.link { border: 0; background: none; color: var(--accent-ink); font-weight: 700; padding: 6px 4px; font-size: 14px; }
.link.sm { font-size: 12px; padding: 0 4px; }
.link.muted { color: var(--sub); font-weight: 500; }

/* セグメント */
.seg { display: flex; background: var(--bg2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 11px; padding: 8px 4px; font-size: 14px; color: var(--sub); font-weight: 700; transition: background .15s; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 6px rgba(120, 80, 50, .12); }
.seg.gpt button { font-size: 13px; }
.seg.gpt button.on.ok { background: var(--mint); color: #fff; }
.seg.gpt button.on.cond { background: var(--yellow); color: #fff; }
.seg.gpt button.on.ng { background: var(--red); color: #fff; }
.seg.range { margin: 14px 0 0; }

/* サマリー */
.summary { position: relative; overflow: hidden; }
.summary::after { content: ""; position: absolute; right: -40px; top: -40px; width: 130px; height: 130px; border-radius: 50%; background: var(--accent-soft); opacity: .6; pointer-events: none; }
.summary.green::after { background: var(--mint-soft); }
.summary.red::after { background: var(--red-soft); }
.summary.yellow::after { background: var(--yellow-soft); }
.summary > * { position: relative; z-index: 1; }
.total { display: flex; align-items: baseline; gap: 6px; margin: 14px 0 8px; flex-wrap: wrap; }
.total b { font-size: 40px; letter-spacing: -.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.total b::after { content: "kcal"; font-size: 15px; margin-left: 3px; color: var(--sub); letter-spacing: 0; }
.bar { height: 12px; border-radius: 6px; background: var(--bg2); position: relative; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb199, var(--accent)); border-radius: 6px; transition: width .4s; }
.bar.over i { background: linear-gradient(90deg, #ffd27a, var(--yellow)); }
.bar .floor { position: absolute; top: -3px; bottom: -3px; width: 3px; border-radius: 2px; background: var(--ink); opacity: .35; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; background: var(--bg2); font-weight: 700; color: var(--sub); }
.pill.red { background: var(--red); color: #fff; }
.pill.okp { background: var(--mint-soft); color: var(--mint); }
.pill.gpt-ok { background: var(--mint-soft); color: var(--mint); }
.pill.gpt-cond { background: var(--yellow-soft); color: #b07600; }
.pill.gpt-ng { background: var(--red-soft); color: var(--red); }
.tags { margin-top: 10px; gap: 6px; }

.flags { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.flags li { padding: 8px 12px; border-radius: 12px; font-size: 14px; display: flex; gap: 8px; align-items: flex-start; line-height: 1.5; }
.flags li::before { flex: none; font-size: 13px; margin-top: 1px; }
.flags li.red { background: var(--red-soft); color: #b3262b; }
.flags li.red::before { content: "●"; color: var(--red); }
.flags li.yellow { background: var(--yellow-soft); color: #8a5a00; }
.flags li.yellow::before { content: "●"; color: var(--yellow); }
@media (prefers-color-scheme: dark) { .flags li.red { color: #ffb3b3; } .flags li.yellow { color: #ffdc8a; } }
.ok-line { margin-top: 12px; padding: 10px 14px; border-radius: 14px; background: var(--mint-soft); color: var(--mint); font-weight: 700; font-size: 15px; }

/* 食事タブ */
.mealtabs { display: flex; gap: 8px; overflow-x: auto; margin: 16px -16px 0; padding: 2px 16px 6px; scrollbar-width: none; scroll-snap-type: x proximity; }
.mealtabs::-webkit-scrollbar { display: none; }
.mealtabs button { flex: 1 0 auto; min-width: 70px; border: 0; background: var(--card); border-radius: 18px; padding: 8px 8px 6px; text-align: center; box-shadow: var(--shadow); scroll-snap-align: start; transition: transform .12s, background .15s; }
.mealtabs button .mi { display: block; font-size: 24px; line-height: 1.2; }
.mealtabs button b { display: block; font-size: 14px; }
.mealtabs button small { font-size: 11px; color: var(--sub); white-space: nowrap; }
.mealtabs button.on { background: var(--accent); color: #fff; transform: translateY(-2px); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent); }
.mealtabs button.on small { color: #ffe9e3; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 4px; vertical-align: 1px; border: 1.5px solid var(--card); box-sizing: content-box; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); } .dot.green { background: var(--mint); }

/* 写真 */
.photos { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photos .ph { flex: none; width: 104px; height: 104px; border-radius: 16px; overflow: hidden; position: relative; background: var(--bg2); }
.photos .phb { border: 0; padding: 0; width: 100%; height: 100%; display: block; background: none; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph .x { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .5); color: #fff; font-size: 13px; line-height: 26px; padding: 0; }
.photos .ph time { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); padding: 10px 4px 3px; text-align: center; pointer-events: none; }
.addphoto { flex: none; width: 104px; height: 104px; border-radius: 16px; border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; cursor: pointer; text-align: center; line-height: 1.35; background: var(--card); }
.addphoto .cam { font-size: 28px; line-height: 1.2; }
.addphoto.need { background: var(--accent-soft); border-style: solid; border-color: transparent; animation: pulse 2.4s ease-in-out infinite; }
.addphoto input { display: none; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* 品目 */
.items { list-style: none; padding: 0; margin: 12px 0 0; background: var(--bg); border-radius: 16px; }
.items li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; }
.items .nm { flex: 1; min-width: 0; font-size: 15px; line-height: 1.35; }
.items .nm small { display: block; font-size: 12px; color: var(--sub); }
.items .kc { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; min-width: 3em; text-align: right; }
.qty { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: 999px; padding: 2px; }
.qty button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--bg2); padding: 0; font-weight: 700; }
.qty span { min-width: 1.5em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.cat { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--bg2); color: var(--sub); margin-left: 6px; vertical-align: 2px; font-weight: 700; }
.cat.bad { background: var(--red-soft); color: var(--red); }

/* よく食べるもの */
.sec-title { font-size: 13px; color: var(--sub); margin: 18px 0 6px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.foods { display: flex; flex-wrap: wrap; gap: 8px; }
.foods button { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; transition: transform .08s, background .15s; }
.foods button small { color: var(--sub); margin-left: 5px; font-weight: 500; font-size: 12px; }
.foods button.ng { border-color: color-mix(in srgb, var(--red) 45%, transparent); color: var(--red); }
.foods button:active { transform: scale(.94); background: var(--accent-soft); border-color: var(--accent); }

details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--accent-ink); font-size: 14px; font-weight: 700; padding: 6px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary.h2s { font-size: 16px; color: var(--ink); }
.form { display: grid; gap: 8px; margin-top: 6px; }
.form .row > * { min-width: 0; }
input[type=text], input[type=number], input[type=date], select, textarea {
  border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 9px 12px; min-height: 44px; width: 100%; font-size: 16px; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--card); }
input:disabled { opacity: .6; }
textarea { min-height: 80px; resize: vertical; }
label.ck { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; font-size: 15px; line-height: 1.45; cursor: pointer; }
label.ck.sm { font-size: 14px; padding: 4px 0; }
label.ck input, label.mini input, .slots input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
label.mini { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
label.mini input { width: 18px; height: 18px; }

/* コメント */
.comments { display: grid; gap: 8px; margin-top: 12px; }
.comments:empty { display: none; }
.cm { padding: 10px 14px; border-radius: 18px 18px 18px 6px; font-size: 14px; background: var(--bg2); white-space: pre-wrap; word-break: break-word; max-width: 88%; }
.cm.aki { background: var(--accent-soft); }
.cm.raisa { background: var(--mint-soft); justify-self: end; border-radius: 18px 18px 6px 18px; }
.cm .meta { font-size: 11px; color: var(--sub); display: flex; gap: 8px; margin-bottom: 2px; align-items: center; }
.cm .meta button { margin-left: auto; border: 0; background: none; color: var(--sub); font-size: 11px; padding: 0; text-decoration: underline; }
.cform { display: flex; gap: 8px; margin-top: 10px; }
.cform input { flex: 1; border-radius: 999px; padding-left: 16px; }
.cform .btn { border-radius: 999px; }
.memo { white-space: pre-wrap; margin: 8px 0 0; }

/* 体重 */
.weight-in { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.weight-in input { width: 120px; font-size: 20px; font-weight: 700; text-align: center; }

/* カレンダー */
.hero { margin: 8px 0 0; border-radius: var(--r); padding: 18px; background: linear-gradient(135deg, #ff9a7a, var(--accent) 55%, #e8577b); color: #fff; box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 35%, transparent); }
.streak { display: flex; align-items: baseline; gap: 8px; }
.streak .fire { font-size: 34px; align-self: center; }
.streak b { font-size: 48px; line-height: 1; letter-spacing: -1px; }
.streak span:last-child { font-weight: 700; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .h { text-align: center; font-size: 12px; color: var(--sub); padding: 2px 0; font-weight: 700; }
.cal .h.sun { color: var(--red); } .cal .h.sat { color: #4a7fe0; }
.cal button { aspect-ratio: 1 / 1.08; border: 0; border-radius: 14px; background: var(--none); padding: 5px 2px 4px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 700; min-width: 0; transition: transform .08s; }
.cal button:active { transform: scale(.92); }
.cal button small { font-size: 9.5px; font-weight: 500; color: var(--sub); }
.cal button.green { background: var(--mint); color: #fff; } .cal button.green small { color: #e5fbf1; }
.cal button.yellow { background: var(--yellow); color: #fff; } .cal button.yellow small { color: #fff6dc; }
.cal button.red { background: var(--red); color: #fff; } .cal button.red small { color: #ffe6e3; }
.cal button.future { opacity: .35; }
.cal button.today { box-shadow: 0 0 0 2.5px var(--card), 0 0 0 4.5px var(--ink); }
.cal .blank { visibility: hidden; }
.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--sub); margin-top: 12px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.legend span.ln::before { display: none; }
.legend span.ln.red { color: var(--red); }
.phasecard p { margin: 0; }
.countdown { margin-top: 10px !important; font-weight: 700; }
.countdown b { font-size: 26px; color: var(--accent-ink); margin: 0 2px; }

/* グラフ */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.stat { background: var(--card); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); }
.stat small { display: block; font-size: 12px; color: var(--sub); font-weight: 700; }
.stat b { font-size: 26px; letter-spacing: -.5px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat b span { font-size: 12px; font-weight: 500; color: var(--sub); margin-left: 2px; letter-spacing: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--sub); font-family: inherit; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tgt { stroke: var(--ink); stroke-width: 1.5; fill: none; stroke-dasharray: 4 3; opacity: .55; }
.chart .floor { stroke: var(--red); stroke-width: 1.2; fill: none; stroke-dasharray: 2 3; opacity: .7; }
.chart .goal { stroke: var(--mint); stroke-width: 2; stroke-dasharray: 6 4; }
.chart .goal-t { fill: var(--mint); font-weight: 700; }
.chart .last-t { fill: var(--accent-ink); font-weight: 700; font-size: 12px; }
.chart .wline { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .wdot { fill: var(--card); stroke: var(--accent); stroke-width: 2.5; }
.chart .b-green { fill: var(--mint); } .chart .b-yellow { fill: var(--yellow); } .chart .b-red { fill: var(--red); } .chart .b-none { fill: var(--line); }

/* 設定 */
.food-row { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 8px; }
.food-row:first-of-type { border-top: 0; padding-top: 0; }
.slots { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; align-items: center; }
.slots label { display: inline-flex; align-items: center; gap: 4px; }
.slots input { width: 18px; height: 18px; }
.phase { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 4px; }
.phase:first-of-type { border-top: 0; padding-top: 0; }
.kv { display: grid; grid-template-columns: 1fr 104px; gap: 8px 12px; align-items: center; font-size: 14px; }
.savebar { position: sticky; bottom: calc(92px + env(safe-area-inset-bottom)); display: flex; gap: 8px; margin: 16px 0; z-index: 5; }
.savebar .btn.pri { flex: 1; }

/* トースト・写真拡大 */
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); background: var(--ink); color: var(--bg); padding: 9px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: .95; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; background: rgba(20, 14, 10, .94); z-index: 40; display: flex; align-items: center; justify-content: center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.modal img { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal button { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .18); color: #fff; font-size: 18px; }

/* ログイン */
.login { max-width: 360px; margin: 16vh auto 0; padding: 0 16px; text-align: center; }
.login .logo { width: 96px; height: 96px; margin: 0 auto; border-radius: 28px; background: linear-gradient(135deg, #ffb199, var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 52px; box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 35%, transparent); }
.login h1 { font-size: 24px; margin: 18px 0 4px; }
.login form { display: grid; gap: 10px; margin-top: 20px; }
.login input { text-align: center; font-size: 18px; }
.err { color: var(--red); font-size: 14px; font-weight: 700; }
.chart .plan { stroke: var(--sub); stroke-width: 1.5; fill: none; stroke-dasharray: 3 4; opacity: .6; }
