/* ==============================================
   ヘルスログ v9 — 完全リデザイン
   ============================================== */

/* ── Variables ── */
:root {
  --bg:        #eef2f7;
  --surface:   #ffffff;
  --surface2:  #f4f7fb;
  --green:     #059669;
  --green-dk:  #047857;
  --green-lg:  #d1fae5;
  --amber:     #b45309;
  --amber-lg:  #fef3c7;
  --text:      #1a202c;
  --text2:     #4a5568;
  --text3:     #a0aec0;
  --red:       #e53e3e;
  --red-lg:    #fff5f5;
  --shadow:    0 2px 10px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.05);
  --shadow-lg: 0 8px 28px rgba(15,23,42,.12), 0 2px 6px rgba(15,23,42,.05);
  --r:         14px;
  --r-lg:      20px;
  --safe: env(safe-area-inset-bottom, 0px);
  --nav-h: 68px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.dialog-open { overflow:hidden; }
button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.sr-only { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }

/* ── Shell ── */
.app-shell {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + 32px + var(--safe));
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  margin-bottom: 4px;
}
.title-block p  { margin: 0; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--green); }
.title-block h1 { margin: 0; font-size: 1.6rem; font-weight: 900; letter-spacing: -.04em; line-height: 1.1; }
.title-block span { display: none; }
.menu-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  color: var(--text2);
  display: grid;
  place-items: center;
}

/* ── Panel tabs ── */
.app-main { display: block; }
.panel { display: none; }
.panel.active { display: block; }

/* ── Page title ── */
.page-title { margin: 0 0 16px; }
.page-title h2 { margin: 0; font-size: 1.4rem; font-weight: 900; letter-spacing: -.03em; }
.page-title p  { margin: 3px 0 0; font-size: .85rem; color: var(--text2); }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* section-head (JS生成との互換) */
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.section-head h2    { margin: 0; font-size: 1.05rem; font-weight: 800; }
.section-head p     { margin: 3px 0 0; font-size: .8rem; color: var(--text2); }
.section-head small { font-size: .78rem; color: var(--text3); font-weight: 700; }

/* ── Inputs ── */
input, textarea, select {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid transparent;
  border-radius: var(--r);
  padding: 10px 14px;
  color: var(--text);
  font-weight: 600;
  min-height: 46px;
  transition: border-color .15s, background .15s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  background: #fff;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.6; font-weight: 500; }

.field-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.field-row span { font-size: .85rem; font-weight: 700; color: var(--text2); white-space: nowrap; }
/* グリッドのはみ出し防止 */
.field-row input,
.field-row select { min-width: 0; width: 100%; }
label { font-weight: 700; display: block; }

/* ── Buttons ── */
.primary {
  width: 100%;
  background: var(--green);
  color: #fff;
  border-radius: var(--r);
  font-size: 1rem;
  font-weight: 800;
  min-height: 50px;
  letter-spacing: .01em;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 4px 14px rgba(5,150,105,.32);
  display: block;
}
.primary:active { transform: scale(.98); opacity: .9; }
.primary:disabled { opacity: .55; }

.secondary {
  background: var(--surface2);
  color: var(--text2);
  border-radius: var(--r);
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
}
.mini-btn {
  background: var(--green-lg);
  color: var(--green-dk);
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  padding: 5px 12px;
  min-height: 0;
}
.close {
  background: var(--surface2);
  color: var(--text2);
  border-radius: 10px;
  font-weight: 700;
  min-height: 36px;
  padding: 0 14px;
}
.danger {
  background: var(--red-lg);
  color: var(--red);
  border-radius: var(--r);
  font-weight: 700;
  min-height: 44px;
  padding: 0 14px;
}

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions > * { flex: 1; }

/* ── Bottom Nav ── */
.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe));
  transform: translateX(-50%);
  width: min(460px, calc(100% - 24px));
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255,255,255,.96);
  border-radius: var(--r-lg);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.tab {
  border-radius: 14px;
  color: var(--text3);
  font-size: .73rem;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 0;
  transition: background .15s, color .15s;
}
.tab-icon { font-size: 1.35rem; line-height: 1; }
.tab.active { background: var(--green-lg); color: var(--green-dk); }

/* ─────────────────────────────
   入力タブ
───────────────────────────── */
.meal-types {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
.meal-type {
  min-height: 44px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text2);
  font-size: .88rem;
  font-weight: 800;
  transition: background .12s, color .12s;
}
.meal-type.active { background: var(--green); color: #fff; }

.compact-details { padding: 0; margin-top: 6px; }
.compact-details summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface2);
  font-size: .88rem;
  font-weight: 700;
  color: var(--text2);
  user-select: none;
}
.compact-details summary::after { content: "›"; font-size: 1.1rem; color: var(--text3); }
.compact-details[open] summary { border-radius: 12px 12px 0 0; }
.compact-details[open] summary::after { content: "‹"; }
details summary::-webkit-details-marker { display: none; }

.assist-panel.flat {
  background: var(--surface2);
  border-radius: 0 0 12px 12px;
  padding: 12px 14px;
}
.assist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.assist-head b { font-size: .85rem; font-weight: 800; }

