:root {
    /* 面 */
    --bg: #f4f2ee;
    --card-bg: #ffffff;
    --sunken: #f7f5f1;
    /* 文字 */
    --text: #2c2a26;
    --text-sub: #55514b;
    /* --muted は小さいラベルに広く使うため、白・sunken・tintのいずれの背景でも
       コントラスト比4.5:1（WCAG AA）を満たす明度にしている。
       以前の #9a958c は白背景で2.98:1しかなく、小さい文字が読みにくかった。 */
    --muted: #6f6a61;
    /* アクセント（深めのグリーン。数値と主要導線に使う） */
    --accent: #4a7c59;
    --accent-strong: #3d6849;
    --accent-soft: #e8f0e9;
    --accent-tint: #f2f7f3;
    /* 補助 */
    --border: #ebe7e0;
    --border-strong: #ddd8cf;
    --cheat: #e8dcc4;
    --cheat-soft: #faf4e8;
    /* 形 */
    --radius: 18px;
    --radius-sm: 12px;
    --tap: 48px;
    --shadow: 0 1px 2px rgba(44,42,38,.05), 0 4px 14px rgba(44,42,38,.05);
    --shadow-sm: 0 1px 3px rgba(44,42,38,.06);
  }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  /* display を明示しているクラス（.summary-line など）に hidden 属性を付けても
     消えない事故を防ぐ。UAの [hidden]{display:none} はクラス指定に負けるため。 */
  [hidden] { display: none !important; }

  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  #app { max-width: 480px; margin: 0 auto; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* ---------- ヘッダー ---------- */
  /* standalone（ホーム画面から全画面で開いた状態）ではステータスバーが
     コンテンツに重なるため、上部にセーフエリア分の余白を足す。
     status-bar-style を black-translucent にしているのが理由。 */
  /* 画面のいちばん上は相棒がいる景色。ここが毎日開く動機になるので、
     ホームでは大きく、記録画面では細い帯にして入力欄を押し下げないようにする。 */
  .app-header { position: relative; background: var(--sunken); }
  /* 設定ボタン。ステータスバーに重なる指定をしているので、その分だけ下げる。 */
  .icon-btn {
    color: var(--text-sub);
    border: 1px solid var(--border);
    border-radius: 50%; width: 44px; height: 44px; padding: 0;
    font-size: 17px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
  }
  .app-header .icon-btn {
    position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 5;
    background: rgba(255,255,255,.9);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    box-shadow: var(--shadow-sm);
  }

  .scene { position: relative; overflow: hidden; background: var(--sunken); }
  /* aspect-ratio非対応でも潰れないよう min-height を保険に置く */
  .scene.full { aspect-ratio: 360 / 214; min-height: 196px; }
  .scene.slim {
    height: calc(78px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0 66px;
    display: flex; align-items: center;
  }

  .scene-svg, .scene-bg-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
  .scene-bg-img { object-fit: cover; }
  .scene-veil { position: absolute; inset: 0; background: rgba(255,255,255,.80); }

  .scene-chara-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
  .scene-chara-svg.slim { inset: auto auto 0 6px; width: 52px; height: 74px; }
  .scene-chara-img {
    position: absolute; right: 18%; bottom: 19%;
    height: 58%; width: auto; max-width: 44%; object-fit: contain; object-position: bottom;
  }
  .scene.slim .scene-chara-img {
    left: 6px; right: auto; bottom: 1px; height: 74px; max-width: 56px;
  }

  /* 待機中のわずかな上下。動きがあるだけで「生きている」感じが出る。 */
  @keyframes scene-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
  .scene.full .scene-chara-svg, .scene.full .scene-chara-img { animation: scene-bob 3.6s ease-in-out infinite; }
  /* ロボットに助言を頼んでいる間、相棒が下をのぞき込む */
  .scene.peeking .scene-chara-svg, .scene.peeking .scene-chara-img {
    animation: none; transform: translateY(6px) rotate(5deg); transform-origin: 66% 82%;
    transition: transform .35s cubic-bezier(.34,1.3,.64,1);
  }
  @media (prefers-reduced-motion: reduce) {
    .scene.full .scene-chara-svg, .scene.full .scene-chara-img { animation: none; }
  }

  /* 情報はすべて左の縦一列に置き、右側は相棒と地面のために空ける */
  .scene-left {
    position: absolute; left: 12px; top: calc(10px + env(safe-area-inset-top)); z-index: 3;
    width: 58%; max-width: 212px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  }
  .scene-top {
    display: inline-flex; align-items: baseline; gap: 7px;
    background: rgba(30,36,46,.80); color: #fff;
    padding: 5px 12px; border-radius: 999px;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  }
  .stage-no { font-size: 9.5px; font-weight: 800; letter-spacing: .09em; }
  .stage-name { font-size: 13px; font-weight: 700; }

  .scene-bubble {
    position: relative; align-self: stretch;
    background: rgba(255,255,255,.96); border-radius: 14px; padding: 8px 12px;
    font-size: 12px; line-height: 1.55; font-weight: 600; color: var(--text-sub);
    box-shadow: var(--shadow-sm);
  }
  /* 3行までにとどめる。AIの要約をそのまま流すと吹き出しが景色の半分を占めてしまう。 */
  .scene-bubble {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  /* しっぽは右向き。相棒は右に立っているので、そちらを指す。 */
  .scene-bubble::after {
    content: ''; position: absolute; right: -6px; top: 16px;
    border-style: solid; border-width: 6px 0 6px 7px;
    border-color: transparent transparent transparent rgba(255,255,255,.96);
  }

  /* Lv・EXPは画面下の帯にまとめる。景色の上に大きなパネルを置くと、
     そのステージらしい景色がぜんぶ裏に隠れてしまうため。
     白96%にしているのは、景色が暗いステージ（星降る峠・空の果て）でも
     小さい文字のコントラストが4.5:1を下回らない濃さにするため。 */
  .scene-bar {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
    padding: 7px 14px 8px;
    background: rgba(255,255,255,.96);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border-top: 1px solid rgba(44,42,38,.07);
  }
  .hud-row { display: flex; align-items: center; gap: 8px; }
  .hud-sub { margin-top: 4px; }
  .hud-lv { font-size: 13px; font-weight: 800; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
  .hud-bar { flex: 1; height: 8px; border-radius: 5px; background: rgba(44,42,38,.15); overflow: hidden; }
  .hud-bar.thin { height: 5px; }
  .hud-bar i { display: block; height: 100%; border-radius: 5px; background: var(--accent); transition: width .4s ease; }
  .hud-bar i.alt { background: #9a6c2c; }
  .hud-num, .hud-next { font-size: 10.5px; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }

  /* 細い帯（記録画面）。相棒とひとことだけ残す。 */
  .scene-slim-text { position: relative; flex: 1; min-width: 0; z-index: 2; }
  .slim-stage { display: block; font-size: 10px; font-weight: 800; color: var(--text-sub); letter-spacing: .02em; }
  .slim-line {
    display: block; font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.4;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .scene-lv {
    position: relative; z-index: 2; flex: none; margin-left: 10px;
    font-size: 12px; font-weight: 800; color: var(--accent-strong);
    background: rgba(255,255,255,.92); border-radius: 999px; padding: 4px 10px;
  }

  .reminder-banner {
    margin: 0 16px 10px;
    padding: 12px 14px;
    background: var(--accent-tint);
    border: 1px solid var(--accent-soft);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.6;
  }

  main { padding: 0 16px; }
  .view { display: none; }
  .view.active { display: block; }
  #input-common[hidden] { display: none; }

  /* ---------- カード ---------- */
  .card {
    background: var(--card-bg);
    border: 1px solid rgba(44,42,38,.05);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
  }
  .card h2 {
    font-size: 13px; margin: 0 0 14px;
    color: var(--text); font-weight: 700;
    letter-spacing: .02em;
  }

  /* ---------- 汎用 ---------- */
  .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .row:last-child { margin-bottom: 0; }
  .unit { font-size: 12px; color: var(--muted); }
  small.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 6px; line-height: 1.6; }

  input[type="number"], input[type="text"], input[type="date"], textarea, select {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    height: var(--tap);
    font-size: 16px; /* iOSで入力時に自動ズームしない最小サイズ */
    background: var(--card-bg);
    color: var(--text);
    width: 100px;
    font-variant-numeric: tabular-nums;
  }
  input[type="date"] { width: 100%; flex: 1; min-width: 140px; }
  input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent);
  }

  button {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 0 18px;
    min-height: var(--tap);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    transition: transform .06s ease, background .12s ease, opacity .12s ease;
  }
  button:active { transform: scale(0.97); }
  /* 独自の見た目を持つボタン（ホームのカードなど）まで緑に塗られないよう、押下色は明示的に当てる */
  button:not(.secondary):not(.tiny):not(.ghost):not(.step):not(.tab-btn):not(.range-btn):not(.time-btn):not(.entry-del):not(.entry-slot):not(.preset-btn):not(.cal-nav):not(.nudge):not(.qcard):not(.art-head):not(.fab-add):not(.add-tab):not(.sheet-close):not(.art-thumb-del):not(.art-thumb-add):active {
    background: var(--accent-strong);
  }
  button:not(.secondary):not(.tiny):not(.ghost):not(.step):not(.tab-btn):not(.range-btn):not(.time-btn):not(.entry-del):not(.entry-slot):not(.preset-btn):not(.cal-nav):not(.nudge):not(.qcard):not(.art-head):not(.fab-add):not(.add-tab):not(.sheet-close):not(.art-thumb-del):not(.art-thumb-add) {
    box-shadow: 0 1px 2px rgba(61,104,73,0.18);
  }
  button:disabled { opacity: .5; }
  button.secondary {
    background: var(--card-bg); color: var(--text-sub);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-sm);
  }
  button.secondary:active { background: var(--sunken); }
  button.ghost {
    background: none; color: var(--muted);
    border: none; min-height: 36px; padding: 0 8px; font-size: 13px; font-weight: 500;
  }
  button.tiny {
    min-height: 44px; padding: 0 10px; font-size: 12px; font-weight: 500;
    background: none; color: var(--muted); border: none;
  }
  button.block { width: 100%; }
  /* ステッパーの ±（正方形で押しやすく） */
  button.step {
    background: var(--sunken); color: var(--text-sub);
    border: 1px solid var(--border);
    width: var(--tap); min-width: var(--tap); padding: 0;
    font-size: 18px; font-weight: 500;
  }

  /* ---------- 数値の主役表示 ---------- */
  .fact {
    font-size: 13px; color: var(--text-sub); line-height: 1.6;
    background: var(--sunken); border-radius: var(--radius-sm);
    padding: 10px 12px; margin-top: 12px;
  }
  .fact b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

  /* 参照画面のグループ見出し。似た見た目のカードが続くと構造が掴めないため */
  .group-heading {
    font-size: 12px; font-weight: 700; color: var(--muted);
    letter-spacing: .08em; margin: 20px 4px 8px;
  }
  .group-heading:first-child { margin-top: 4px; }

  /* 食事の区分ボタン（現在時刻から自動選択される） */
  .slot-seg {
    display: flex; gap: 4px; margin-bottom: 14px;
    background: var(--sunken); border-radius: 14px; padding: 4px;
  }
  .slot-btn {
    flex: 1; min-height: 52px; padding: 0;
    background: none; border: none; color: var(--text-sub);
    border-radius: 10px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    transition: background .14s ease, color .14s ease;
  }
  .slot-name { font-size: 13px; font-weight: 700; line-height: 1.2; }
  .slot-sub {
    font-size: 10px; font-weight: 600; line-height: 1.2;
    color: var(--muted); font-variant-numeric: tabular-nums;
  }
  /* 記録済みは色を乗せて、ひと目で分かるようにする */
  .slot-btn.done { color: var(--accent-strong); }
  .slot-btn.done .slot-sub { color: var(--accent-strong); }
  .slot-btn.done:not(.active) { background: var(--accent-tint); }
  .slot-btn.active {
    background: var(--accent); color: #fff;
    box-shadow: 0 2px 6px rgba(61,104,73,.25);
  }
  .slot-btn.active .slot-sub { color: #fff; }

  /* ロボットの発言（相棒とは別人格であることが見て分かるように顔を付ける） */
  .robot-say { display: flex; gap: 9px; align-items: flex-start; }
  .robot-face {
    font-size: 19px; line-height: 1.2; flex: none;
    filter: grayscale(.25);
  }

  /* ---------- 相棒と道場 ---------- */
  #character-card {
    background: linear-gradient(170deg, var(--accent-tint) 0%, var(--card-bg) 62%);
    padding: 14px 16px 16px;
  }
  .dojo { display: flex; align-items: flex-end; gap: 10px; }
  .dojo-scene {
    position: relative; width: 132px; height: 118px; flex: none;
  }
  /* 差し替え用の画像。登録されていればSVGの上に重ねる */
  .dojo-photo {
    position: absolute; inset: 0; margin: auto;
    max-width: 100%; max-height: 100%; object-fit: contain;
  }
  .bubble {
    flex: 1; min-width: 0; position: relative;
    background: var(--card-bg); border: 1px solid var(--border-strong);
    border-radius: 14px; padding: 11px 13px; margin-bottom: 14px;
    font-size: 12.5px; line-height: 1.7; color: var(--text-sub);
    box-shadow: var(--shadow-sm);
  }
  /* 吹き出しのしっぽ */
  .bubble::before, .bubble::after {
    content: ''; position: absolute; left: -8px; bottom: 14px;
    border-style: solid;
  }
  .bubble::before {
    border-width: 7px 8px 7px 0; border-color: transparent var(--border-strong) transparent transparent;
  }
  .bubble::after {
    left: -6.5px;
    border-width: 6px 7px 6px 0; border-color: transparent var(--card-bg) transparent transparent;
  }

  .dojo-status { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
  .chara-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
  .chara-sub { font-size: 11px; color: var(--muted); font-weight: 600; }
  .chara-sub b { color: var(--accent-strong); font-size: 14px; font-variant-numeric: tabular-nums; }
  .chara-bar {
    height: 8px; border-radius: 999px; background: var(--card-bg);
    border: 1px solid var(--border); overflow: hidden; margin: 8px 0 5px;
  }
  .chara-bar-in { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
  .chara-next { font-size: 11px; color: var(--muted); font-weight: 600; line-height: 1.7; }
  .chara-next b { color: var(--accent-strong); font-variant-numeric: tabular-nums; }

  /* 設定：相棒の絵の差し替え */
  .chara-imgs { margin-top: 10px; }
  .chara-img-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid var(--border);
  }
  .chara-img-row:last-child { border-bottom: none; }
  .chara-img-name { font-size: 13px; font-weight: 700; width: 52px; flex: none; }
  .chara-thumb {
    width: 40px; height: 40px; border-radius: 9px; object-fit: cover;
    background: var(--sunken); border: 1px solid var(--border); flex: none;
  }
  .chara-thumb.empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 12px;
  }
  .chara-pick {
    min-height: 38px; padding: 0 12px; display: inline-flex; align-items: center;
    background: var(--card-bg); color: var(--text-sub);
    border: 1px solid var(--border-strong); border-radius: 9px;
    font-size: 12px; font-weight: 600; margin-left: auto;
  }

  /* ---------- 参照画面：主役の数値と補足 ---------- */
  .hero { display: flex; flex-direction: column; align-items: flex-start; }
  .hero-main { display: flex; align-items: baseline; gap: 6px; }
  .hero-value {
    font-size: 46px; font-weight: 700; line-height: 1;
    color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.03em;
  }
  /* 主役が2つ並ぶと視線が割れるので、カロリー側は一段小さくする */
  #budget-card .hero-value { font-size: 34px; }
  #budget-card .hero-unit { font-size: 13px; }
  .hero-unit { font-size: 16px; font-weight: 700; color: var(--muted); }
  .hero-sub { font-size: 11px; color: var(--muted); margin-top: 5px; font-weight: 600; }

  .hero-fact {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--accent-tint); border: 1px solid var(--accent-soft);
    border-radius: var(--radius-sm); padding: 11px 13px; margin-top: 14px;
  }
  .hf-label { font-size: 12px; color: var(--text-sub); font-weight: 600; }
  .hf-value {
    font-size: 20px; font-weight: 700; color: var(--accent-strong);
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .hf-value i { font-size: 11px; font-style: normal; color: var(--text-sub); margin-left: 3px; font-weight: 600; }

  .track { margin-top: 16px; }
  .track-ends {
    display: flex; justify-content: space-between;
    font-size: 10px; color: var(--muted); font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .meta-row {
    display: flex; gap: 8px; margin-top: 14px;
    padding-top: 14px; border-top: 1px solid var(--border);
  }
  .meta { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .meta-label { font-size: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; }
  .meta-value {
    font-size: 15px; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }

  /* 立て直しの見通し。数字を突きつけるだけで終わらせないための一言 */
  .recovery {
    margin-top: 10px; padding: 11px 13px;
    background: var(--sunken); border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 13px; line-height: 1.7; color: var(--text-sub);
  }
  .recovery b { color: var(--accent-strong); font-variant-numeric: tabular-nums; }

  /* チートデイの日は週バーでも分かるようにする */
  .week-bar-day.cheat .week-bar-track { background: var(--cheat-soft); }

  /* 補足の注記。小さいグレー行が積み重なって見えないよう、まとめて囲む */
  .notes {
    margin-top: 14px; padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .notes p {
    margin: 0 0 7px; font-size: 11px; line-height: 1.7;
    color: var(--muted); padding-left: 12px; position: relative;
  }
  .notes p:last-child { margin-bottom: 0; }
  .notes p::before {
    content: ''; position: absolute; left: 0; top: 7px;
    width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong);
  }

  /* ---------- 進捗バー ---------- */
  .progress-bar-outer {
    background: var(--sunken); border-radius: 999px; height: 10px;
    overflow: hidden; margin: 5px 0;
    border: 1px solid var(--border);
  }
  .progress-bar-inner { background: var(--accent); height: 100%; border-radius: 999px; transition: width .3s ease; }

  /* 週予算の積み上げバー（7日分） */
  .week-bar { display: flex; gap: 3px; margin: 12px 0 6px; height: 44px; align-items: flex-end; }
  .week-bar-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .week-bar-track {
    width: 100%; height: 34px; background: var(--sunken);
    border-radius: 5px; position: relative; overflow: hidden;
    display: flex; align-items: flex-end;
  }
  .week-bar-fill {
    width: 100%; background: var(--accent-soft); border-radius: 5px;
    position: relative; z-index: 1;
  }
  .week-bar-fill.over { background: var(--cheat); }
  /* 1日あたりの目安を示す点線。棒の高さが何に対して高いのかを読めるようにする */
  .track-target {
    position: absolute; left: 0; right: 0; height: 0;
    border-top: 1px dashed var(--muted); opacity: .65; z-index: 2;
  }
  .bar-legend {
    font-size: 10px; color: var(--muted); margin: 2px 0 4px;
    display: flex; align-items: center; gap: 6px;
  }
  .bar-legend span { display: inline-flex; align-items: center; gap: 5px; }
  .legend-line {
    width: 14px; height: 0; border-top: 1px dashed var(--muted);
    display: inline-block; vertical-align: middle;
  }
  .week-bar-day.today .week-bar-track { box-shadow: inset 0 0 0 1.5px var(--accent); }
  .week-bar-label { font-size: 10px; color: var(--muted); }

  /* ---------- フッタータブ ---------- */
  /* タブは「ホーム」「きろく」の2つだけ。食事・体重・運動はここに並べず、
     中央の＋（記録シート）に統合した。align-items:flex-end + ＋の負のmargin-topで、
     ＋だけがタブバーの上に浮き出て見える構図にする。 */
  .footer-tabs {
    position: fixed; left: 0; right: 0; bottom: 0;
    max-width: 480px; margin: 0 auto;
    display: flex; align-items: flex-end; gap: 4px;
    background: rgba(255,255,255,0.92);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .footer-tabs .tab-btn {
    flex: 1; min-width: 0; min-height: 54px; padding: 0 1px;
    border: none; background: none; color: var(--muted);
    font-size: 10px; font-weight: 700; white-space: nowrap;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: var(--radius-sm);
  }
  .footer-tabs .tab-btn .tab-icon {
    font-size: 17px; line-height: 1;
    filter: grayscale(1); opacity: .5;
    transition: filter .12s ease, opacity .12s ease;
  }
  /* accent(#4a7c59)ではtint背景で4.49となり基準(4.5)をわずかに下回るため、濃い方を使う */
  .footer-tabs .tab-btn.active { color: var(--accent-strong); background: var(--accent-tint); }
  .footer-tabs .tab-btn.active .tab-icon { filter: none; opacity: 1; }

  /* 記録シートを開く＋ボタン。タブバーから上へ浮き出た円形にして、
     どのタブより優先度の高い「まず押すところ」だと分かるようにする。 */
  .fab-add {
    flex: none; width: 56px; height: 56px; min-height: 56px;
    margin-top: -22px;
    border-radius: 50%; padding: 0;
    background: linear-gradient(155deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fff; font-size: 26px; font-weight: 400; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 18px rgba(61,104,73,.38), 0 2px 6px rgba(44,42,38,.14);
  }
  .fab-add:active { transform: scale(0.93); }

  /* 期間切り替え（セグメント） */
  .segment { display: inline-flex; background: var(--sunken); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
  .segment .range-btn {
    background: none; color: var(--text-sub); border: none;
    min-height: 44px; padding: 0 20px; font-size: 13px; font-weight: 600;
    border-radius: 8px;
  }
  .segment .range-btn.active { background: var(--card-bg); color: var(--accent); box-shadow: var(--shadow); }

  /* ---------- 日付バー ---------- */
  .date-bar {
    display: flex; align-items: center; gap: 6px;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px; margin-bottom: 12px;
    box-shadow: var(--shadow);
  }
  /* 表示テキストの上に透明のdate inputを重ね、タップでネイティブのカレンダーを開く */
  .date-field {
    position: relative; flex: 1; min-width: 0; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
  }
  .date-field.is-today { background: var(--accent-tint); }
  .date-field > span {
    display: inline-flex; align-items: baseline; gap: 6px;
    font-size: 16px; font-weight: 700; color: var(--text);
    pointer-events: none; white-space: nowrap;
  }
  .date-field .date-sub {
    font-size: 12px; font-weight: 600; color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .date-field input[type="date"] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; border: none; background: none; padding: 0; margin: 0;
  }
  .date-field input[type="date"]:focus { outline: none; }
  .date-field:focus-within { box-shadow: 0 0 0 2px var(--accent-soft); }
  .date-bar .nudge {
    background: var(--sunken); color: var(--text-sub); border: 1px solid var(--border);
    width: 44px; min-width: 44px; min-height: 44px; padding: 0; font-size: 16px;
  }
  #cheat-day-btn {
    min-height: 44px; width: 44px; min-width: 44px; padding: 0;
    font-size: 17px; line-height: 1;
    filter: grayscale(1) opacity(0.45);
  }
  #cheat-day-btn.done { filter: none; }
  #cheat-day-btn.done { background: var(--cheat); color: #7a6338; border-color: var(--cheat); }

  /* ---------- 食事 ---------- */
  /* プリセットのワンタップ列 */
  /* プリセットは横1行・横スクロール。件数が増えても縦に伸びない */
  .preset-row {
    display: flex; gap: 8px; margin-bottom: 10px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 4px; scroll-snap-type: x proximity;
  }
  .preset-row::-webkit-scrollbar { height: 3px; }
  .preset-row::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
  .preset-row .preset-btn { flex: 0 0 auto; scroll-snap-align: start; }
  .preset-btn {
    background: var(--card-bg); color: var(--accent-strong);
    border: 1px solid var(--accent-soft);
    min-height: 50px; padding: 6px 15px;
    border-radius: 13px; font-size: 14px; font-weight: 600;
    display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center;
    gap: 1px; text-align: left; box-shadow: var(--shadow-sm);
  }
  .preset-btn:active { background: var(--accent-soft); }
  .preset-btn .kcal {
    font-size: 11px; color: var(--muted); font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .preset-btn .kcal::after { content: ' kcal'; font-size: 9px; font-weight: 500; }

  /* 記録済みエントリ */
  .entry {
    display: flex; align-items: center; gap: 10px;
    background: var(--card-bg); border: 1px solid rgba(44,42,38,.05);
    border-radius: 13px; box-shadow: var(--shadow-sm);
    padding: 7px 7px 7px 9px; margin-bottom: 6px; font-size: 14px;
  }
  .entry-name {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-weight: 500;
  }
  .entry-kcal {
    font-size: 13px; color: var(--text); font-weight: 700;
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .entry-kcal::after { content: ' kcal'; font-size: 10px; color: var(--muted); font-weight: 500; }
  .entry-del {
    background: none; border: none; color: var(--muted);
    min-height: 44px; width: 44px; min-width: 44px; padding: 0; font-size: 15px;
  }

  /* 記録済み行の時刻ボタン・編集パネル */
  /* 記録行の区分チップ（タップで区分を変更できる） */
  .entry-slot {
    background: var(--accent-tint); color: var(--accent-strong);
    border: 1px solid var(--accent-soft);
    min-height: 34px; min-width: 44px; padding: 0 9px;
    font-size: 12px; font-weight: 700;
    border-radius: 7px; white-space: nowrap;
  }
  .entry-edit {
    background: var(--accent-tint); border: 1px solid var(--accent-soft);
    border-radius: var(--radius-sm); padding: 12px; margin: -2px 0 8px;
  }
  .entry-edit select {
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 0 10px; height: var(--tap); font-size: 16px;
    background: var(--card-bg); color: var(--text);
  }
  /* カード見出しの右に出す件数・合計 */
  .card-summary {
    font-size: 11px; color: var(--muted); font-weight: 600;
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .card-summary b {
    color: var(--accent); font-size: 17px; font-weight: 700;
    letter-spacing: -.01em; margin: 0 1px;
  }
  .card-summary:empty { display: none; }

  /* 入力エリアの下に置く「この日の記録」 */
  .record-list { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
  .meal-input {
    background: var(--sunken); border-radius: 16px;
    padding: 16px 14px; margin-top: 2px;
  }
  .meal-input input[type="time"],
  .meal-input input[type="text"],
  .meal-input input[type="number"] { background: var(--card-bg); }
  .input-methods {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--border-strong);
  }
  .method-label {
    font-size: 11px; color: var(--muted); font-weight: 700;
    letter-spacing: .04em; margin-bottom: 8px;
  }
  .input-methods .method-label:not(:first-child) { margin-top: 14px; }
  .slot-badge {
    background: var(--accent); color: #fff;
    font-size: 11px; font-weight: 700; padding: 6px 11px; border-radius: 6px;
    letter-spacing: .02em;
  }

  /* ---------- AI推定の待ち時間表現 ---------- */
  .ai-loading {
    background: var(--sunken); border-radius: var(--radius-sm);
    padding: 14px; margin: 8px 0;
  }
  .ai-loading-msg {
    font-size: 13px; color: var(--text-sub); margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
  }
  .ai-spinner {
    width: 15px; height: 15px; border-radius: 50%; flex: none;
    border: 2px solid var(--accent-soft); border-top-color: var(--accent);
    animation: ai-spin .8s linear infinite;
  }
  @keyframes ai-spin { to { transform: rotate(360deg); } }
  .skeleton {
    height: 12px; border-radius: 6px; margin-bottom: 8px;
    background: linear-gradient(90deg, var(--border) 25%, var(--sunken) 37%, var(--border) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
  }
  .skeleton:last-child { margin-bottom: 0; }
  .skeleton.w60 { width: 60%; }
  .skeleton.w40 { width: 40%; }
  @keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
  @media (prefers-reduced-motion: reduce) {
    .skeleton, .ai-spinner { animation: none; }
  }

  .ai-result {
    background: var(--accent-tint); border: 1px solid var(--accent-soft);
    border-radius: var(--radius-sm); padding: 12px; margin: 8px 0;
  }
  .ai-result-name { font-weight: 700; font-size: 15px; }
  .ai-result-kcal { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
  .ai-result-head {
    font-size: 12px; color: var(--text-sub); font-weight: 600;
    margin-bottom: 10px;
  }
  .ai-result-head b { color: var(--accent); font-variant-numeric: tabular-nums; }
  .ai-item {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px; margin-bottom: 6px;
  }
  .ai-item:last-of-type { margin-bottom: 0; }
  .ai-item-breakdown {
    font-size: 11px; color: var(--muted); line-height: 1.55; padding: 0 2px;
  }
  .ai-result-breakdown { font-size: 12px; color: var(--text-sub); margin-top: 4px; line-height: 1.6; }
  .ai-error {
    font-size: 13px; color: var(--text-sub); background: var(--sunken);
    border-left: 3px solid var(--cheat);
    border-radius: 0 12px 12px 0; padding: 12px 13px; margin: 8px 0; line-height: 1.7;
  }
  .ai-error b { color: var(--text); }
  .err-raw {
    margin-top: 8px; font-size: 10px; color: var(--muted);
    word-break: break-all; line-height: 1.5;
  }

  /* ---------- 運動 ---------- */
  .ex-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .ex-item:last-of-type { border-bottom: none; }
  .ex-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 8px; margin-bottom: 7px;
  }
  /* white-space:nowrap が無いと幅が足りないとき1文字ずつ折り返して縦読みになる */
  .ex-name {
    font-size: 14px; font-weight: 700; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; min-width: 0;
  }
  .ex-est { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
  .ex-controls { display: flex; align-items: center; gap: 6px; }
  .ex-min { flex: 1; min-width: 0; text-align: center; padding: 0 4px; }
  .ex-log-btn { padding: 0 14px; }

  /* ---------- モーダル ---------- */
  .modal {
    position: fixed; inset: 0; background: rgba(30,28,25,0.45);
    align-items: flex-end; justify-content: center; z-index: 100;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  }
  .modal:not([hidden]) { display: flex; }
  .modal-inner {
    background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px 20px;
    width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 12px; }
  .modal-inner h3 { font-size: 17px; margin: 0 0 14px; }
  #settings-close-btn { margin-top: 6px; width: 100%; background: var(--card-bg); color: var(--text-sub); border: 1px solid var(--border-strong); }

  /* ---------- 記録シート（食事・体重・運動） ---------- */
  .add-sheet .modal-inner { position: relative; max-height: 92vh; }
  .sheet-close {
    position: absolute; top: 6px; right: 8px; z-index: 5;
    width: 44px; height: 44px; min-height: 44px; padding: 0;
    border-radius: 50%; background: var(--sunken); color: var(--text-sub);
    font-size: 18px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
  }
  .add-sheet-tabs {
    display: flex; gap: 4px; margin: 14px 0 12px;
    background: var(--sunken); border-radius: var(--radius-sm); padding: 3px;
  }
  .add-tab {
    flex: 1; min-height: 44px; padding: 0 4px;
    background: none; color: var(--text-sub);
    font-size: 12.5px; font-weight: 700; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; gap: 5px;
  }
  .add-tab .tab-icon { font-size: 15px; }
  .add-tab.active { background: var(--card-bg); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
  .add-pane { display: none; }
  .add-pane.active { display: block; }

  .preset-list-item {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
  }
  .preset-list-item:last-of-type { border-bottom: none; }
  .slot-checks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
  .slot-checks label {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; color: var(--text-sub);
    background: var(--sunken); border-radius: 8px; padding: 8px 10px; min-height: 38px;
  }
  .slot-checks input { width: 17px; height: 17px; accent-color: var(--accent); }
  label.check-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-sub); min-height: 44px;
  }
  label.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }

  /* 体重カードの畳んだ表示 */
  .weight-compact-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
  }
  .wc-values { display: flex; align-items: baseline; gap: 14px; }
  .wc-item {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 24px; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  }
  .wc-item .dot { width: 7px; height: 7px; }
  .wc-unit { font-size: 12px; color: var(--muted); font-weight: 600; }

  /* ---------- サマリー行（入力タブ上部・常時表示） ---------- */
  .summary-line {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 4px 14px; padding: 0 4px 10px;
    font-size: 12px; color: var(--muted); font-weight: 600;
  }
  .summary-line:empty { display: none; }
  .summary-line > span { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
  .summary-line b {
    font-size: 16px; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; letter-spacing: -.01em;
  }
  .summary-line .sl-diff {
    font-style: normal; font-size: 11px; color: var(--muted);
    font-variant-numeric: tabular-nums; margin-left: 2px;
  }

  /* 正方形のアイコンボタン（写真など） */
  .icon-square {
    width: var(--tap); min-width: var(--tap); padding: 0;
    font-size: 19px; line-height: 1;
  }
  /* 行内に収める小さなチェック */
  .mini-check {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--muted); font-weight: 600;
    min-height: var(--tap); padding: 0 4px; white-space: nowrap;
  }
  .mini-check input { width: 18px; height: 18px; accent-color: var(--accent); }

  /* 朝＝塗りつぶし／夜＝白抜きの共通ドット */
  .dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block; flex: none; vertical-align: middle;
  }
  .dot.filled { background: var(--accent); }
  .dot.hollow { background: var(--card-bg); border: 2px solid var(--accent); }
  .chart-legend {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 11px; color: var(--muted); margin-top: 8px;
  }
  .chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
  .chart-legend .dash {
    width: 16px; height: 0; border-top: 1.5px dashed var(--muted);
    display: inline-block; vertical-align: middle;
  }

  /* ---------- カレンダー ---------- */
  .cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .cal-head b { font-size: 15px; font-variant-numeric: tabular-nums; }
  .cal-nav {
    background: var(--sunken); color: var(--text-sub); border: 1px solid var(--border);
    width: 44px; min-width: 44px; min-height: 44px; padding: 0; font-size: 15px;
  }
  .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .calendar-dow { font-size: 10px; color: var(--muted); text-align: center; padding: 2px 0 4px; font-weight: 600; }
  .calendar-cell {
    aspect-ratio: 1; border-radius: 8px; background: var(--sunken);
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    padding: 3px 1px 0; gap: 0; border: 1px solid transparent; overflow: hidden;
  }
  .calendar-cell.empty { background: none; }
  .calendar-cell.today { border-color: var(--accent); }
  .calendar-cell.cheat { background: var(--cheat-soft); }
  .calendar-cell.has-record { background: var(--card-bg); border-color: var(--border); }
  .calendar-cell.has-record.cheat { background: var(--cheat-soft); }

  /* 日付の数字と体重の数字を明確に見分けられるようにする。
     日付＝小さく淡く上部に、体重＝濃く太くドット付きで下に置く。 */
  .cal-daynum {
    font-size: 9px; color: var(--muted); font-weight: 500;
    line-height: 1; align-self: flex-start; margin-left: 3px;
  }
  /* accent(#4a7c59)ではsunken背景で4.47となり基準(4.5)をわずかに下回るため、濃い方を使う */
  .calendar-cell.today .cal-daynum { color: var(--accent-strong); font-weight: 700; }
  .cal-weight {
    display: flex; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 1px;
  }
  .cal-weight .dot { width: 5px; height: 5px; }
  .cal-weight .dot.hollow { border-width: 1.5px; }
  .cal-weight.sub { font-weight: 600; color: var(--text-sub); font-size: 10px; }
  .cal-diff { font-size: 8.5px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.2; }

  .cal-legend { font-size: 11px; color: var(--muted); margin-top: 10px; display: flex; gap: 12px; flex-wrap: wrap; }
  .cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
  .cal-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
  .cal-swatch.cheat-swatch { background: var(--cheat-soft); border: 1px solid var(--cheat); }
  .cal-swatch.today-swatch { background: none; border: 1px solid var(--accent); }

  .empty-note { font-size: 13px; color: var(--muted); padding: 4px 0; }

  /* 画面には出さないが読み上げには渡す */
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }

  /* ---------- ふりかえり（AIコメント） ---------- */
  .fb-summary {
    font-size: 14px; line-height: 1.75; color: var(--text);
    font-weight: 600; margin-bottom: 12px;
  }
  .fb-list { display: flex; flex-direction: column; gap: 8px; }
  .fb-next {
    margin-top: 12px; padding: 12px 13px;
    background: var(--accent-tint); border: 1px solid var(--accent-soft);
    border-radius: var(--radius-sm);
    font-size: 13px; line-height: 1.7; color: var(--text-sub);
  }
  .fb-next-label {
    display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
    color: var(--accent-strong); margin-bottom: 4px;
  }
  .fb-item {
    background: var(--sunken); border-radius: var(--radius-sm);
    padding: 12px 13px; font-size: 13px; line-height: 1.7; color: var(--text-sub);
  }
  .fb-tag {
    display: inline-block; margin-right: 7px;
    background: var(--accent-soft); color: var(--accent-strong);
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
    padding: 2px 7px; border-radius: 5px; vertical-align: 1px;
    white-space: nowrap;
  }

  /* ふりかえりの口調の選択 */
  .tone-list { display: flex; flex-direction: column; gap: 6px; }
  .tone-btn {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    background: var(--card-bg); border: 1px solid var(--border-strong);
    color: var(--text); text-align: left;
    min-height: 56px; padding: 9px 13px; border-radius: var(--radius-sm);
  }
  .tone-btn.active { border-color: var(--accent); background: var(--accent-tint); }
  .tone-label { font-size: 14px; font-weight: 700; }
  .tone-btn.active .tone-label { color: var(--accent-strong); }
  .tone-desc { font-size: 11px; color: var(--muted); font-weight: 500; }

  /* 記録について聞く（AI画面） */
  .ask-q {
    font-size: 12px; color: var(--muted); font-weight: 700;
    padding-left: 12px; border-left: 3px solid var(--border-strong);
    margin-bottom: 10px; line-height: 1.6;
  }
  .ask-a {
    font-size: 13px; line-height: 1.85; color: var(--text-sub);
    background: var(--sunken); border-radius: var(--radius-sm); padding: 13px;
  }
  .ask-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .ask-chip {
    background: var(--card-bg); color: var(--text-sub);
    border: 1px solid var(--border-strong);
    min-height: 38px; padding: 0 12px; font-size: 12px; font-weight: 600;
    border-radius: 999px; white-space: nowrap;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  }
  .ask-chip:active { background: var(--sunken); }

  /* ---------- 記録できたことを知らせる通知 ---------- */
  .toast {
    position: fixed;
    left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
    transform: translate(-50%, 12px);
    max-width: min(90vw, 440px);
    background: var(--text); color: #fff;
    font-size: 13px; font-weight: 600; line-height: 1.5;
    padding: 12px 18px; border-radius: 999px;
    box-shadow: 0 6px 20px rgba(44,42,38,0.22);
    opacity: 0; pointer-events: none; z-index: 200;
    transition: opacity .18s ease, transform .18s ease;
    text-align: center;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  @media (prefers-reduced-motion: reduce) {
    .toast { transition: opacity .18s ease; transform: translate(-50%, 0); }
  }

  /* 体重カードの AM/PM 切り替え */
  .time-btn {
    background: none; color: var(--text-sub); border: none;
    min-height: 48px; padding: 0 16px; border-radius: 10px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  }
  .time-btn.done { color: var(--accent-strong); }
  .time-btn.done .slot-sub { color: var(--accent-strong); }
  .time-btn.active { background: var(--card-bg); color: var(--accent-strong); box-shadow: var(--shadow-sm); }

  /* ---------- ホーム：記録への入り口カード ---------- */
  /* 「押す場所」と「いまいくつか」を同じカードに載せる。
     見る→押すが一動作で済み、上の帯に数字を探しに行かなくてよくなる。 */
  /* ---------- ヒーローリング ---------- */
  /* 今日の食事・運動・体重の達成度を、数値の羅列ではなく円で見せる。
     ホームを開いた瞬間にいちばん目に入る場所に置く「今日どうだったか」の主役。 */
  .hero-rings-card { padding: 18px 8px 16px; }
  .hero-rings { display: flex; justify-content: space-around; align-items: center; }
  .ring-item { position: relative; width: 84px; height: 84px; }
  .ring-svg { display: block; width: 84px; height: 84px; transform: rotate(-90deg); }
  .ring-track { fill: none; stroke: var(--sunken); stroke-width: 8; }
  .ring-fill {
    fill: none; stroke-width: 8; stroke-linecap: round;
    transition: stroke-dashoffset .7s cubic-bezier(.34,1.05,.64,1);
  }
  .tone-meal .ring-fill { stroke: var(--accent); }
  .tone-exercise .ring-fill { stroke: #a8564c; }
  .tone-weight .ring-fill { stroke: #4f629c; }
  .ring-center {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
  }
  .ring-icon { font-size: 13px; line-height: 1; margin-bottom: 3px; }
  .ring-center b { font-size: 15px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
  .ring-center small { font-size: 9.5px; font-weight: 700; color: var(--muted); }

  .quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .qcard {
    display: block; text-align: left; position: relative;
    background: var(--card-bg); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 12px 13px; min-height: 118px;
    box-shadow: var(--shadow-sm);
  }
  .qcard:active { background: var(--sunken); }
  .qcard-art {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px; margin-bottom: 7px; overflow: hidden;
  }
  .qcard-art img { width: 100%; height: 100%; object-fit: cover; }
  .qcard-icon { font-size: 20px; line-height: 1; }
  .qcard-label { display: block; font-size: 11.5px; font-weight: 800; color: var(--muted); }
  .qcard-value { display: flex; align-items: baseline; gap: 3px; margin-top: 1px; }
  .qcard-value b { font-size: 23px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
  .qcard-value i { font-size: 11px; font-style: normal; font-weight: 700; color: var(--muted); }
  .qcard-sub {
    display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tone-meal .qcard-art { background: #e8f0e9; }
  .tone-exercise .qcard-art { background: #fbeae7; }
  .tone-weight .qcard-art { background: #e9edf6; }
  .tone-ai .qcard-art { background: #e6eff2; }

  /* ---------- 今日のできごと ---------- */
  /* 記録したことだけを並べる。空いている区分は出さない
     （入れていないところを突きつけない、という方針のため）。 */
  .timeline { display: flex; flex-direction: column; }
  .tl-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
  .tl-item + .tl-item { border-top: 1px dashed var(--border); }
  .tl-icon {
    width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--sunken);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
  }
  .tl-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tl-detail { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .tl-empty { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.75; }
  .robot-line { margin: 0; font-size: 13.5px; line-height: 1.75; color: var(--text-sub); }
  .muted-note { font-size: 11px; font-weight: 700; color: var(--muted); }

  /* ---------- 旅の記録 ---------- */
  .journey { display: flex; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
  .jstop { flex: none; width: 74px; text-align: center; position: relative; }
  .jstop::before {
    content: ''; position: absolute; top: 13px; left: -37px; width: 74px; height: 3px;
    background: var(--border-strong);
  }
  .jstop:first-child::before { display: none; }
  .jstop.done::before, .jstop.here::before { background: var(--accent); }
  .jdot {
    position: relative; display: flex; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%;
    align-items: center; justify-content: center; font-size: 13px;
    background: var(--border-strong); color: #fff;
  }
  .jstop.done .jdot { background: var(--accent); }
  .jstop.here .jdot { background: #9a6c2c; box-shadow: 0 0 0 4px rgba(154,108,44,.22); }
  .jname { display: block; font-size: 10px; margin-top: 6px; color: var(--muted); font-weight: 700; line-height: 1.35; }
  .jstop.here .jname { color: var(--text); }

  .map { display: flex; flex-direction: column; gap: 8px; }
  .map-row { display: flex; align-items: center; gap: 11px; padding: 7px; border-radius: var(--radius-sm); background: var(--sunken); }
  .map-row.here { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent-soft); }
  .map-thumb {
    width: 76px; height: 47px; flex: none; border-radius: 9px; overflow: hidden;
    background: var(--border); display: flex; align-items: center; justify-content: center;
  }
  .map-thumb svg { width: 100%; height: 100%; display: block; }
  .map-lock { font-size: 17px; }
  .map-text b { display: block; font-size: 13.5px; }
  .map-text small { font-size: 11px; color: var(--muted); font-weight: 700; }

  /* ---------- バッジ ---------- */
  .badge-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
  .badge { flex: none; width: 66px; text-align: center; }
  .badge-icon {
    display: flex; width: 44px; height: 44px; margin: 0 auto; border-radius: 50%;
    background: var(--accent-tint); align-items: center; justify-content: center; font-size: 21px;
  }
  .badge-name { display: block; font-size: 10px; margin-top: 6px; color: var(--text-sub); font-weight: 700; line-height: 1.35; }
  .badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .badge-cell { background: var(--sunken); border-radius: var(--radius-sm); padding: 12px 9px; text-align: center; }
  .badge-cell b { display: block; font-size: 12px; margin-top: 7px; }
  .badge-cell small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
  /* 未取得は opacity では薄めない（文字のコントラストが基準を割るため）。
     アイコンだけ灰色にして、文字はそのままの濃さで残す。 */
  .badge-cell.off .badge-icon { background: var(--border); }
  .badge-cell.off b { color: var(--text-sub); }

  /* ---------- バッジ獲得のお知らせ ---------- */
  .cheer {
    position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top));
    transform: translate(-50%, -16px);
    display: flex; align-items: center; gap: 12px;
    max-width: min(92vw, 400px);
    background: var(--card-bg); border: 1px solid var(--border-strong); border-radius: 16px;
    padding: 11px 16px 11px 13px;
    box-shadow: 0 8px 26px rgba(44,42,38,.16);
    opacity: 0; z-index: 120;
    transition: opacity .3s ease, transform .3s cubic-bezier(.34,1.3,.64,1);
  }
  .cheer.show { opacity: 1; transform: translate(-50%, 0); }
  .cheer-icon { font-size: 26px; line-height: 1; }
  .cheer-text b { display: block; font-size: 14px; }
  .cheer-text small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
  @media (prefers-reduced-motion: reduce) {
    .cheer { transition: opacity .18s ease; transform: translate(-50%, 0); }
  }

  /* ---------- 設定：イラスト ---------- */
  .art-usage { font-size: 11.5px; color: var(--muted); font-weight: 700; margin: 10px 0; }
  .art-group + .art-group { margin-top: 8px; }
  .art-head {
    width: 100%; display: flex; align-items: center; gap: 8px;
    min-height: 46px; padding: 0 12px;
    background: var(--sunken); color: var(--text); border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 700;
  }
  .art-head > span:first-child { flex: 1; text-align: left; }
  .art-head .art-count { font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
  .art-head::after { content: '\25BE'; color: var(--muted); font-size: 11px; transition: transform .15s ease; }
  .art-head.open::after { transform: rotate(180deg); }
  .art-head:active { background: var(--border); }
  .art-list { padding: 8px 2px 4px; }
  /* 1枠に複数枚を横並びで登録できる。日替わりで表示されることが伝わるよう、
     「1枚だけ」ではなく「並べて増やす」見た目にしている。 */
  .art-slot { padding: 10px 0; }
  .art-slot + .art-slot { border-top: 1px solid var(--border); }
  .art-slot-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
  .art-slot-count { font-size: 10.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
  .art-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .art-thumb-item {
    position: relative; flex: none; width: 60px; height: 60px;
    border-radius: 10px; overflow: hidden; background: var(--sunken);
  }
  .art-thumb-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .art-thumb-tag {
    position: absolute; left: 0; right: 0; bottom: 0; text-align: center;
    font-size: 8.5px; font-weight: 700; color: #fff;
    background: rgba(20,19,17,.78); padding: 1px 0;
  }
  .art-thumb-del {
    position: absolute; top: 2px; right: 2px; z-index: 2;
    width: 20px; height: 20px; min-height: 20px; padding: 0;
    border-radius: 50%; background: rgba(30,28,25,.65); color: #fff;
    font-size: 12px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
  }
  .art-thumb-add {
    flex: none; width: 60px; height: 60px; padding: 0;
    border-radius: 10px; background: var(--sunken); color: var(--muted);
    font-size: 20px; font-weight: 400;
    display: flex; align-items: center; justify-content: center;
    border: 1px dashed var(--border-strong);
  }
  .art-name { flex: 1; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .art-name small { display: block; font-size: 10px; color: var(--muted); font-weight: 700; }


  /* ---------- 監査で見つかった、以前からの取りこぼし ---------- */
  /* 記録済みエントリの朝/昼/夜ボタンが高さ34pxで、最小44pxに届いていなかった */
  .entry-slot { min-height: 44px; }
  /* AIの質問チップも同様 */
  .ask-chip { min-height: 44px; }
  /* 食事プリセット登録のチェックボックス。枠自体が18pxで押しにくい */
  .check-row { min-height: 44px; display: flex; align-items: center; gap: 8px; }
  .check-row input[type="checkbox"] { width: 22px; height: 22px; }
  /* 食事の区分ボタンの補助数値（選択中のみ）。白85%では緑地に対して4.02しかなかった。
     .slot-btn を付けずに書くと未選択時の「—」まで白になり、白背景に白文字で消える事故になる。 */
  .slot-btn.active .slot-sub { color: rgba(255,255,255,.96); }


  /* プリセットの区分チェック（朝/昼/夜/間食）。枠が17pxで押しにくかったので、
     ラベルごと44pxの当たり判定にして枠も大きくする。 */
  #preset-settings label, #exercise-preset-settings label {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px; padding-right: 8px;
  }
  #preset-settings label input[type="checkbox"],
  #exercise-preset-settings label input[type="checkbox"] {
    width: 22px; height: 22px; accent-color: var(--accent);
  }


  /* 話しかけられた相棒が、ひょいと跳ねる */
  @keyframes chara-hop {
    0% { transform: translateY(0); }
    35% { transform: translateY(-10px); }
    60% { transform: translateY(0); }
    75% { transform: translateY(-4px); }
    100% { transform: translateY(0); }
  }
  .scene.poked .scene-chara-svg, .scene.poked .scene-chara-img {
    animation: chara-hop .55s cubic-bezier(.34,1.3,.64,1);
  }
  @media (prefers-reduced-motion: reduce) {
    .scene.poked .scene-chara-svg, .scene.poked .scene-chara-img { animation: none; }
  }
  /* 押せることが分かるように、指のカーソルにしておく */
  .scene.full { cursor: pointer; }
