:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --text: #1f2a24;
  --muted: #6b7a71;
  --border: #dde5df;
  --primary: #2e9e6b;
  --primary-ink: #ffffff;
  --accent: #f08a24;
  --danger: #d9463b;
  --good: #2e9e6b;
  --warn: #e0a100;
  --bad: #d9463b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 40, 30, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1b221e;
    --surface-2: #232c27;
    --text: #e6ede8;
    --muted: #93a39a;
    --border: #2e3a33;
    --primary: #3bb57e;
    --accent: #f59e45;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

/* iOS 対策:
   - text-size-adjust: Safari が勝手に文字を拡大して横にはみ出すのを防ぐ
   - touch-action: manipulation: ダブルタップでの拡大を無効化（ピンチ操作での拡大は残す）
   - overscroll-behavior: 端で引っぱったときの跳ね返りを止める。
     iOS はこの跳ね返り中、position: fixed のタブバーを画面の下端に保てない
   はみ出し対策の overflow-x: clip は main だけに付ける。html や body に付けると、
   iOS Safari ではタブバーなどの position: fixed が画面ではなくページに貼り付き、
   スクロールすると一緒に動いてしまう */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  max-width: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}
img, svg, canvas { max-width: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS は文字が16px未満の入力欄をタップすると画面を自動で拡大し、そのまま戻らない。
   16px にしておくと拡大されず、左右のずれも起きない */
input, select, textarea { font-size: 16px; }
a { color: var(--primary); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; }
.badge { font-size: 12px; background: var(--warn); color: #000; padding: 2px 8px; border-radius: 99px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* お知らせの鈴。未読があるときだけ赤い点が光る */
.bell { position: relative; display: inline-flex; padding: 4px; text-decoration: none; line-height: 1; }
.bell .ico { font-size: 20px; filter: grayscale(1); opacity: .7; }
.bell .dot {
  position: absolute; top: 2px; right: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--bad); border: 2px solid var(--surface);
  animation: blink 1.2s ease-in-out infinite;
}
.bell:has(.dot:not([hidden])) .ico { filter: none; opacity: 1; }
@keyframes blink { 50% { opacity: .25; } }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; overflow-x: clip; }
@supports not (overflow-x: clip) {
  main { overflow-x: hidden; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ボタン・フォーム */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 20px; width: 44px; height: 44px; cursor: pointer; border-radius: 50%; }
.icon-btn:hover { background: var(--surface-2); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; text-align: center; position: relative; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 10px; cursor: pointer; }
.seg input:checked + span { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.error { color: var(--danger); font-size: 14px; min-height: 1.4em; margin: 4px 0 8px; }

/* 認証画面 */
.auth-hero { text-align: center; padding: 24px 0 8px; }
.auth-hero img { width: 72px; height: 72px; }
.auth-hero p { margin: 6px 0 0; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { flex: 1; white-space: nowrap; border: 0; background: transparent; padding: 10px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* 日付ナビ */
.datenav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.datenav .date { font-weight: 700; font-size: 17px; border: 0; background: none; cursor: pointer; }
.datenav .date small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); text-align: center; }

/* スコア */
.score-card { display: flex; gap: 16px; align-items: center; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .val { transition: stroke-dashoffset .6s ease; }
.ring .label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .label b { font-size: 30px; line-height: 1; }
.ring .label small { font-size: 11px; color: var(--muted); }
.kcal-big { font-size: 26px; font-weight: 700; line-height: 1.2; }
.kcal-big small { font-size: 14px; font-weight: 400; color: var(--muted); }

/* 栄養バー（目標=バーの2/3の位置） */
.nbar { margin: 10px 0; }
.nbar .top { display: flex; justify-content: space-between; font-size: 13px; }
.nbar .track { position: relative; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.nbar .fill { height: 100%; border-radius: 99px; background: var(--good); transition: width .5s ease; }
.nbar .fill.low { background: var(--warn); }
.nbar .fill.high { background: var(--bad); }
.nbar .goal { position: absolute; top: -2px; bottom: -2px; left: 66.66%; width: 2px; background: var(--text); opacity: .5; }

.advice { margin: 0; padding: 0; list-style: none; }
.advice li { position: relative; padding: 8px 0 8px 28px; border-top: 1px dashed var(--border); }
.advice li:first-child { border-top: 0; }
.advice li::before { content: "💡"; position: absolute; left: 0; top: 8px; }

/* 食事リスト */
.meal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meal-head h3 { margin: 0; min-width: 0; }
.meal-head .row { flex: none; }
.meal-items { list-style: none; margin: 8px 0 0; padding: 0; }
.meal-items li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.meal-items .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.meal-items .name small { display: block; color: var(--muted); font-size: 12px; }
.item-edit {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  border: 0; background: none; padding: 6px 0; text-align: left; cursor: pointer; border-radius: 8px;
}
.item-edit:hover { background: var(--surface-2); }
.item-edit .edit-mark { font-size: 12px; opacity: .45; }
.edit-name { font-size: 17px; font-weight: 700; margin: 0 0 2px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0 0; }

/* 過去の食事をコピー */
.copy-list { list-style: none; margin: 0 0 12px; padding: 0; }
.copy-list button {
  display: flex; width: 100%; gap: 8px; align-items: center; text-align: left;
  border: 0; border-top: 1px solid var(--border); background: none; padding: 12px 4px; cursor: pointer;
}
.copy-list button:hover { background: var(--surface-2); }
.copy-list small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.copy-list .kcal { color: var(--accent); font-weight: 700; white-space: nowrap; }

/* 食品検索 */
.search { position: sticky; top: 0; background: var(--surface); padding-bottom: 8px; }
.food-list { list-style: none; margin: 0; padding: 0; }
.food-list button {
  display: flex; width: 100%; gap: 8px; align-items: center; text-align: left;
  border: 0; border-top: 1px solid var(--border); background: none; padding: 12px 4px; cursor: pointer;
}
.food-list button:hover { background: var(--surface-2); }
.food-list .kcal { color: var(--accent); font-weight: 700; white-space: nowrap; }
.tag { font-size: 11px; background: var(--surface-2); color: var(--muted); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.qty { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.qty button { min-width: 56px; }
.qty button.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.nut-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
.nut-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.nut-table td:last-child { text-align: right; }
.nut-table.detail th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 4px 0; border-bottom: 1px solid var(--border); }
.nut-table.detail th.num, .nut-table.detail td.num { text-align: right; }
.nut-table.detail td { padding: 7px 0; }
.nut-table .good { color: var(--good); }
.nut-table .under { color: var(--warn); }
.nut-table .over { color: var(--bad); }
.detail-h { margin: 18px 0 6px; font-size: 14px; }
.pfc-bar { display: flex; height: 28px; border-radius: 8px; overflow: hidden; background: var(--surface-2); font-size: 12px; font-weight: 600; color: #fff; }
.pfc-bar span { display: grid; place-items: center; min-width: 0; overflow: hidden; white-space: nowrap; }
.pfc-bar .p { background: #3b82c4; }
.pfc-bar .f { background: var(--accent); }
.pfc-bar .c { background: var(--primary); }

/* 写真AI解析 */
.photo-cta {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 12px;
  padding: 14px 16px; border: 0; border-radius: var(--radius); cursor: pointer; text-align: left;
  background: linear-gradient(135deg, var(--primary), #1f7f55); color: #fff; box-shadow: var(--shadow);
}
.photo-cta .ico { font-size: 28px; }
.photo-cta b { display: block; font-size: 16px; }
.photo-cta small { opacity: .9; font-size: 12px; }
.photo-drop {
  position: relative; aspect-ratio: 4 / 3; border: 2px dashed var(--border); border-radius: var(--radius);
  display: grid; place-items: center; overflow: hidden; background: var(--surface-2);
}
.photo-drop.has { border-style: solid; }
.photo-drop img { width: 100%; height: 100%; object-fit: cover; }
.photo-drop .ph { text-align: center; color: var(--muted); font-size: 14px; line-height: 2; }
.photo-drop .ph::first-line { font-size: 40px; }
.photo-drop .scan {
  position: absolute; left: 0; right: 0; height: 30%; top: -30%;
  background: linear-gradient(to bottom, transparent, rgba(59, 181, 126, .45), transparent);
  animation: scan 1.8s ease-in-out infinite;
}
@keyframes scan { to { top: 100%; } }
.ai-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.ai-head img { width: 88px; height: 88px; object-fit: cover; border-radius: 12px; flex: none; }
.ai-thumb { flex: none; width: 88px; height: 88px; border-radius: 12px; overflow: hidden; }
.ai-thumb.multi { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.ai-thumb.multi img, .ai-thumb.multi .ph { width: 100%; height: 100%; border-radius: 0; }
.ai-thumb .ph { display: grid; place-items: center; background: var(--surface-2); font-size: 22px; height: 100%; }
.photo-grid { display: grid; width: 100%; height: 100%; gap: 2px; }
.photo-grid.n2 { grid-template-columns: 1fr 1fr; }
.photo-grid.n3, .photo-grid.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.photo-grid.n3 > :first-child { grid-row: span 2; }
.photo-grid > * { width: 100%; height: 100%; object-fit: cover; min-height: 0; }
.photo-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.photo-list li { display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 99px; padding: 2px 4px 2px 10px; }
.photo-list .icon-btn { width: 28px; height: 28px; font-size: 14px; }
.btn.disabled { opacity: .5; pointer-events: none; }
.ai-thumb-ph { width: 88px; height: 88px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 32px; background: var(--surface-2); }
.photo-drop .ph small { font-size: 12px; }
.ai-comment { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 0 0 8px; }
.ai-items { list-style: none; margin: 0 0 12px; padding: 0; }
.ai-items li { border-top: 1px solid var(--border); padding: 10px 0; }
.ai-items li.off { opacity: .45; }
.ai-items input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.ai-name { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; background: transparent; font-weight: 600; }
.ai-name:not([readonly]):hover, .ai-name:focus { border-color: var(--border); background: var(--surface); }
.conf { font-size: 11px; border-radius: 6px; padding: 1px 6px; white-space: nowrap; color: #fff; }
.conf.good { background: var(--good); }
.conf.warn { background: var(--warn); color: #000; }
.conf.bad { background: var(--bad); }
.scale { flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.scale .btn { min-height: 30px; padding: 0 8px; font-size: 12px; }
.scale .btn.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.note { margin: 6px 0 0; }

.key-note { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.key-note.ok { display: block; background: none; color: var(--muted); font-size: 12px; padding: 0 0 8px; margin: 0; }
.key-note.warn { display: block; background: none; border: 2px solid var(--accent); }
.key-note.warn p { margin: 4px 0 8px; }
.key-note b { white-space: nowrap; }
.key-note.warn b { white-space: normal; }
.nutrient-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.nutrient-picker label {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 99px; padding: 6px 12px; font-size: 14px;
}
.nutrient-picker label.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.nutrient-picker input { position: absolute; opacity: 0; width: 0; height: 0; }
.nutrient-picker label:focus-within { outline: 2px solid var(--primary); outline-offset: 1px; }
.consent { margin-bottom: 12px; }
.consent input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.activity-note { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); color: var(--muted); }
.activity-note b.up { color: var(--good); }
.activity-note b.down { color: var(--warn); }
.aikey-ok { margin: 0 0 4px; font-weight: 600; color: var(--good); }
.api-help ol { margin: 4px 0; padding-left: 1.3em; }
.terms h3 { margin: 18px 0 6px; font-size: 15px; }
.terms p, .terms li { font-size: 14px; }
.terms .draft { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 8px 12px; border-radius: 8px; }

/* 使い方ガイド */
.guide-index { list-style: none; margin: 0; padding: 0; }
.guide-index li + li { border-top: 1px solid var(--border); }
.guide-index a { display: block; padding: 12px 4px; text-decoration: none; color: var(--text); }
.guide-index a:hover { background: var(--surface-2); }
.guide-index small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.guide p { line-height: 1.7; }
.guide-h { margin: 22px 0 8px; font-size: 16px; padding-bottom: 6px; border-bottom: 2px solid var(--primary); }
.guide-steps { list-style: none; counter-reset: step; margin: 8px 0 0; padding: 0; }
.guide-steps > li { position: relative; padding: 0 0 18px 34px; }
.guide-steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.guide-steps h4 { margin: 2px 0 4px; font-size: 15px; }
.guide-steps p { margin: 0 0 8px; font-size: 14px; }
.guide-steps code, .guide code { background: var(--surface-2); border-radius: 5px; padding: 1px 5px; font-size: 13px; overflow-wrap: anywhere; }
.guide-img { margin: 8px 0 0; }
.guide-img img { width: 100%; border: 1px solid var(--border); border-radius: 10px; display: block; cursor: zoom-in; }
/* タップすると画面いっぱいに拡大して細部を確認できる */
.guide-img img.zoom {
  position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%;
  object-fit: contain; background: rgba(0, 0, 0, .92); border-radius: 0; cursor: zoom-out; padding: 8px;
}
.guide-img figcaption { display: none; }
.guide-img.missing {
  border: 2px dashed var(--border); border-radius: 10px; padding: 14px; text-align: center;
}
.guide-img.missing figcaption { display: block; color: var(--muted); font-size: 12px; }
.guide-notes { margin: 8px 0 0; padding-left: 1.1em; }
.guide-notes li { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.install-banner { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.install-banner.done { border-left: 4px solid var(--good); }
.install-banner p { margin: 0 0 8px; }

/* ログイン画面のアプリ紹介 */
.intro h2 { margin-top: 0; }
.intro-steps { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: none; }
.intro-steps li { margin-bottom: 20px; }
.intro-steps li + li { border-top: 1px solid var(--border); padding-top: 16px; }
.intro-steps h3 { margin: 0 0 4px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.intro-steps h3 .n {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.intro-steps p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
/* スクリーンショットは実寸より大きくしない */
.intro-steps .guide-img img { max-width: 320px; margin: 10px auto 0; }

/* お知らせ */
.news-item.is-new { border-left: 4px solid var(--primary); }
.news-item h3 { margin: 0 0 2px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.news-item .date { margin: 0 0 10px; }
/* 本文の改行をそのまま見せる（投稿欄で打った形のまま表示される） */
.news-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; }
.news-admin { margin: 12px 0 0; gap: 8px; }
.news-item .badge-new { margin-left: 0; }

/* ユーザー一覧（管理者のみ） */
.user-list { list-style: none; margin: 0 0 12px; padding: 0; }
.user-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.user-list li:last-child { border-bottom: 0; }
.user-list .grow { flex: 1; min-width: 0; }
.user-list b { display: block; overflow-wrap: anywhere; }
.user-list small { display: block; color: var(--muted); font-size: 12px; }
.user-list .last { flex: none; text-align: right; font-variant-numeric: tabular-nums; }

/* AI解析の失敗ログ（管理者のみ） */
.tag {
  flex: none; display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.ai-kinds { list-style: none; margin: 0; padding: 0; }
.ai-kinds li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-kinds small { flex-basis: 100%; color: var(--muted); font-size: 12px; }
.ai-log { list-style: none; margin: 0; padding: 0; }
.ai-log > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.ai-log > li:last-child { border-bottom: 0; }
.ai-log .row { display: flex; align-items: center; gap: 8px; }
.ai-log .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tries { margin: 6px 0 0; padding-left: 1.3em; }
.tries li { font-size: 13px; margin-bottom: 2px; }
.tries small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

/* 不具合報告・要望 */
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-list li { margin-bottom: 8px; }
.thread-list a {
  display: flex; gap: 8px; align-items: center; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.thread-list a.closed { opacity: .6; }
.thread-list small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.badge-new { background: var(--accent); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; margin-left: 6px; }
.chat { list-style: none; margin: 0 0 12px; padding: 0; }
.chat li { margin-bottom: 10px; max-width: 85%; }
.chat .bubble { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.chat small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat .from-user { margin-left: auto; }
.chat .from-user .bubble { background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 4px; }
.chat .from-user small { text-align: right; }
.chat .from-admin .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

/* 外部連携トークン */
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 12px;
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px;
}
.token-new { border: 2px solid var(--accent); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.token-list { list-style: none; margin: 8px 0 12px; padding: 0; }
.token-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.token-list small { display: block; color: var(--muted); font-size: 12px; }
.api-help { margin-bottom: 8px; }
.hlog-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.hlog-list li { display: flex; gap: 6px; padding: 6px 0; border-top: 1px solid var(--border); }
.hlog-list small { display: block; color: var(--muted); font-size: 11px; }
.hlog-list .grow { overflow-wrap: anywhere; }
.hlog-list li.ng { color: var(--danger); }
.api-help summary { cursor: pointer; color: var(--primary); }
.api-help pre { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; overflow-x: auto; margin: 4px 0; }

/* 体重グラフ */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.5; }
.chart .dot { fill: var(--primary); }
.chart .target { stroke: var(--accent); stroke-dasharray: 5 4; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 12px; color: var(--muted); }

/* タブバー */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar .ico { font-size: 20px; line-height: 1.3; filter: grayscale(1); opacity: .6; }
.tabbar a.active { color: var(--primary); }
.tabbar a.active .ico { filter: none; opacity: 1; }

/* ボトムシート */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 16px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { overflow-y: auto; min-height: 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; z-index: 30;
  font-size: 14px; max-width: calc(100% - 32px);
}
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