.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row button, .chip {
  flex: 0 0 auto;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: .83rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.meal-hint, .info-box {
  margin-top: 8px;
  font-size: .8rem;
  color: var(--text3);
  font-weight: 600;
}
.info-box {
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 10px;
  color: var(--text2);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 12px;
  color: #166534;
  font-weight: 600;
  font-size: .9rem;
  margin-top: 10px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #bbf7d0;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  padding: 12px 14px;
  background: var(--red-lg);
  border: 1.5px solid #fecaca;
  border-radius: 12px;
  color: var(--red);
  font-size: .9rem;
  margin-top: 10px;
}
.error b { display: block; font-weight: 800; margin-bottom: 2px; }

/* 推定結果カード */
.title-input {
  width: 100%;
  font-size: 1.1rem;
  font-weight: 900;
  border: 0;
  border-bottom: 2px solid var(--surface2);
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
  margin-bottom: 14px;
  min-height: 0;
  color: var(--text);
}
.title-input:focus { border-bottom-color: var(--green); background: transparent; }

.number-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.number-grid label {
  background: var(--surface2);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.number-grid input, .number-grid select {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  min-height: 36px;
  padding: 4px 8px;
}
.number-grid input:focus { border-color: var(--green); }
.number-grid small { display: block; text-align: center; color: var(--text3); font-size: .73rem; font-weight: 700; }

.main-nutrients { grid-template-columns: repeat(2, 1fr); }
.extra-grid     { grid-template-columns: repeat(2, 1fr); }
.profile-grid   { grid-template-columns: repeat(2, 1fr); }
.body-grid      { grid-template-columns: repeat(3, 1fr); }
.body-grid label { padding: 8px 10px; }

.details-box { margin-top: 12px; }
.details-box summary {
  list-style: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 700;
  color: var(--green-dk);
  padding: 6px 2px;
}
.details-box summary::-webkit-details-marker { display: none; }
#saveFeedback { font-size: .85rem; margin-top: 8px; }

/* ── Card label ── */
.card-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}
.card-label-standalone {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 4px 4px 8px;
}
.card-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 12px;
}

/* ── Row actions ── */
.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.row-actions > .primary { flex: 1; }

/* ── Section label (body tab) ── */
.section-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 4px 4px 8px;
}

/* ── Template row ── */
.template-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.template-row .chip-row { flex: 1; }
.ghost-sm {
  flex-shrink: 0;
  background: var(--surface2);
  color: var(--text2);
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  padding: 6px 12px;
  white-space: nowrap;
}
.meal-hint {
  font-size: .8rem;
  color: var(--text3);
  font-weight: 600;
  min-height: 1em;
  margin-top: 4px;
}

/* ── Chart note ── */
.chart-note {
  font-size: .78rem;
  color: var(--text3);
  margin: 6px 0 0;
  font-weight: 600;
}

/* ── Ghost button ── */
.ghost {
  background: var(--surface2);
  color: var(--text2);
  border-radius: var(--r);
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
  white-space: nowrap;
}

/* ── More fields (details) ── */
.more-fields { margin-top: 10px; }
.more-fields summary {
  list-style: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 700;
  color: var(--green-dk);
  padding: 6px 0;
}
.more-fields summary::-webkit-details-marker { display: none; }

/* ── Info note ── */
.info-note {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 10px;
  font-size: .8rem;
  color: var(--text2);
  font-weight: 500;
}

/* ─────────────────────────────
   記録タブ
───────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.date-nav label { flex: 1; }
.date-nav label span {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 3px;
}
.square-btn {
  width: 44px; height: 44px;
  background: var(--surface2);
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* 記録タブ：日付カード */
.date-card { padding: 14px 16px; }
.day-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.sq-btn {
  width: 44px; height: 44px;
  background: var(--surface2);
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text2);
  display: grid;
  place-items: center;
}
.day-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.day-total > span { font-size: .9rem; font-weight: 700; color: var(--text2); }
.day-total strong { font-size: 2.2rem; font-weight: 900; color: var(--amber); line-height: 1; }
.day-total strong span { font-size: inherit; font-weight: inherit; color: inherit; }
.day-total em { font-style: normal; font-size: .85rem; font-weight: 700; color: var(--text2); margin-left: 2px; }

/* 分析タブ：期間カード */
.period-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
}
.period-card .field-row { flex: 1; margin: 0; }

/* 旧: day-line, total-line との互換 */
.day-line {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: end;
}
.day-line label span {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 3px;
}
.total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  gap: 10px;
}
.total-line span { font-size: .92rem; font-weight: 700; color: var(--text2); }
.total-line b    { font-size: 2rem; font-weight: 900; color: var(--amber); line-height: 1; }
.add-btn {
  width: 42px; height: 42px;
  background: var(--green);
  color: #fff;
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(5,150,105,.3);
}

/* 副栄養素グリッド */
.mini-kpi {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.mini-kpi div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
  border-radius: 11px;
  padding: 10px 13px;
}
.mini-kpi div span {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text2);
}
.mini-kpi div b {
  font-size: .98rem;
  font-weight: 900;
  color: var(--text);
}

