*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ────────────────────────────────────────── */
:root {
  --bg:          #f5f3ef;
  --bg-2:        #edeae4;
  --surface:     #ffffff;
  --border:      #e6e0d8;

  --rose:        #c05f58;
  --rose-h:      #a84e48;
  --rose-l:      #faf0ef;
  --rose-grad:   linear-gradient(135deg, #c86460 0%, #d4876a 100%);

  --teal:        #4a9a8c;
  --teal-l:      #e8f5f2;

  --tx:          #1a1614;
  --tx-2:        #6b5f59;
  --tx-3:        #b0a49c;

  --sh-xs: 0 1px 3px rgba(50,30,20,.06);
  --sh-sm: 0 2px 8px rgba(50,30,20,.08), 0 1px 3px rgba(50,30,20,.04);
  --sh-md: 0 6px 24px rgba(50,30,20,.10), 0 2px 6px rgba(50,30,20,.05);
  --sh-lg: 0 12px 40px rgba(50,30,20,.12), 0 4px 12px rgba(50,30,20,.06);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
               'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--tx);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 740px;
  margin: 0 auto;
  padding: 40px 18px 80px;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 32px;
  position: relative;
}

header::before {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--rose-grad);
  border-radius: 99px;
  margin: 0 auto 20px;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  background: var(--rose-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--tx-3);
  letter-spacing: 0.04em;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 2px;
  background: var(--bg-2);
  border-radius: var(--r-lg);
  padding: 4px;
  margin-bottom: 28px;
  box-shadow: inset 0 1px 3px rgba(50,30,20,.08);
  overflow-x: visible;
}

.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 4px;
  border: none;
  border-radius: calc(var(--r-lg) - 4px);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--tx-2);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--tx);
  font-weight: 700;
  box-shadow: var(--sh-sm);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Section spacing ──────────────────────────────────────── */
.input-section, .chart-section, .stats-section, .history-section {
  margin-bottom: 18px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card, .input-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 26px;
  box-shadow: var(--sh-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

/* Subtle top accent line on cards */
.card::before, .input-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.card h2, .input-card h2 {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tx-3);
  margin-bottom: 20px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.sub-heading {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tx-3);
  margin-bottom: 14px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tx-3);
  margin-bottom: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.93rem;
  color: var(--tx);
  background: var(--bg);
  outline: none;
  font-family: inherit;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--rose);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(192,95,88,.12);
}

.form-group input::placeholder { color: var(--tx-3); }

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23b0a49c' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.form-row   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--rose-grad);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.08em;
  font-family: inherit;
  margin-top: 6px;
  box-shadow: 0 4px 16px rgba(192,95,88,.35);
  transition: filter 0.18s, transform 0.1s, box-shadow 0.18s;
}

.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 6px 20px rgba(192,95,88,.42);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 10px rgba(192,95,88,.3);
}

.btn-danger {
  padding: 7px 16px;
  background: transparent;
  color: var(--tx-3);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.18s, color 0.18s;
  letter-spacing: 0.03em;
}

.btn-danger:hover { border-color: var(--rose); color: var(--rose); }

.btn-text {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: inherit;
}

/* ── Messages ─────────────────────────────────────────────── */
.error-msg   { margin-top: 8px; font-size: 0.78rem; color: var(--rose); min-height: 18px; }
.success-msg { margin-top: 8px; font-size: 0.78rem; color: var(--teal); min-height: 18px; }
.hint        { margin-top: 7px; font-size: 0.73rem; color: var(--tx-3); line-height: 1.6; }
.no-data     { text-align: center; font-size: 0.82rem; color: var(--tx-3); padding: 16px 0 6px; }

/* ── Stats ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 18px 12px;
  box-shadow: var(--sh-sm);
  border: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 2px;
  border-radius: 99px;
  background: var(--rose-grad);
  opacity: 0.5;
}

.stat-label {
  font-size: 0.62rem;
  color: var(--tx-3);
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--tx);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 0.66rem;
  color: var(--tx-3);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.stat-value.surplus { color: var(--rose); }
.stat-value.deficit { color: var(--teal); }

/* ── Chart ────────────────────────────────────────────────── */
.chart-wrapper { position: relative; height: 260px; }

/* 横スクロール可能なチャートラッパー */
.chart-scroll-wrap {
  overflow-x: auto;
  overflow-y: visible;
  height: 250px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chart-scroll-wrap::-webkit-scrollbar { height: 4px; }
.chart-scroll-wrap::-webkit-scrollbar-track { background: transparent; }
.chart-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chart-scroll-inner { height: 100%; display: flex; align-items: stretch; }
.chart-scroll-inner canvas { display: block; width: 100% !important; }

/* チャート固定凡例 */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 10px;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  color: var(--tx-2);
  white-space: nowrap;
}