/* ドロワー */
.drawer { padding: 0; }
.drawer summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  font-size: .92rem;
  font-weight: 800;
  user-select: none;
}
.drawer summary::after { content: "›"; color: var(--text3); font-size: 1.1rem; }
.drawer[open] summary::after { content: "‹"; }
.drawer > *:not(summary) { padding: 0 16px; }
.drawer > div:last-child,
.drawer > .records { padding-bottom: 14px; }
.drawer[open] summary { border-bottom: 1px solid var(--surface2); }

/* 栄養素リスト */
.nutrient-list { display: grid; gap: 6px; margin: 10px 0; }
.nutrient-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 13px;
  background: var(--surface2);
  border-radius: 10px;
}
.nutrient-list div span { font-size: .85rem; color: var(--text2); font-weight: 600; }
.nutrient-list div b    { font-size: .92rem; font-weight: 800; }
.nutrient-list div small{ font-size: .78rem; color: var(--text3); margin-left: 8px; font-weight: 600; }

/* ネクストアクション */
.next-actions { display: grid; gap: 6px; margin: 10px 0; }
.next-actions div, .next-actions p {
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  margin: 0;
  color: var(--text2);
}

/* 記録タブのサマリーは重複するので非表示 */
#recordsDaySummary { display: none; }

/* ミニサマリー（分析タブ 履歴用） */
.mini-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 13px;
  background: var(--surface2);
  border-radius: 11px;
  margin: 0 0 10px;
  font-size: .88rem;
  font-weight: 700;
  flex-wrap: wrap;
  gap: 4px;
}
/* 全栄養素の長い文字列を2行に制限 */
.mini-summary small {
  width: 100%;
  font-size: .72rem;
  color: var(--text3);
  font-weight: 500;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 食事記録 */
.records { display: grid; gap: 6px; margin: 8px 0; }
.empty {
  text-align: center;
  padding: 22px;
  color: var(--text3);
  font-size: .9rem;
  font-weight: 600;
}

.meal-group { margin-bottom: 10px; }
.meal-group h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 7px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 2px;
}
.meal-group h4 b {
  font-weight: 600;
  color: var(--text2);
  font-size: .8rem;
  text-transform: none;
  letter-spacing: 0;
}
.meal-group h4 span {
  background: var(--surface2);
  border-radius: 6px;
  padding: 2px 8px;
}

/* 記録行：食事・身体で完全に同一の構造／スタイル */
.record {
  background: var(--surface2);
  border-radius: 11px;
  padding: 10px 13px;
}
.record-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.record-main { min-width: 0; }
.record-name { font-size: .9rem; font-weight: 600; line-height: 1.35; }
.record-sub { font-size: .7rem; font-weight: 500; color: var(--text3); margin-top: 1px; }
.record-val { font-size: 1rem; font-weight: 700; color: var(--amber); white-space: nowrap; flex-shrink: 0; }
.record-val small { font-size: .68rem; font-weight: 600; margin-left: 1px; }

.record-meta { margin-top: 5px; font-size: .76rem; font-weight: 500; color: var(--text2); line-height: 1.5; }

.record-more { margin-top: 3px; }
.record-more summary {
  list-style: none;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text3);
  padding: 2px 0;
}
.record-more summary::-webkit-details-marker { display: none; }
.record-more .record-meta { margin-top: 3px; }

.record-acts {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 8px;
}
.record-acts button {
  background: none;
  min-height: 0;
  padding: 2px 0;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text2);
}
.record-acts button.del { color: var(--red); }

/* ─────────────────────────────
   分析タブ
───────────────────────────── */
.analysis-toolbar { padding: 14px 18px; }
.period-controls { display: grid; gap: 9px; }
.period-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; width: 148px; flex-shrink: 0; }
.period-tab {
  min-height: 42px;
  border-radius: 11px;
  background: var(--surface2);
  color: var(--text2);
  font-weight: 800;
  font-size: .9rem;
  transition: background .12s, color .12s;
}
.period-tab.active { background: var(--green); color: #fff; }

.analysis-menu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.analysis-tab {
  min-height: 40px;
  border-radius: 11px;
  background: var(--surface);
  color: var(--text2);
  font-weight: 800;
  font-size: .82rem;
  box-shadow: var(--shadow);
  transition: background .12s, color .12s, box-shadow .12s;
}
.analysis-tab.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 10px rgba(5,150,105,.3);
}
.analysis-section { display: none; }
.analysis-section.active { display: block; }

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.analysis-grid div {
  background: var(--surface2);
  border-radius: 13px;
  padding: 13px 14px;
}
.analysis-grid div span {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.analysis-grid div b {
  display: block;
  font-size: .82rem;
  font-weight: 800;
  line-height: 1.5;
}
.analysis-grid div small {
  display: block;
  font-size: .75rem;
  color: var(--text3);
  margin-top: 4px;
  font-weight: 600;
}

.analysis-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.analysis-stats div {
  background: var(--surface2);
  border-radius: 13px;
  padding: 12px 14px;
}
.analysis-stats div span {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 5px;
}
.analysis-stats div b { font-size: .95rem; font-weight: 800; }

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text2);
  margin: 8px 0;
  flex-wrap: wrap;
}
.chart-legend i { display: inline-block; width: 14px; height: 6px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.legend-cal    { background: #f59e0b; }
.legend-goal   { background: #94a3b8; }
.legend-weight { background: #f97316; }

.chart-wrap {
  position: relative;
  border-radius: 13px;
  background: var(--surface2);
  padding: 8px;
  height: 196px;
}
.body-chart { height: 180px; }

/* グラフの吹き出し（タップした点に追従） */
.chart-tip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 12px));
  background: #1e293b;
  color: #fff;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 240px;
  box-shadow: 0 6px 18px rgba(15,23,42,.28);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; font-size: .82rem; font-weight: 800; }
.chart-tip span { display: block; font-size: .72rem; font-weight: 600; color: #cbd5e1; white-space: normal; }
.chart-tip::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
  border-bottom: 0;
}

/* 栄養素バー */
.bars { display: grid; gap: 8px; }
.bar-row {
  background: var(--surface2);
  border-radius: 12px;
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 80px 1fr auto 44px;
  gap: 8px;
  align-items: center;
}
.bar-row b    { font-size: .84rem; font-weight: 700; color: var(--text2); }
.bar-row meter { width: 100%; height: 7px; border-radius: 4px; }
.bar-row span { font-size: .82rem; font-weight: 700; white-space: nowrap; text-align: right; }
.bar-row span small { font-size: .72rem; color: var(--text3); font-weight: 600; }
.bar-row strong { font-size: .85rem; font-weight: 900; text-align: right; }
.bar-row.low  strong { color: #3b82f6; }
.bar-row.high strong { color: var(--red); }

.advice-list { margin-top: 10px; }
.advice-list p {
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text2);
  margin: 0 0 6px;
}

.analysis-card details {
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface2);
  margin-bottom: 8px;
}
.analysis-card details summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-size: .9rem;
  font-weight: 800;
  user-select: none;
  display: flex;
  justify-content: space-between;
}
.analysis-card details summary::after { content: "›"; color: var(--text3); }
.analysis-card details[open] summary::after { content: "‹"; }
.analysis-card details summary::-webkit-details-marker { display: none; }
.analysis-card details > *:not(summary) { padding: 0 14px 14px; }