/* 今日ヘッダー */
.today-header {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tx-3);
  letter-spacing: 0.06em;
  text-transform: none;
  margin-bottom: 10px;
}

/* ── Record list ──────────────────────────────────────────── */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-header h2 { margin-bottom: 0; }

.record-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--bg);
}

.record-item:last-child { border-bottom: none; }

.record-date   { font-size: 0.78rem; color: var(--tx-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.record-weight { font-size: 0.95rem; font-weight: 700; color: var(--tx); flex: 1; }
.record-fat    { font-size: 0.76rem; font-weight: 500; color: var(--teal); margin-left: 6px; }

.record-diff {
  font-size: 0.76rem;
  font-weight: 700;
  min-width: 64px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.record-diff.up   { color: var(--rose); }
.record-diff.down { color: var(--teal); }
.record-diff.same { color: var(--tx-3); }

.record-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--border);
  font-size: 0.75rem;
  padding: 4px 7px;
  border-radius: 6px;
  transition: color 0.18s, background 0.18s;
  flex-shrink: 0;
}

.record-delete:hover { color: var(--rose); background: var(--rose-l); }

/* ── Drop zone ────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  margin-bottom: 14px;
  overflow: hidden;
  min-height: 136px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--rose);
  background: var(--rose-l);
}

.drop-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--tx-3);
  text-align: center;
  padding: 28px;
  font-size: 0.82rem;
  line-height: 1.7;
}

.drop-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

#photo-preview {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--r-sm);
  display: block;
}

/* ── Loading ──────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--tx-2);
  padding: 10px 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--bg-2);
  margin: 20px 0;
}

/* ── Meal list ────────────────────────────────────────────── */
.meal-group { margin-bottom: 10px; }

.meal-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
}

.meal-group-date  { font-size: 0.76rem; font-weight: 800; color: var(--tx); letter-spacing: 0.04em; }
.meal-group-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.meal-group-total { font-size: 0.8rem; font-weight: 800; color: var(--rose); font-variant-numeric: tabular-nums; }
.meal-balance {
  font-size: 0.68rem; font-weight: 700; padding: 2px 7px;
  border-radius: 99px; font-variant-numeric: tabular-nums;
}
.meal-balance.under { background: var(--teal-l); color: var(--teal); }
.meal-balance.over  { background: var(--rose-l);  color: var(--rose); }
.meal-balance.ok    { background: var(--teal-l); color: var(--teal); }

.meal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--bg);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  margin: 0 -4px;
}
.meal-item:last-child { border-bottom: none; }
.meal-item:hover  { background: var(--bg); }
.meal-item:active { background: var(--bg-2); }

.meal-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.meal-time      { font-size: 0.7rem; color: var(--tx-3); font-variant-numeric: tabular-nums; }
.meal-name      { font-size: 0.88rem; font-weight: 700; color: var(--tx); }
.meal-memo-text { font-size: 0.72rem; color: var(--tx-2); }

.meal-nutrition { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.meal-cal   { font-size: 0.92rem; font-weight: 800; color: var(--rose); font-variant-numeric: tabular-nums; }
.meal-macro { font-size: 0.68rem; color: var(--tx-3); }

/* ── Nutrient progress bars ──────────────────────────────── */
.nut-date-label { font-size: 0.72rem; color: var(--tx-3); font-weight: 600; }

.nutrient-summary { display: flex; flex-direction: column; gap: 12px; }

.nutrient-row { display: flex; flex-direction: column; gap: 5px; }

.nutrient-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.nutrient-label { font-size: 0.8rem; font-weight: 700; color: var(--tx-2); }

.nutrient-value {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex-shrink: 0;
}
.nutrient-value .cur  { font-weight: 800; color: var(--tx); }
.nutrient-value .sep  { color: var(--tx-3); margin: 0 2px; }
.nutrient-value .tgt  { color: var(--tx-3); }
.nutrient-value .pct  { font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 99px; margin-left: 6px; }
.nutrient-value .pct.ok   { background: var(--teal-l);  color: var(--teal); }
.nutrient-value .pct.warn { background: #fef3e2;         color: #c47d10; }
.nutrient-value .pct.low  { background: var(--rose-l);   color: var(--rose); }
.nutrient-value .pct.over { background: var(--rose-l);   color: var(--rose); }

.nutrient-bar-track {
  height: 6px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}
.nutrient-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}
.nutrient-bar-fill.ok   { background: var(--teal); }
.nutrient-bar-fill.warn { background: #e0a040; }
.nutrient-bar-fill.low  { background: var(--rose); }
.nutrient-bar-fill.over { background: var(--rose); }

/* ── Meal detail bottom sheet ────────────────────────────── */
.meal-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,22,20,0.46);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}
.meal-detail-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.meal-detail-sheet {
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 740px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(env(safe-area-inset-bottom), 24px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}
.meal-detail-overlay.open .meal-detail-sheet {
  transform: translateY(0);
}

.meal-detail-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 12px auto 0;
}

.meal-detail-head {
  padding: 16px 20px 16px;
  border-bottom: 1px solid var(--bg-2);
}
.meal-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.meal-detail-time { font-size: 0.72rem; color: var(--tx-3); font-variant-numeric: tabular-nums; }
.meal-detail-cat  {
  font-size: 0.7rem; font-weight: 700;
  background: var(--bg-2); color: var(--tx-2);
  padding: 2px 9px; border-radius: 99px;
}
.meal-detail-name {
  font-size: 1.0rem; font-weight: 800; color: var(--tx);
  line-height: 1.45;
}
.meal-detail-cal {
  font-size: 1.6rem; font-weight: 800; color: var(--rose);
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}
.meal-detail-cal-unit { font-size: 0.85rem; font-weight: 500; color: var(--tx-3); }

.meal-detail-body { padding: 20px 20px 8px; }
.meal-detail-section-title {
  font-size: 0.68rem; font-weight: 800;
  color: var(--tx-3); letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.meal-nutrient-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}
.meal-nutrient-card {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meal-nutrient-card .nc-label { font-size: 0.66rem; color: var(--tx-3); font-weight: 600; margin-bottom: 2px; }
.meal-nutrient-card .nc-value { font-size: 1.05rem; font-weight: 800; color: var(--tx); font-variant-numeric: tabular-nums; line-height: 1.1; }
.meal-nutrient-card .nc-unit  { font-size: 0.65rem; font-weight: 500; color: var(--tx-3); }
.meal-nutrient-card .nc-pct   { font-size: 0.65rem; font-weight: 700; margin-top: 4px; }
.meal-nutrient-card .nc-pct.ok   { color: var(--teal); }
.meal-nutrient-card .nc-pct.warn { color: #c47d10; }
.meal-nutrient-card .nc-pct.low  { color: var(--rose); }

/* ── Chat UI ──────────────────────────────────────────────── */
.chat-card { padding: 0; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--bg-2);
}

.chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--rose-grad);
  box-shadow: 0 3px 10px rgba(192,95,88,.30);
}

.chat-header-text { display: flex; flex-direction: column; gap: 1px; }
.chat-header-title { font-size: 0.88rem; font-weight: 700; color: var(--tx); }
.chat-header-sub   { font-size: 0.7rem; color: var(--tx-3); }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 180px;
  max-height: 380px;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg);
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-row.user { flex-direction: row-reverse; }

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--rose-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(192,95,88,.25);
  padding: 5px;
}

.chat-avatar svg { width: 100%; height: 100%; }

.chat-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.7;
}

.chat-row.assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--tx);
  border-bottom-left-radius: 5px;
  box-shadow: var(--sh-xs);
}

.chat-row.user .chat-bubble {
  background: var(--rose-grad);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 3px 12px rgba(192,95,88,.30);
}

.chat-row.loading .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  box-shadow: var(--sh-xs);
}

.typing-dots { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--tx-3);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-example { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chat-example-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--tx-2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.73rem;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.18s, color 0.18s, box-shadow 0.18s;
}

.chat-example-chip:hover {
  border-color: var(--rose);
  color: var(--rose);
  box-shadow: 0 2px 8px rgba(192,95,88,.15);
}

/* Result card inside bubble */
.chat-weight-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--teal-l);
  color: var(--teal);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.chat-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 12px;
  margin-top: 10px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: var(--sh-xs);
}

.chat-result-name { font-weight: 800; color: var(--tx); font-size: 0.9rem; margin-bottom: 10px; }

.chat-result-macros {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 4px;
  margin-bottom: 12px;
}

.macro-chip {
  background: var(--bg);
  border-radius: 8px;
  padding: 7px 2px;
  text-align: center;
  min-width: 0;
}