/* ─────────────────────────────
   身体タブ
───────────────────────────── */
.burn {
  margin-top: 10px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text2);
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 10px;
}
.vital-item { background: var(--surface); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.vital-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.vital-weight { font-size: 1.05rem; font-weight: 900; color: var(--amber); }
.vital-weight small { font-size: .72rem; margin-left: 2px; }
.compact-list { display: grid; gap: 8px; margin: 8px 0; }

.profile-details > *:not(summary) { margin-top: 10px; }
.profile-details summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .92rem;
  font-weight: 800;
  user-select: none;
}
.profile-details summary::after { content: "›"; color: var(--text3); font-size: 1.1rem; }
.profile-details[open] summary::after { content: "‹"; }
.profile-details summary::-webkit-details-marker { display: none; }

/* ── 日付ドラムロール（iOS純正風・全端末共通） ── */
#dateSheet { z-index: 95; }
.drum-date { cursor: pointer; }
.date-sheet { padding: 0 0 calc(12px + var(--safe)); }
.drum-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.drum-title { font-size: .95rem; font-weight: 700; color: var(--text2); }
.drum-btn { font-size: 1rem; font-weight: 700; background: none; min-height: 0; padding: 4px; }
.drum-btn.cancel { color: var(--text3); }
.drum-btn.done { color: var(--green); font-weight: 800; }
.drum {
  position: relative;
  display: flex;
  justify-content: center;
  height: 220px;
  margin: 6px 0 4px;
  overflow: hidden;
}
.drum-col {
  flex: 1;
  max-width: 130px;
  height: 220px;
  overflow-y: scroll;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.drum-col::-webkit-scrollbar { display: none; }
.drum-spacer { position: relative; width: 100%; }
.drum-item {
  position: absolute;
  left: 0; right: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 500;
  color: #c2c9d3;
  transition: color .12s;
}
.drum-item.on { color: var(--text); font-weight: 700; }
.drum-center {
  position: absolute;
  left: 8px; right: 8px; top: 90px;
  height: 40px;
  border-top: 1px solid #d4dae3;
  border-bottom: 1px solid #d4dae3;
  pointer-events: none;
}

/* ── Sheet head ── */
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.sheet-head h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }

/* ── Drawer body ── */
.drawer-body { padding: 0 16px 16px; }

/* ─────────────────────────────
   運用管理パネル
───────────────────────────── */
.tools-panel {
  position: fixed;
  inset: 10px;
  z-index: 60;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  overflow: auto;
}
.tools-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  position: sticky;
  top: 0;
  background: var(--surface);
  padding-bottom: 12px;
  z-index: 2;
}
.tools-head p  { margin: 0; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--green); }
.tools-head h2 { margin: 0; font-size: 1.35rem; font-weight: 900; }
.ops-menu { display: grid; gap: 10px; }
.ops-menu details { background: var(--surface2); border-radius: 14px; padding: 8px; }
.ops-menu summary { list-style: none; font-weight: 800; font-size: .9rem; padding: 8px; cursor: pointer; }
.ops-menu img { display: block; width: 100%; border-radius: 10px; }
.ops-links, .tool-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.ops-links a {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 12px;
  background: var(--green-lg);
  color: var(--green-dk);
  font-weight: 800;
  font-size: .88rem;
}
.tool-actions button {
  min-height: 44px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text2);
  font-weight: 700;
  font-size: .88rem;
}
.debug {
  white-space: pre-wrap;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  font-size: .82rem;
  max-height: 220px;
  overflow: auto;
  margin-top: 10px;
  font-family: "Cascadia Code", "Consolas", monospace;
}