.macro-chip .macro-val   { display: block; font-size: 0.85rem; font-weight: 800; color: var(--tx); white-space: nowrap; }
.macro-chip .macro-label { display: block; font-size: 0.58rem; color: var(--tx-3); margin-top: 1px; letter-spacing: 0.02em; white-space: nowrap; }
.macro-chip:first-child .macro-val { color: var(--rose); }
.macro-chip .macro-val.teal { color: var(--teal); }

.chat-result-actions { display: flex; gap: 7px; }

.btn-save-chat {
  flex: 1;
  padding: 9px;
  background: var(--rose-grad);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  box-shadow: 0 3px 10px rgba(192,95,88,.30);
  transition: filter 0.18s;
}

.btn-save-chat:hover { filter: brightness(1.06); }

.btn-discard-chat {
  padding: 9px 14px;
  background: transparent;
  color: var(--tx-3);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.18s;
}

.btn-discard-chat:hover { color: var(--tx); }

/* Input bar */
/* Photo attach preview above input */
.photo-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 0;
}
.photo-attach-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
}
.photo-remove-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tx-2);
  color: #fff;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--bg-2);
}

/* Pill wrapping attach-btn + text input */
.chat-input-pill {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--bg);
  transition: border-color 0.18s, background 0.18s;
  overflow: hidden;
}
.chat-input-pill:focus-within {
  border-color: var(--rose);
  background: var(--surface);
}

.chat-attach-btn {
  width: 40px;
  height: 44px;
  background: transparent;
  color: var(--tx-3);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.18s;
}
.chat-attach-btn:hover { color: var(--rose); }

.chat-input-pill input {
  flex: 1;
  padding: 10px 14px 10px 0;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  color: var(--tx);
  outline: none;
  font-family: inherit;
}
.chat-input-pill input::placeholder { color: var(--tx-3); }

/* Photo thumbnail in chat bubble */
.chat-photo-thumb {
  display: block;
  max-width: 200px;
  max-height: 160px;
  border-radius: var(--r-sm);
  object-fit: cover;
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  background: var(--rose-grad);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(192,95,88,.30);
  transition: filter 0.18s;
}

.chat-send-btn:hover { filter: brightness(1.08); }
.chat-send-btn:disabled { background: var(--bg-2); box-shadow: none; cursor: not-allowed; }

/* ── Activity ─────────────────────────────────────────────── */
.activity-stats { grid-template-columns: repeat(4, 1fr); }

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg);
}

.activity-item:last-child { border-bottom: none; }

.activity-info  { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.activity-name  { font-size: 0.88rem; font-weight: 700; color: var(--tx); }
.activity-meta  { font-size: 0.72rem; color: var(--tx-3); }
.activity-cal   { font-size: 0.92rem; font-weight: 800; color: var(--teal); flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ── Coach tab ────────────────────────────────────────────── */
.goal-card { padding-bottom: 22px; }

.goal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.goal-header h2 { margin-bottom: 0; }

.goal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.goal-item {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.goal-label { font-size: 0.62rem; color: var(--tx-3); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.goal-value { font-size: 1.05rem; font-weight: 800; color: var(--tx); }

.goal-memo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--rose-l);
  border-radius: var(--r-sm);
  margin-top: 8px;
  border-left: 3px solid var(--rose);
}

.goal-memo-text { font-size: 0.84rem; color: var(--rose); font-weight: 600; }

.progress-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.progress-label { font-size: 0.7rem; font-weight: 700; color: var(--tx-3); letter-spacing: 0.08em; text-transform: uppercase; }
.progress-pct   { font-size: 0.84rem; font-weight: 800; color: var(--rose); }

.progress-bar-bg {
  height: 7px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--rose-grad);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(.34,1.56,.64,1);
}

.progress-sub { font-size: 0.8rem; color: var(--tx-2); margin-top: 6px; }

.coach-chat-card { padding: 0; }

.coach-icon {
  background: linear-gradient(135deg, var(--teal) 0%, #7abfb0 100%) !important;
  box-shadow: 0 3px 10px rgba(74,154,140,.30) !important;
}

.coach-messages { min-height: 260px; max-height: 460px; }

.coach-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 14px 18px;
  border-top: 1px solid var(--bg-2);
  background: var(--bg);
}

/* フローティングチャット内では横スクロール1行に */
.float-chat-sheet .coach-messages {
  max-height: none;  /* flex:1 を妨げる max-height を解除 */
}
.float-chat-sheet .coach-quick-btns {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 16px;
  gap: 8px;
}
.float-chat-sheet .coach-quick-btns::-webkit-scrollbar { display: none; }
.float-chat-sheet .quick-btn { flex-shrink: 0; }

.quick-btn {
  padding: 7px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tx-2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
  white-space: nowrap;
}

.quick-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-l);
  box-shadow: 0 2px 8px rgba(74,154,140,.15);
}