/* ─────────────────────────────
   シート (bottom sheet)
───────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 70; }
.backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.sheet-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  max-height: 92dvh;
  overflow: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(20px + var(--safe));
}
.sheet-panel label { display: block; margin-top: 10px; }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 24px + var(--safe));
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
  z-index: 80;
}

/* ── 計算するボタン sticky ── */
.sticky-action {
  position: sticky;
  bottom: calc(var(--nav-h) + 16px + var(--safe));
  z-index: 10;
  padding: 8px 0 2px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  margin-top: 10px;
}

/* ─────────────────────────────
   ゲージ（目安ライン付きバー）
───────────────────────────── */
.gauges { display: grid; gap: 14px; }
.gbar-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.gbar-top b { font-size: .9rem; font-weight: 700; color: var(--text2); }
.gbar-val { font-size: 1.18rem; font-weight: 900; color: var(--text); }
.gbar-val i { font-size: .72rem; font-weight: 700; color: var(--text3); margin-left: 2px; font-style: normal; }
.gbar-track { position: relative; height: 12px; border-radius: 6px; background: #e7edf5; }
.gbar-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 6px; min-width: 5px; transition: width .35s ease; }
/* 目安（=100%）のライン。トラック最大は目安の150%なので 2/3 の位置 */
.gbar-mark { position: absolute; left: 66.666%; top: -3px; height: 18px; width: 2px; background: #1e293b; opacity: .5; border-radius: 1px; }
.gbar-bot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: .73rem; font-weight: 600; }
.gbar-goal { color: var(--text3); }
.gbar-tag { font-weight: 800; }
/* 状態色：不足=青 / 適正=緑 / 過多=赤 */
.gbar.under .gbar-fill { background: #3b82f6; }
.gbar.under .gbar-tag  { color: #2563eb; }
.gbar.ok    .gbar-fill { background: var(--green); }
.gbar.ok    .gbar-tag  { color: var(--green-dk); }
.gbar.over  .gbar-fill { background: #ef4444; }
.gbar.over  .gbar-tag  { color: #dc2626; }
.gbar.none  .gbar-fill { background: var(--text3); }
.gbar.none  .gbar-tag  { color: var(--text3); }

.muted-label { color: var(--text3); font-weight: 700; text-transform: none; letter-spacing: 0; }
.balance-wrap { height: 160px; }

/* ── 身体：3指標カード（同列・タップで選択） ── */
.bmetric-cards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.bmcard {
  min-width: 0;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 13px;
  padding: 11px 8px;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.bmcard span { display: block; font-size: .72rem; font-weight: 700; color: var(--text2); margin-bottom: 3px; }
.bmcard b { display: block; font-size: 1.12rem; font-weight: 900; color: var(--text); white-space: nowrap; line-height: 1.1; }
.bmcard b i { font-size: .66rem; font-weight: 700; color: var(--text3); font-style: normal; margin-left: 1px; }
.bm-badge { display: inline-block; margin-top: 5px; font-size: .68rem; font-weight: 800; font-style: normal; padding: 1px 8px; border-radius: 999px; }
.bm-badge.tone-ok    { background: var(--green-lg); color: var(--green-dk); }
.bm-badge.tone-under { background: #dbeafe; color: #2563eb; }
.bm-badge.tone-over  { background: #fee2e2; color: #dc2626; }
.bm-badge.tone-none  { background: var(--surface); color: var(--text3); }
.bm-range { display: block; min-height:2.4em; margin-top: 4px; font-size: .625rem; font-weight: 600; line-height:1.2; white-space: normal; overflow-wrap:anywhere; color: var(--text3); }
.bm-delta { display: block; margin-top: 2px; font-size: .66rem; font-weight: 700; white-space: nowrap; color: var(--text3); min-height: .9em; }
.bm-delta.d-down { color: #2563eb; }
.bm-delta.d-up   { color: #dc2626; }
.bmcard.active { background: #fff; border-color: var(--green); }

/* グラフ操作のヒント（吹き出し本体は .chart-tip） */
.point-detail {
  margin-top: 8px;
  font-size: .7rem;
  font-weight: 500;
  color: var(--text3);
  text-align: center;
}

/* ═══════════════════════════════════
   Responsive — tablet ≥ 600px
═══════════════════════════════════ */
@media (min-width: 600px) {
  .app-shell { max-width: 640px; padding-left: 20px; padding-right: 20px; }
  .bottom-tabs { width: min(620px, calc(100% - 20px)); }
  .main-nutrients, .extra-grid, .profile-grid { grid-template-columns: repeat(3, 1fr); }
  .analysis-stats { grid-template-columns: repeat(4, 1fr); }
  .mini-kpi { grid-template-columns: repeat(4, 1fr); }
  .chart-wrap { height: 220px; }
  .tools-panel { left: 50%; right: auto; transform: translateX(-50%); width: min(640px, calc(100% - 24px)); }
}

/* ═══════════════════════════════════
   Responsive — desktop ≥ 1024px
═══════════════════════════════════ */
@media (min-width: 1024px) {
  .app-shell { max-width: 860px; padding-left: 28px; padding-right: 28px; }
  .bottom-tabs { width: min(840px, calc(100% - 28px)); }
  .analysis-stats { grid-template-columns: repeat(4, 1fr); }
  .chart-wrap { height: 240px; }
  .ops-links, .tool-actions { grid-template-columns: repeat(4, 1fr); }
  .ops-menu img { max-height: 660px; object-fit: contain; }
  .tools-panel { width: min(860px, calc(100% - 32px)); }
}

/* ═══════════════════════════════════
   Responsive — small ≤ 375px
═══════════════════════════════════ */
@media (max-width: 375px) {
  html { font-size: 14px; }
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .mini-kpi { grid-template-columns: repeat(2, 1fr); }
  .meal-types { gap: 5px; }
  .analysis-menu { grid-template-columns: repeat(2, 1fr); }
  .analysis-stats { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 1fr; gap: 5px; }
  .chart-wrap { height: 172px; }
  .body-grid { grid-template-columns: repeat(2, 1fr); }
}

/* v10 — editorial utility theme. Existing DOM and application flow are unchanged. */
:root {
  --bg: #f3f0e8;
  --surface: #fffdf7;
  --surface2: #ece8de;
  --green: #176b55;
  --green-dk: #0b3f34;
  --green-lg: #cfe3d8;
  --amber: #b45b2d;
  --amber-lg: #f5dfc5;
  --text: #17201d;
  --text2: #53605b;
  --text3: #87908b;
  --red: #b63d32;
  --red-lg: #f7ded8;
  --line: #d6d2c7;
  --shadow: 0 1px 0 rgba(23,32,29,.08);
  --shadow-lg: 0 16px 40px rgba(23,32,29,.14);
  --r: 9px;
  --r-lg: 13px;
}
body {
  background:
    linear-gradient(rgba(23,32,29,.035) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--bg);
  letter-spacing: .005em;
}
.app-shell { max-width: 520px; padding-inline: 18px; }
.app-header { height: 76px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.title-block p { color: var(--green); font-size: .62rem; letter-spacing: .2em; }
.title-block h1 { font-family: Georgia, "Yu Mincho", serif; font-size: 1.72rem; font-weight: 600; letter-spacing: -.04em; }
.menu-btn { background: transparent; border: 1px solid var(--line); box-shadow: none; border-radius: 50%; }
.card { border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px; }
.input-card { position: relative; overflow: hidden; border-top: 4px solid var(--green-dk); }
.input-card::before { content: "MEAL ENTRY"; display: block; margin-bottom: 14px; color: var(--text3); font-size: .62rem; font-weight: 800; letter-spacing: .18em; }
.card-label { color: var(--text); font-family: Georgia, "Yu Mincho", serif; font-size: 1.02rem; letter-spacing: -.02em; }
input, textarea, select { background: #f7f4ed; border: 1px solid transparent; border-bottom-color: #cbc6ba; border-radius: 7px; font-weight: 550; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,85,.12); }
textarea { min-height: 112px; }
.meal-types { background: transparent; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; gap: 0; margin-bottom: 14px; }
.meal-type { border-radius: 0; padding: 9px 4px; color: var(--text3); }
.meal-type.active { color: var(--green-dk); background: transparent; box-shadow: inset 0 -3px var(--green); }
.chip-row { gap: 6px; }
.chip { background: transparent; border: 1px solid #c9c4b8; color: var(--text2); border-radius: 999px; }
.ghost-sm { color: var(--green-dk); }
.primary { background: var(--green-dk); border-radius: 7px; box-shadow: 3px 3px 0 #9db8aa; letter-spacing: .04em; }
.primary:hover { background: var(--green); }
.primary:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 #9db8aa; }
.ghost, .secondary { border: 1px solid var(--line); background: transparent; }
.number-grid label { background: #f7f4ed; border: 1px solid var(--line); border-radius: 8px; }
.number-grid label input { background: transparent; border: 0; box-shadow: none; }
.date-card { background: var(--green-dk); color: #f8f4e9; border: 0; box-shadow: 4px 4px 0 #a9bdb4; }
.date-card input, .date-card button { color: inherit; }
.date-card input { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); }
.day-total em, .muted-label { color: inherit; opacity: .65; }
.add-btn { background: #e6bb58; color: #17201d !important; border-radius: 50%; box-shadow: none; }
.gbar { border-bottom: 1px solid var(--line); padding-block: 12px; }
.gbar:last-child { border-bottom: 0; }
.gbar-track { height: 7px; background: #e3ded3; }
.gbar-fill { border-radius: 0; }
.record { border: 1px solid var(--line); border-left: 3px solid var(--green); box-shadow: none; background: #fffdf8; }
.bottom-tabs { bottom: calc(10px + var(--safe)); background: rgba(20,31,27,.96); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; box-shadow: 0 12px 32px rgba(10,20,16,.28); backdrop-filter: blur(12px); }
.tab { color: #9eaaa5; border-radius: 7px; }
.tab-icon { font-family: Georgia, serif; font-size: 1.15rem; }
.tab.active { background: #f2ead9; color: var(--green-dk); }
.period-tabs { background: #e8e3d8; }
.period-tab.active { background: var(--green-dk); }
.drawer > summary { font-family: Georgia, "Yu Mincho", serif; }
.sheet-panel { background: var(--surface); border-radius: 18px 18px 0 0; border-top: 4px solid var(--green-dk); }
.toast { background: #17201d; border: 1px solid rgba(255,255,255,.18); }
.error { border-radius: 7px; border-left: 4px solid var(--red); }
.info-note { background: #e7eee9; border: 1px solid #bdd0c5; color: var(--green-dk); }
canvas { filter: saturate(.72); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #e6bb58; outline-offset: 2px; }
@media (min-width: 700px) {
  body { background-color: #ded9ce; }
  .app-shell { max-width: 920px; padding-inline: 28px; }
  .app-header { height: 88px; }
  .panel.active { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .panel.active > * { min-width: 0; margin-bottom: 0; }
  #tab-input .input-card { grid-column: auto; }
  #tab-input:has(#result.hidden) .input-card { grid-column: 1 / -1; max-width: 620px; width: 100%; justify-self: center; }
  #tab-records .date-card,
  #tab-graph .period-card { grid-column: 1 / -1; }
  #tab-graph > .card:nth-of-type(2) { grid-row: span 2; }
  #tab-body > .card:nth-of-type(2) { grid-row: span 2; }
  .bottom-tabs { width: min(760px, calc(100% - 40px)); }
  .chart-wrap { height: 230px; }
  .sheet-panel { max-width: 680px; left: 50%; transform: translateX(-50%); border-radius: 18px 18px 0 0; }
}
@media (min-width: 1080px) {
  .app-shell { max-width: 1180px; padding: 0 32px 48px 152px; }
  .app-header { height: 104px; }
  .title-block h1 { font-size: 2rem; }
  .panel.active { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
  #tab-input .input-card { grid-column: 1 / 7; }
  #tab-input #result { grid-column: 7 / -1; }
  #tab-records .date-card { grid-column: 1 / -1; }
  #tab-records > .card:nth-of-type(2) { grid-column: 1 / 8; }
  #tab-records > .drawer { grid-column: 8 / -1; }
  #tab-graph .period-card { grid-column: 1 / -1; }
  #tab-graph > .card:nth-of-type(2) { grid-column: 1 / 8; grid-row: span 2; }
  #tab-graph > .card:nth-of-type(3),
  #tab-graph > .card:nth-of-type(4) { grid-column: 8 / -1; }
  #tab-body > .card:nth-of-type(1) { grid-column: 1 / 6; }
  #tab-body > .card:nth-of-type(2) { grid-column: 6 / -1; grid-row: span 3; }
  #tab-body > .drawer { grid-column: 1 / 6; }
  .bottom-tabs {
    left: calc(50% - 558px);
    top: 120px;
    bottom: auto;
    transform: none;
    width: 104px;
    height: auto;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }
  .tab { min-height: 68px; }
  .chart-wrap { height: 270px; }
}
@media (min-width: 1500px) {
  .app-shell { max-width: 1280px; }
  .bottom-tabs { left: calc(50% - 608px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* v11 — unified product UI */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface2: #eef2f6;
  --green: #155eef;
  --green-dk: #004eeb;
  --green-lg: #e8f0ff;
  --amber: #b54708;
  --amber-lg: #fff1dc;
  --text: #101828;
  --text2: #344054;
  --text3: #475467;
  --red: #b42318;
  --red-lg: #fee4e2;
  --line: #d0d5dd;
  --shadow: 0 1px 2px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.16);
  --r: 10px;
  --r-lg: 12px;
}
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
}
.app-header { height: 72px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.title-block p { color: var(--text3); font-size: .6875rem; font-weight: 700; letter-spacing: .12em; }
.title-block h1, .card-label, .drawer > summary { font-family: inherit; }
.title-block h1 { font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; }
.menu-btn { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text2); }
.card { padding: 20px; margin-bottom: 16px; border: 1px solid #e4e7ec; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
.input-card { border-top: 1px solid #e4e7ec; overflow: visible; }
.input-card::before { display: none; }
.card-label { margin-bottom: 16px; color: var(--text); font-size: 1rem; font-weight: 700; letter-spacing: 0; }
.field-row span, label { color: var(--text2); font-size: .875rem; font-weight: 600; }
input, textarea, select { min-height: 48px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: 1rem; font-weight: 400; }
input::placeholder, textarea::placeholder { color: #667085; opacity: 1; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(21,94,239,.14); }
.meal-types { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; padding: 4px; margin-bottom: 16px; border: 0; border-radius: var(--r); background: var(--surface2); }
.meal-type { min-height: 40px; padding: 8px; border-radius: 7px; color: var(--text2); font-size: .875rem; font-weight: 600; }
.meal-type.active { background: var(--surface); color: var(--green-dk); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.chip-row { gap: 8px; }
.chip, .chip-row button { min-height: 36px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text2); font-size: .8125rem; font-weight: 600; }
.primary { min-height: 48px; border-radius: var(--r); background: var(--green); color: #fff; box-shadow: none; font-size: .9375rem; font-weight: 700; letter-spacing: 0; }
.primary:hover { background: var(--green-dk); }
.primary:active { transform: none; box-shadow: none; }
.ghost, .secondary, .ghost-sm { color: var(--green-dk); font-weight: 600; }
.number-grid { gap: 12px; }
.number-grid label { padding: 12px; border: 1px solid #e4e7ec; border-radius: var(--r); background: #f9fafb; }
.number-grid label input { background: var(--surface); }
.number-grid input::placeholder { color:#667085; font-size:.8125rem; font-weight:500; }
.date-card { border: 1px solid #c7d7fe; background: #edf3ff; color: var(--text); box-shadow: none; }
.date-card input { border-color: #b2ccff; background: var(--surface); color: var(--text); }
.day-total em, .muted-label { color: var(--text3); opacity: 1; }
.day-total strong { color: var(--text); font-size: 2rem; font-weight: 750; }
.add-btn { background: var(--green); color: #fff !important; box-shadow: none; }
.gbar { padding-block: 14px; border-bottom-color: #e4e7ec; }
.gbar-track { height: 8px; border-radius: 4px; background: #e4e7ec; }
.gbar-fill { border-radius: 4px; }
.gbar-bot, .gbar-goal, .gbar-tag, .record-sub, .record-meta, .chart-note, .point-detail, .empty, .meal-hint { color: var(--text3); }
.record { padding: 14px; border: 1px solid #e4e7ec; border-left: 1px solid #e4e7ec; border-radius: var(--r); background: var(--surface); }
.record-name { color: var(--text); font-size: .9375rem; font-weight: 650; }
.record-val { color: var(--text); }
.record-acts button { min-width: 44px; min-height: 40px; color: var(--green-dk); }
.drawer > summary { min-height: 52px; color: var(--text); font-size: .9375rem; font-weight: 650; }
.bottom-tabs { background: rgba(255,255,255,.98); border: 1px solid #d0d5dd; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.tab { min-height: 52px; border-radius: 8px; color: var(--text3); font-size: .75rem; font-weight: 600; }
.tab-icon { width: 22px; height: 22px; font-size: 0; }
.tab-icon svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { background: var(--green-lg); color: var(--green-dk); }
.period-tabs { padding: 4px; border-radius: var(--r); background: var(--surface2); }
.period-card { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 12px; }
.period-card .field-row { width: 100%; }
.period-card .period-tabs { width: 100%; }
.period-tab { min-height: 38px; color: var(--text2); }
.period-tab.active { border-radius: 7px; background: var(--surface); color: var(--green-dk); box-shadow: var(--shadow); }
.sheet-panel { border-top: 0; background: var(--surface); }
.error { border: 1px solid #fecdca; border-left: 4px solid var(--red); border-radius: var(--r); background: #fff6f5; color: var(--red); }
.info-note { border: 1px solid #b2ccff; border-radius: var(--r); background: #eff4ff; color: #00359e; }
.status { color: var(--text2); }
.toast { background: #101828; color: #fff; }
.empty-state { display:grid; place-items:center; gap:4px; min-height:120px; padding:24px; text-align:center; color:var(--text2); }
.empty-state b { color:var(--text); font-size:.9375rem; }
.empty-state span { color:var(--text3); font-size:.8125rem; }
.empty-state.compact { min-height:104px; }
.daily-energy { display:grid; gap:10px; padding:4px 0 16px; }
.daily-energy > div:first-child { display:flex; justify-content:space-between; align-items:baseline; gap:16px; }
.daily-energy span { color:var(--text2); font-size:.875rem; font-weight:600; }
.daily-energy strong { color:var(--text); font-size:1.75rem; line-height:1; }
.daily-energy small, .daily-metric small { margin-left:3px; color:var(--text3); font-size:.6875rem; font-weight:600; }
.daily-progress { height:8px; overflow:hidden; border-radius:4px; background:#e4e7ec; }
.daily-progress i { display:block; height:100%; border-radius:inherit; background:var(--green); }
.daily-energy p { margin:0; color:var(--text3); font-size:.75rem; }
.daily-metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.daily-metric { display:grid; gap:3px; min-width:0; padding:12px; border:1px solid #e4e7ec; border-radius:var(--r); background:#f9fafb; }
.daily-metric span { color:var(--text2); font-size:.75rem; font-weight:600; }
.daily-metric strong { color:var(--text); font-size:1.125rem; }
.daily-metric em { color:var(--text3); font-size:.6875rem; font-style:normal; }
.stack-field { display:grid; gap:6px; margin-top:12px; color:var(--text2); font-size:.8125rem; font-weight:600; }
.stack-field input, .stack-field textarea { margin:0; }
.edit-meta { margin-top:12px; }
.edit-meta > summary { min-height:44px; display:flex; align-items:center; color:var(--green-dk); font-size:.875rem; font-weight:650; cursor:pointer; }
@media (min-width:700px){ .sheet-panel { width:min(640px,calc(100% - 40px)); border-radius:16px 16px 0 0; } }
canvas { filter: none; }
.legend-cal { background: #155eef; }
.legend-goal { background: #667085; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(21,94,239,.35); outline-offset: 2px; }
@media (min-width: 1080px) {
  .bottom-tabs { background: var(--surface); }
  .tab { min-height: 68px; }
}
@media (min-width: 700px) {
  .period-card { grid-template-columns: minmax(240px,1fr) 200px; align-items: end; }
}