.coach-bubble-content { white-space: pre-wrap; }

/* ── Markdown レンダリング（AIコーチ吹き出し内） ─────────── */
.coach-bubble-content.md {
  white-space: normal;
  line-height: 1.65;
}
.coach-bubble-content.md p          { margin: 0 0 8px; }
.coach-bubble-content.md p:last-child { margin-bottom: 0; }
.coach-bubble-content.md strong     { font-weight: 700; color: var(--tx); }
.coach-bubble-content.md em         { font-style: italic; }
.coach-bubble-content.md ul,
.coach-bubble-content.md ol         { margin: 6px 0 8px; padding-left: 18px; }
.coach-bubble-content.md li         { margin-bottom: 3px; }
.coach-bubble-content.md h1,
.coach-bubble-content.md h2,
.coach-bubble-content.md h3         { font-size: 0.88rem; font-weight: 700; margin: 10px 0 4px; color: var(--tx); }
.coach-bubble-content.md code       {
  font-family: monospace; font-size: 0.82em;
  background: rgba(0,0,0,0.07); border-radius: 3px; padding: 1px 5px;
}
.coach-bubble-content.md pre        {
  background: rgba(0,0,0,0.06); border-radius: 6px;
  padding: 10px 12px; overflow-x: auto; margin: 8px 0;
}
.coach-bubble-content.md pre code   { background: none; padding: 0; }
.coach-bubble-content.md table      {
  border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.78rem;
}
.coach-bubble-content.md th,
.coach-bubble-content.md td         {
  border: 1px solid var(--border); padding: 5px 10px; text-align: left;
}
.coach-bubble-content.md th         { background: var(--bg-2); font-weight: 700; }
.coach-bubble-content.md blockquote {
  border-left: 3px solid var(--border); margin: 6px 0;
  padding: 4px 12px; color: var(--tx-2);
}
.coach-bubble-content.md hr         { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ── Clinic connected badge ───────────────────────────────── */
.clinic-connected-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--teal-l);
  border: 1px solid rgba(74,154,140,0.25);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--teal);
}

/* ── Desktop / PC layout ─────────────────────────────────── */
@media (min-width: 640px) {
  /* タブを均等割り付け（PC） */
  .tab-btn {
    font-size: 0.85rem;
    padding: 10px 12px;
  }

  /* コンテナ余白を広げて読みやすく */
  .container {
    padding: 48px 32px 96px;
  }

  /* ヘッダーを少し大きく */
  header h1 { font-size: 2.4rem; }

  /* カードを横に並べるグリッド */
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .activity-stats { grid-template-columns: repeat(4, 1fr); }
  .goal-grid { grid-template-columns: repeat(4, 1fr); }

  /* 食事・活動の入力フォームを2列に */
  .form-row { grid-template-columns: 1fr 1fr; }

  /* チャット吹き出し最大幅 */
  .chat-bubble { max-width: 480px; }

  /* フローティングボタン位置をコンテナ右端に近づける */
  .float-chat-wrap {
    right: max(24px, calc((100vw - 740px) / 2 - 20px));
  }

  /* チャットパネルをデスクトップ向け：丸みをつけてやや高めに */
  .float-chat-sheet {
    border-radius: 22px;
    height: 84vh;
    margin-bottom: 24px;
  }
  .float-chat-panel {
    align-items: flex-end;
    padding-bottom: 0;
  }
  .float-chat-drag-handle { display: none; }
  .float-chat-sheet .chat-messages { padding: 20px 28px; }
  .float-chat-sheet .coach-quick-btns { padding: 8px 24px 6px; }
  .float-chat-header { padding: 14px 24px; }
  .float-input-bar { padding: 10px 24px max(env(safe-area-inset-bottom), 14px); }
  .chat-bubble { max-width: 72%; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 560px) {
  /* コンテナ余白を縮小 */
  .container { padding: 20px 12px 80px; }

  /* ヘッダー */
  header { margin-bottom: 20px; }
  header h1 { font-size: 1.7rem; }

  /* タブ：スクロール式なので縮小不要 */
  .tab-nav { padding: 3px; gap: 2px; }
  .tab-btn { font-size: 0.75rem; padding: 9px 12px; }

  /* グリッド系 */
  .stats-grid, .activity-stats { grid-template-columns: repeat(2, 1fr); }
  .form-row   { grid-template-columns: 1fr; }
  .form-row-4 { grid-template-columns: repeat(2, 1fr); }
  .goal-grid  { grid-template-columns: repeat(2, 1fr); }

  /* チャット結果マクロ：4列→2列 */
  .chat-result-macros { grid-template-columns: repeat(2, 1fr); }

  /* 記録アイテムの日付が折り返さないよう調整 */
  .record-item { flex-wrap: wrap; gap: 4px; }
  .record-date { font-size: 0.72rem; }

  /* 食事アイテム */
  .meal-item { flex-wrap: wrap; }
  .meal-nutrition { min-width: 60px; }

  /* チャット吹き出し */
  .chat-bubble { max-width: 82vw; }
  .chat-photo-thumb { max-width: 160px; }

  /* カード内余白を少し縮小 */
  .card, .input-card { padding: 16px 14px; }

  /* 入力フォーム */
  input[type="number"], input[type="date"], input[type="text"], select {
    font-size: 16px; /* iOSのズームを防ぐ */
  }
}

/* ── Clinic selector (AI tab) ─────────────────────────────── */
.clinic-selector-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tx-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.clinic-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.clinic-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tx-2);
}

.clinic-pill:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.clinic-pill.active {
  border-color: var(--teal);
  background: var(--teal-l);
  color: var(--teal);
}

.clinic-pill-goal {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--tx-3);
  margin-top: 2px;
}

.clinic-pill.active .clinic-pill-goal {
  color: var(--teal);
  opacity: 0.75;
}

/* ── Clinic list (settings tab) ──────────────────────────── */
.clinic-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.clinic-list-item:last-child { border-bottom: none; }

.clinic-list-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clinic-list-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--tx);
}

.clinic-list-goal {
  font-size: 0.72rem;
  color: var(--tx-3);
}

/* ═══════════════════════════════════════════════════════════
   フローティングAIチャット
   ══════════════════════════════════════════════════════════ */

/* FABラッパー（ラベル＋ボタンをまとめて揺らす） */
.float-chat-wrap {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: fab-attention 7s ease-in-out 3s infinite;
}
.float-chat-wrap:hover { animation: none; }

/* ラベルタグ */
.float-chat-label-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--rose);
  background: var(--surface);
  padding: 3px 10px;
  border-radius: 99px;
  box-shadow: 0 2px 8px rgba(50,30,20,0.12);
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

/* 円形ボタン */
.float-chat-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--rose-grad);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(192,95,88,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.2s;
  animation: fab-glow 3s ease-in-out infinite;
}
.float-chat-btn:hover  { transform: scale(1.07); box-shadow: 0 6px 26px rgba(192,95,88,0.58); }
.float-chat-btn:active { transform: scale(0.95); }

/* グロー：ふわっと光る */
@keyframes fab-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(192,95,88,0.42); }
  50%       { box-shadow: 0 6px 28px rgba(192,95,88,0.62), 0 0 0 7px rgba(192,95,88,0.10); }
}

/* アテンション：定期的にぴょこっと揺れる */
@keyframes fab-attention {
  0%, 80%, 100% { transform: translateY(0) rotate(0deg); }
  82%  { transform: translateY(-5px) rotate(-5deg); }
  85%  { transform: translateY(-3px) rotate(4deg); }
  88%  { transform: translateY(-4px) rotate(-3deg); }
  91%  { transform: translateY(-1px) rotate(2deg); }
  94%  { transform: translateY(-2px) rotate(-1deg); }
  97%  { transform: translateY(0) rotate(0deg); }
}

/* パネル背景 */
.float-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.float-chat-panel.open {
  pointer-events: auto;
  opacity: 1;
}

.float-chat-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(2px);
}

/* ボトムシート */
.float-chat-sheet {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 740px;
  height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 40px rgba(50,30,20,0.2);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1);
}
.float-chat-panel.open .float-chat-sheet {
  transform: translateY(0);
}

/* ドラッグハンドル */
.float-chat-drag-handle {
  width: 38px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 2px;
  flex-shrink: 0;
}

/* ヘッダー */
.float-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.float-chat-header-left  { display: flex; align-items: center; gap: 10px; }
.float-chat-header-right { display: flex; align-items: center; gap: 8px; }

.float-chat-title-area .float-chat-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--tx);
}
.float-chat-title-area .float-chat-sub {
  font-size: 0.7rem;
  color: var(--tx-3);
}

.float-chat-close {
  width: 30px;
  height: 30px;
  border: none;
  background: var(--bg-2);
  border-radius: 50%;
  color: var(--tx-2);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.float-chat-close:hover { background: var(--border); }

/* クリニック選択 */
.float-clinic-wrap {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* 今日のサマリー（コンパクト1行バー） */
.chat-today-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
  font-size: 0.75rem;
  color: var(--tx-2);
  font-variant-numeric: tabular-nums;
}
.chat-today-item strong { color: var(--tx); font-weight: 700; }
.chat-today-sep { color: var(--tx-3); }
.chat-today-balance { margin-left: auto; font-weight: 700; }
.chat-today-balance .surplus { color: var(--rose); }
.chat-today-balance .deficit { color: var(--teal); }

/* メッセージエリア（スクロール） */
.float-chat-sheet .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}

/* クイックボタン */
.float-chat-sheet .coach-quick-btns {
  padding: 6px 12px 4px;
  flex-shrink: 0;
}

/* 入力バー */
.float-input-bar {
  padding: 8px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* 食事記録の写真サムネイル */
.meal-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}

.meal-macro-sub {
  font-size: 0.72rem;
  color: var(--tx-3);
  margin-top: 2px;
}

/* 食事アイテムのレイアウト調整（サムネ対応） */
.meal-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.meal-item .meal-info {
  flex: 1;
}
.meal-item .meal-nutrition {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

/* ── Goal nutrient chips ─────────────────────────────────────── */
.goal-nutrients-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.goal-nutrient-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--teal-l);
  border: 1px solid rgba(74,154,140,0.2);
  border-radius: 99px;
  font-size: 0.72rem;
}

.gnc-label {
  color: var(--teal);
  font-weight: 700;
}

.gnc-value {
  color: var(--tx);
  font-weight: 600;
}

/* ── Goal nutrient details/summary ─────────────────────────── */
.goal-nutrients-details {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 14px;
  margin: 12px 0;
}

.goal-nutrients-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tx-2);
  cursor: pointer;
  list-style: none;
}

.goal-nutrients-summary::-webkit-details-marker { display: none; }

.goal-nutrients-details[open] .goal-nutrients-summary {
  border-bottom: 1px solid var(--border);
}

.goal-nutrients-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--tx-3);
  padding: 3px 10px;
  border-radius: 99px;
}

.goal-nutrients-details .form-row {
  padding: 10px 0 4px;
}

/* ── Blood test status grid ──────────────────────────────────── */
.blood-status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.blood-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bsc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.bsc-label {
  font-size: 0.7rem;
  color: var(--tx-3);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.bsc-badge {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.bsc-badge.good { background: #e6f4f1; color: #2a7a6c; }
.bsc-badge.warn { background: #fef6e2; color: #7a6400; }
.bsc-badge.bad  { background: #fdf0ef; color: #963838; }
.bsc-badge.none { background: var(--bg-2); color: var(--tx-3); }

.bsc-value-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.bsc-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--tx);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bsc-unit {
  font-size: 0.6rem;
  color: var(--tx-3);
  font-weight: 400;
}

.bsc-bar-bg {
  height: 3px;
  background: var(--bg-2);
  border-radius: 99px;
  margin-top: 7px;
  overflow: hidden;
}

.bsc-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

.bsc-range {
  font-size: 0.66rem;
  color: var(--tx-3);
  margin-top: 4px;
  line-height: 1.5;
}

.bsc-trend {
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 6px;
  white-space: nowrap;
}

/* ── details / summary ───────────────────────────────────────── */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.details-summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--tx-2);
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.details-summary::before {
  content: '▶';
  font-size: 0.6rem;
  color: var(--tx-3);
  transition: transform 0.2s;
  display: inline-block;
}
details[open] > .details-summary::before {
  transform: rotate(90deg);
}

/* ── Blood photo button ──────────────────────────────────────── */
.btn-blood-photo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--tx-2);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-blood-photo:hover { border-color: var(--teal); color: var(--teal); }
.btn-blood-photo:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Supplement reminder banner ──────────────────────────────── */
.supp-reminder-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fef7e3;
  border: 1px solid #e8c84e;
  border-left: 3px solid #c8961e;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #7a6400;
}

.supp-reminder-close {
  background: none;
  border: none;
  font-size: 0.74rem;
  color: #7a6400;
  cursor: pointer;
  padding: 0 0 0 8px;
  font-family: inherit;
  opacity: 0.7;
  flex-shrink: 0;
}
.supp-reminder-close:hover { opacity: 1; }

/* ── Blood history ───────────────────────────────────────────── */
.blood-hist-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.blood-hist-row:last-child {
  border-bottom: none;
}

.blood-hist-date {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tx-2);
  margin-bottom: 6px;
}

.blood-hist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.blood-hist-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 3px 9px;
  border: 1px solid;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
}

.blood-hist-chip small {
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.8;
}

.blood-hist-note {
  font-size: 0.72rem;
  color: var(--tx-3);
  margin-top: 5px;
}

/* ── Supplement check ────────────────────────────────────────── */
.supp-check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.supp-check-row:last-child {
  border-bottom: none;
}

.supp-check-row:hover {
  background: var(--bg-2);
}

.supp-check-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
  transition: all 0.2s;
}

.supp-check-icon.checked {
  background: var(--teal);
  border-color: var(--teal);
}

.supp-check-info {
  flex: 1;
}

.supp-check-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--tx);
}

.supp-check-dose {
  font-size: 0.72rem;
  color: var(--tx-3);
  margin-top: 1px;
}

.supp-check-status {
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Nurse messages (patient app) ────────────────────────────── */
.badge-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--rose);
  color: white;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
}

.nurse-msg-card {
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
}

.nurse-msg-card.unread {
  background: var(--teal-l);
  border-color: rgba(74,154,140,0.3);
}

.nurse-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.nurse-msg-from {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal);
}

.nurse-msg-date {
  font-size: 0.7rem;
  color: var(--tx-3);
}

.nurse-msg-body {
  font-size: 0.85rem;
  color: var(--tx);
  line-height: 1.6;
}

/* ── Nurse sent card (portal) ────────────────────────────────── */
.nurse-sent-card {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
}

.nurse-sent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.nurse-sent-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--teal);
}

.nurse-sent-date {
  font-size: 0.7rem;
  color: var(--tx-3);
}

.nurse-sent-body {
  font-size: 0.82rem;
  color: var(--tx-2);
  line-height: 1.5;
}

/* ── 歯茎健康スコア ─────────────────────────────────────────── */
.oral-score-card { background: linear-gradient(135deg, #f9f5f2 0%, #fff 100%); }
.oral-score-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.oral-score-circle {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--rose-grad);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
#oral-score-value { font-size: 1.6rem; font-weight: 900; color: #fff; line-height: 1; }
.oral-score-unit  { font-size: 0.65rem; color: rgba(255,255,255,0.85); margin-top: 1px; }
.oral-score-bars  { display: flex; flex-direction: column; gap: 10px; }
.osb-row { display: flex; flex-direction: column; gap: 4px; }
.osb-meta { display: flex; justify-content: space-between; font-size: 0.75rem; }
.osb-label { color: var(--tx-2); font-weight: 600; }
.osb-val   { color: var(--tx-3); }
.osb-track { height: 7px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.osb-fill  { height: 100%; border-radius: 99px; transition: width 0.6s ease; background: var(--rose-grad); }
.osb-fill.ok   { background: linear-gradient(90deg, #4a9a8c, #5fbfad); }
.osb-fill.warn { background: linear-gradient(90deg, #e8a84a, #f0c070); }
.osb-fill.low  { background: var(--rose-grad); }
.oral-score-msg { font-size: 0.78rem; color: var(--tx-3); margin: 14px 0 0; line-height: 1.6; text-align: center; }

/* ── 手動食事入力 ─────────────────────────────────────── */
.btn-add-meal {
  font-size: 0.78rem; font-weight: 600; padding: 5px 12px;
  background: var(--rose-grad); color: #fff; border: none;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: opacity .15s;
}
.btn-add-meal:hover { opacity: .85; }
.manual-label {
  display: block; font-size: 0.72rem; color: var(--tx-3);
  font-weight: 600; margin-bottom: 5px;
}
.manual-meal-type-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.mtype-btn {
  flex: 1; min-width: 60px; padding: 8px 4px;
  font-size: 0.82rem; font-weight: 600;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--tx-2); cursor: pointer;
  transition: all .15s;
}
.mtype-btn.active {
  background: var(--rose-grad); color: #fff; border-color: transparent;
}

/* ── 音声入力ボタン ───────────────────────────────────── */
.voice-btn { margin-left: 2px; }
.voice-btn.recording {
  color: #e05;
  animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.15); }
}

/* ── 撮影ガイド ───────────────────────────────────────── */
.photo-guide-tip {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 14px; background: var(--bg); border-radius: 12px;
}
.photo-guide-icon { font-size: 1.4rem; flex-shrink: 0; }
.photo-guide-title { font-size: 0.88rem; font-weight: 700; color: var(--tx); margin-bottom: 2px; }
.photo-guide-desc  { font-size: 0.75rem; color: var(--tx-3); line-height: 1.5; }
