/* ══════════════════════════════════════════════════════════
   デザイントークン
   方向: 淡いブルーの背景、余白を取ったカード、選択中を示す青い面。
   人の識別は系列色、操作の状態はアクセント色で示す。
   確定値の説明は docs/design.md
   ══════════════════════════════════════════════════════════ */
:root {
  color-scheme: light;

  /* 面 */
  --page:            #f2f5fb;
  --surface:         #ffffff;
  --surface-sunken:  #edf2fa;
  --soft: #e6eefe;
  --hero: #dfeafb;
  --content-width: 760px;
  --nav-height: 80px;

  /* 文字 */
  --text-primary:    #182b48;
  --text-secondary:  #5c6b80;
  --text-muted:      #66768b;

  /* 線 */
  --grid:            #e2e8f1;
  --axis:            #b0bed0;
  --border:          rgba(11, 11, 11, 0.10);

  /* 意味を持つ色 */
  --accent:          #2458b9;
  --accent-ink:      #ffffff;
  --danger:          #d03b3b;
  --success:         #006300;

  /* グラフの系列色（8色固定・色覚多様性検証済み / src/colors.js 参照） */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* 余白（4の倍数で5段階） */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;  --s5: 24px;
  --gutter: 16px;

  /* 角丸 */
  --r1: 16px;  --r2: 24px;

  /* 文字サイズ */
  --fs-title: 28px;
  --fs-body:  15px;
  --fs-sub:   13px;
  --fs-num:   48px;
  --fs-input: 16px;

  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:            #111722;
    --surface:         #1b2431;
    --surface-sunken:  #243043;
  --soft: #293b57;
  --hero: #233755;
    --text-primary:    #ffffff;
    --text-secondary:  #b0bed0;
    --text-muted:      #b0bed0;
    --grid:            #334155;
    --axis:            #53657f;
    --border:          rgba(255, 255, 255, 0.10);
    --accent:          #aac6ff;
    --accent-ink:      #111722;
    --danger:          #e66767;
    --success:         #8dd9bd;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:            #111722;
  --surface:         #1b2431;
  --surface-sunken:  #243043;
  --soft: #293b57;
  --hero: #233755;
  --text-primary:    #ffffff;
  --text-secondary:  #b0bed0;
  --text-muted:      #b0bed0;
  --grid:            #334155;
  --axis:            #53657f;
  --border:          rgba(255, 255, 255, 0.10);
  --accent:          #aac6ff;
  --accent-ink:      #111722;
  --danger:          #e66767;
  --success:         #8dd9bd;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

/* ══ ベース ═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--page);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p, ul, figure { margin: 0; }
ul { list-style: none; padding: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r1);
}

[hidden] { display: none !important; }

/* ══ 画面の枠 ═════════════════════════════════════════════ */
.screen { min-height: 100dvh; }

#app-screen {
  /* タブバー + ホームバーの分だけ本文の下に余白を作る */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + var(--s5));
}

.view {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s4) var(--gutter) 0;
}

.view-head { margin-bottom: var(--s4); }
.view-title { font-size: var(--fs-title); font-weight: 600; letter-spacing: 0.01em; }
.view-sub { font-size: var(--fs-sub); color: var(--text-secondary); margin-top: 2px; }

.section-title {
  font-size: var(--fs-sub);
  font-weight: 600;
  color: var(--text-secondary);
  margin: var(--s5) 0 var(--s2);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: var(--s4);
}

.rule { border: 0; border-top: 1px solid var(--border); margin: var(--s4) 0; }

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-top: var(--s3);
}

.stamp { font-size: 12px; color: var(--text-muted); }

.stack { display: flex; flex-direction: column; gap: var(--s3); }

/* ══ フォーム ═════════════════════════════════════════════ */
.form { display: flex; flex-direction: column; gap: var(--s4); }
.form fieldset { border: 0; margin: 0; padding: 0; }

.field { display: flex; flex-direction: column; gap: var(--s1); }
.field-label { font-size: var(--fs-sub); font-weight: 600; color: var(--text-secondary); }
.field-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.field input,
.field select,
.inline-row input {
  min-height: var(--tap);
  padding: 0 var(--s3);
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--axis);
  border-radius: var(--r1);
  width: 100%;
}
.field input:focus,
.field select:focus { border-color: var(--accent); }

.inline-row { display: flex; gap: var(--s2); align-items: center; }
.inline-row input { flex: 1; min-width: 0; }

.form-error {
  font-size: var(--fs-sub);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-radius: var(--r1);
  padding: var(--s2) var(--s3);
}

.ok-msg { font-size: var(--fs-sub); color: var(--success); text-align: center; }
.hint { font-size: 12px; color: var(--text-muted); text-align: center; }

/* ══ ボタン ═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r1);
  border: 1px solid transparent;
  background: none;
  font-size: var(--fs-body);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-lg { width: 100%; min-height: 52px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-quiet {
  border-color: var(--axis);
  color: var(--text-primary);
  background: var(--surface);
  font-weight: 500;
}

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ══ セグメント切替 ═══════════════════════════════════════ */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s1);
  padding: var(--s1);
  background: var(--surface-sunken);
  border-radius: var(--r1);
  margin-bottom: var(--s4);
}
.segmented-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }

.seg-btn {
  min-height: 40px;
  border: 0;
  border-radius: calc(var(--r1) - 2px);
  background: none;
  color: var(--text-secondary);
  font-size: var(--fs-sub);
  font-weight: 600;
  cursor: pointer;
}
.seg-btn.is-on { background: var(--surface); color: var(--text-primary); }

/* ══ ログイン画面 ═════════════════════════════════════════ */
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--s5) var(--gutter) var(--s5);
}
.auth-title { font-size: 24px; font-weight: 600; text-align: center; }
.auth-lead {
  font-size: var(--fs-sub);
  color: var(--text-secondary);
  text-align: center;
  margin: var(--s2) 0 var(--s5);
}

/* ══ 色えらび ═════════════════════════════════════════════ */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s2);
}
.color-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-height: var(--tap);
  padding: var(--s2) 0;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: var(--surface);
  cursor: pointer;
}
.color-cell[aria-pressed="true"] { border-color: var(--text-primary); border-width: 2px; }
.color-cell:disabled { opacity: 0.35; cursor: default; }
.color-dot { width: 20px; height: 20px; border-radius: 50%; }
.color-name { font-size: 11px; color: var(--text-secondary); }

/* ══ 自分の現在地（統計タイル）════════════════════════════ */
.stat-tile {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0 var(--s3);
  margin-bottom: var(--s3);
  padding: var(--s3) var(--s4);
}
.stat-label { font-size: var(--fs-sub); color: var(--text-secondary); }
.stat-value {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-size: 36px;
  font-weight: 600;
  /* 大きな単独の数字なので tabular-nums にしない */
}
.stat-unit { font-size: var(--fs-sub); font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.stat-delta { font-size: 12px; color: var(--text-secondary); }
.stat-delta.is-good { color: var(--success); }

/* ══ 凡例 兼 フィルタ ═════════════════════════════════════ */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
}
.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 36px;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--fs-sub);
  color: var(--text-primary);
  cursor: pointer;
}
/* 44px のタップ領域を見た目を太らせずに確保する */
.legend-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
}
.legend-btn { position: relative; }
.legend-btn[aria-pressed="false"] { color: var(--text-muted); border-style: dashed; }
.legend-btn[aria-pressed="false"] .legend-key { opacity: 0.3; }
.legend-btn:disabled { opacity: 0.5; cursor: default; }

/* 線グラフの凡例なので、四角ではなく線で示す */
.legend-key { width: 16px; height: 3px; border-radius: 2px; flex: none; }
.legend-delta { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-size: 12px; }

/* ══ グラフ ═══════════════════════════════════════════════ */
.chart-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.chart-tools-label { font-size: 12px; color: var(--text-muted); }
.seg-compact { width: 108px; margin-bottom: 0; }
.seg-compact .seg-btn { min-height: 34px; }
.chart-foot { display: block; margin-top: var(--s2); text-align: right; }

.chart-card { padding: var(--s3) var(--s2) var(--s2); position: relative; }
.chart-holder { position: relative; width: 100%; }

/* 1日ぶんの列幅を守るため、入りきらない期間は横スクロールで見せる。
   ページ全体は横に動かさない（body は overflow-x:hidden のまま）。 */
.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.chart-plot { position: relative; }
.chart-holder svg { display: block; }
/* 横にも縦にもブラウザのスクロールを任せる。指で払ったら期間を送れる */
.chart-svg { touch-action: pan-x pan-y; }

.chart-hint {
  padding: var(--s1) var(--s2) 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* 縦軸だけはスクロールさせない。流れていくと目盛りが読めなくなる */
.chart-axis {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  pointer-events: none;
}

.chart-empty {
  padding: var(--s5) var(--s3);
  text-align: center;
  font-size: var(--fs-sub);
  color: var(--text-muted);
  line-height: 1.8;
}

.chart-tip {
  position: absolute;
  z-index: 3;
  min-width: 132px;
  max-width: 200px;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r1);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
  pointer-events: none;
  font-size: 12px;
}
.chart-tip-time { color: var(--text-muted); margin-bottom: var(--s1); }
.chart-tip-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: var(--s2);
  padding: 1px 0;
}
.chart-tip-key { height: 3px; border-radius: 2px; }
.chart-tip-name { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tip-val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.chart-tip-row.is-now .chart-tip-name { color: var(--text-primary); font-weight: 600; }

/* ══ 体重入力 ═════════════════════════════════════════════ */
.weigh-card { display: flex; flex-direction: column; gap: var(--s4); align-items: stretch; }
.weigh-label { font-size: var(--fs-sub); color: var(--text-secondary); text-align: center; }
.weigh-row { display: flex; align-items: baseline; justify-content: center; gap: var(--s2); }

.weigh-input {
  width: 5.2ch;
  padding: 0;
  border: 0;
  border-bottom: 2px solid var(--axis);
  border-radius: 0;
  background: none;
  font-size: var(--fs-num);
  font-weight: 600;
  text-align: center;
  /* 大きな単独の数字なので tabular-nums は使わない（字間が間延びする） */
}
.weigh-input:focus { border-bottom-color: var(--accent); }
.weigh-input::-webkit-outer-spin-button,
.weigh-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.weigh-input { -moz-appearance: textfield; }
.weigh-unit { font-size: var(--fs-body); color: var(--text-secondary); }
.weigh-input::placeholder { color: var(--text-muted); opacity: 0.45; }
.weigh-prev { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: calc(var(--s3) * -1); }

/* 記録日時。ふだんは触らない欄。カード幅いっぱいの帯にすると、主役であるはずの
   体重入力より目立ち、左右の縁まで届いて枠から張り出して見える。
   中身ぶんの幅に絞って中央に置き、面も一段沈めて「そこに用があるときだけ触る欄」にする */
.weigh-when { gap: var(--s2); align-items: center; }
.weigh-when .field-label,
.weigh-when .field-hint { text-align: center; }
/* 案内文がカードの縁まで届くと、それだけで枠からはみ出して見える。
   常に左右に余白が残る幅で折り返させる（狭い端末では2行、広い端末では1行になる） */
.weigh-when .field-hint { max-width: 88%; }
.weigh-when input {
  width: auto;
  max-width: 100%;
  min-width: 0;
  text-align: center;
  background: var(--surface-sunken);
}

/* ══ 記録リスト ═══════════════════════════════════════════ */
/* コメントは落ち着いた面と系列色の小さな印で、グラフと結び付ける。 */
.comment-compose { display: grid; gap: var(--s2); min-width: 0; }
.comment-label { display: flex; align-items: center; gap: var(--s2); font-weight: 600; }
.comment-optional { font-size: var(--fs-sub); font-weight: 400; color: var(--text-secondary); }
.comment-compose textarea {
  width: 100%; min-width: 0; min-height: calc(var(--tap) * 2); max-height: 40dvh;
  padding: var(--s3); border: 1px solid var(--axis); border-radius: var(--r1);
  background: var(--surface-sunken); color: var(--text-primary);
  font-size: var(--fs-input); line-height: 1.6; resize: vertical;
}
.comment-compose textarea::placeholder { color: var(--text-secondary); }
.comment-compose textarea:focus { border-color: var(--accent); }
.comment-compose textarea[aria-invalid="true"] { border-color: var(--danger); }
.comment-meta { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); font-size: var(--fs-sub); color: var(--text-secondary); }
.comment-counter { flex: none; font-variant-numeric: tabular-nums; }
.comment-counter.is-over { color: var(--danger); font-weight: 600; }
.comments-section { margin-top: var(--s5); }
.comments-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s2); }
.comments-heading h2 { font-size: var(--fs-input); font-weight: 600; }
.comment-count { font-size: var(--fs-sub); color: var(--text-secondary); }
.comments-context, .comments-guide { font-size: var(--fs-sub); color: var(--text-secondary); margin-top: var(--s1); }
.comments-list { display: grid; gap: var(--s3); margin-top: var(--s4); }
.comment-card { min-width: 0; padding: var(--s4); border-radius: var(--r2); border: 1px solid var(--border); background: var(--surface); }
.comment-card-head { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.comment-person-key { width: var(--s2); height: var(--s2); border-radius: 50%; background: var(--person-color); flex: none; }
.comment-person { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.comment-delta { margin-left: auto; flex: none; font-size: var(--fs-sub); font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.comment-time { display: block; margin-top: var(--s1); font-size: var(--fs-sub); color: var(--text-secondary); }
.comment-text { margin-top: var(--s3); font-size: var(--fs-input); white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-url { color: var(--accent); text-decoration: underline; text-underline-offset: 0.18em; overflow-wrap: anywhere; }
.comments-empty { padding: var(--s5) var(--s4); margin-top: var(--s3); border-radius: var(--r2); background: var(--surface-sunken); color: var(--text-secondary); font-size: var(--fs-sub); }
.comments-more { width: 100%; margin-top: var(--s3); }
.comments-reset { margin-top: var(--s3); font-size: var(--fs-sub); }
.record-comment { grid-column: 1 / -1; min-width: 0; color: var(--text-secondary); font-size: var(--fs-sub); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chart-tip-comments { border-top: 1px solid var(--border); padding-top: var(--s1); margin-top: var(--s1); color: var(--text-secondary); }

.list-card { padding: 0; }
.record-list li { border-bottom: 1px solid var(--border); }
.record-list li:last-child { border-bottom: 0; }

.record-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s4);
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}
/* ══ 履歴（アコーディオン）════════════════════════════════ */
.accordion { padding: 0; margin-top: var(--s5); overflow: hidden; }

.accordion-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: var(--s2) var(--s4);
  cursor: pointer;
  list-style: none;                       /* 既定の三角を消して自前の印を出す */
}
.accordion-head::-webkit-details-marker { display: none; }
.accordion-title { font-size: var(--fs-body); font-weight: 600; }
.accordion-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.accordion-mark { margin-left: auto; color: var(--text-muted); display: flex; }
.accordion-mark svg { width: 20px; height: 20px; }
.accordion[open] .accordion-mark { transform: rotate(180deg); }

.accordion-body { border-top: 1px solid var(--border); }

.range-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.range-field { display: flex; flex-direction: column; gap: var(--s1); flex: 1 1 40%; min-width: 0; }
.range-field select {
  min-height: var(--tap);
  padding: 0 var(--s2);
  border: 1px solid var(--axis);
  border-radius: var(--r1);
  background: var(--surface);
  width: 100%;
}
.range-sep { color: var(--text-muted); padding-bottom: var(--s3); }
.btn-sm { min-height: 38px; padding: 0 var(--s3); font-size: var(--fs-sub); }

.record-when { font-size: var(--fs-sub); color: var(--text-secondary); }
.record-weight { font-variant-numeric: tabular-nums; font-weight: 600; }
.record-delta { font-variant-numeric: tabular-nums; font-size: var(--fs-sub); color: var(--text-secondary); min-width: 5.5ch; text-align: right; }
.list-empty { padding: var(--s4); font-size: var(--fs-sub); color: var(--text-muted); text-align: center; }

/* ══ 管理 ═════════════════════════════════════════════════ */
.admin-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
}
.admin-list li:last-child { border-bottom: 0; }
.admin-name { font-weight: 600; }
.admin-meta { font-size: 12px; color: var(--text-muted); flex: 1 1 100%; }
.admin-list .btn { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-sub); }

/* ロック中の行は目立たせる。本人から連絡が来る前に管理者が気付けるようにするため（要件 6-17）。
   色だけに頼らず、左の帯と meta の文言でも分かるようにしてある。 */
.admin-list li.is-locked {
  border-left: 3px solid var(--danger);
  padding-left: var(--s3);
  background: color-mix(in srgb, var(--danger) 7%, transparent);
}
.admin-list li.is-locked .admin-meta { color: var(--danger); }

/* ══ ホーム画面に追加する導線 ═════════════════════════════ */
/* 案内であって警告ではないので、--danger 系の強い色は使わない。
   .view と同じ幅・同じ左右余白に収め、本文の一部として読めるようにする。 */
.install-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  /* .view と同じ左右余白・同じ最大幅に収める。
     900px 以上では #app-screen 側に padding-left: 216px が付くので、ここは触らなくてよい */
  width: calc(100% - var(--gutter) * 2);
  max-width: 560px;
  margin: var(--s4) auto 0;
  padding: var(--s2) var(--s3);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--r2);
}
.install-bar-text {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-sub);
  color: var(--text-secondary);
  line-height: 1.5;
}
.install-bar .btn-sm { flex: none; }
.install-bar-close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  border-radius: var(--r1);
  cursor: pointer;
}

.install-state { font-size: var(--fs-sub); color: var(--text-secondary); line-height: 1.6; }

.install-steps {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin: 0;
  padding-left: 1.4em;
  font-size: var(--fs-sub);
  color: var(--text-secondary);
  line-height: 1.6;
}
.install-steps strong { color: var(--text-primary); }

/* ══ タブバー ═════════════════════════════════════════════ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);   /* ホームバーに潜らせない */
}
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
.nav-brand { display: none; }                    /* PC の左ナビでだけ出す */
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.tab.is-on { color: var(--accent); }
.tab-icon svg { width: 22px; height: 22px; display: block; }
.tab-text { font-size: 11px; font-weight: 600; }

/* ══ シート ═══════════════════════════════════════════════ */
.sheet {
  width: min(100% - 24px, 420px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text-primary);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.4); }
.sheet-body { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5) var(--s4); }
.sheet-title { font-size: var(--fs-title); font-weight: 600; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }

/* ══ トースト ═════════════════════════════════════════════ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(70px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100vw - 32px);
  padding: var(--s2) var(--s4);
  background: var(--text-primary);
  color: var(--page);
  border-radius: 999px;
  font-size: var(--fs-sub);
  font-weight: 600;
}

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

/* ══ 共有コメントと3画面のデザイン（2026-09-13） ══ */
.app-head { max-width: var(--content-width); margin: 0 auto; padding: calc(var(--s5) + env(safe-area-inset-top)) var(--gutter) var(--s2); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2); }
.app-brand { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sub); font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 24px; }
#app-date { color: var(--text-secondary); font-size: var(--fs-sub); }
.card { border-color: transparent; }
.stat-tile { background: var(--hero); align-items: center; padding: var(--s5) var(--s4); margin-bottom: var(--s4); }
.stat-main { display: grid; min-width: 0; }
.stat-value { grid-row: auto; grid-column: auto; line-height: 1.3; }
.stat-status { display: grid; text-align: right; gap: var(--s1); font-size: var(--fs-sub); }
.stat-status span { color: var(--text-secondary); }
.community-switch { background: var(--surface); padding: var(--s1); border: 0; margin-bottom: var(--s4); }
.community-switch .seg-btn { border-radius: var(--r1); min-height: var(--tap); }
.community-switch .seg-btn.is-on { color: var(--accent); background: var(--soft); box-shadow: none; }
.community-card { padding: var(--s4) var(--s4) 0; min-width: 0; }
.community-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.community-head h2 { font-size: var(--fs-input); font-weight: 600; }
.community-head .view-sub { font-size: 12px; }
.filter-row { gap: var(--s1) var(--s2); margin: var(--s2) 0; }
.legend-btn { min-height: var(--tap); max-width: 100%; padding: 0 var(--s1); border: 0; border-radius: 0; background: none; flex-wrap: wrap; overflow-wrap: anywhere; }
.legend-btn::before { content: none; }
.legend-btn[aria-pressed="false"] { text-decoration: line-through; }
.legend-key { width: 8px; height: 8px; border-radius: 50%; }
.legend-delta { display: inline; }
.chart-tools { justify-content: space-between; flex-wrap: wrap; }
.chart-tools-label { font-size: var(--fs-sub); }
.seg-compact { flex: none; }
.seg-compact .seg-btn { min-height: var(--tap); }
.chart-card { padding: 0; }
.chart-holder { min-width: 0; }
.chart-hint { font-size: 12px; }
.chart-point.is-day-selected { stroke-width: 2.5; }
.comment-days { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s2) 0 var(--s4); }
.comment-day { display: flex; justify-content: center; align-items: center; gap: var(--s2); min-height: var(--tap); padding: var(--s2) var(--s3); border: 1px solid var(--border); background: var(--surface); border-radius: 12px; font-size: var(--fs-sub); cursor: pointer; }
.comment-day span { font-size: 12px; }
.comment-day[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--soft); font-weight: 600; }
#comment-days-more { width: 100%; margin-bottom: var(--s4); }

/* ══ 減った量ランキング（グラフの下）══════════════════════ */
.ranking { margin-top: var(--s4); }
.ranking-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--s1) var(--s2); }
.ranking-head h3 { font-size: var(--fs-input); font-weight: 600; }
.ranking-sub { font-size: 12px; color: var(--text-secondary); }
.ranking-list { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: var(--s1); }
.ranking-row {
  display: grid;
  grid-template-columns: 2.5em 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s2);
  border-radius: 12px;
}
/* 自分の行だけ、絞り込みの選択と同じ薄い青で示す（順位で色は変えない） */
.ranking-row.is-me { background: var(--soft); }
.ranking-rank { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-secondary); font-size: var(--fs-sub); }
.ranking-key { width: 8px; height: 8px; border-radius: 50%; }
.ranking-name { min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-sub); }
.ranking-delta { font-variant-numeric: tabular-nums; font-size: var(--fs-sub); font-weight: 600; white-space: nowrap; }
.ranking-delta.is-good { color: var(--success); }
.comments-section { margin: 0 calc(-1 * var(--s4)); padding: var(--s4); border-top: 1px solid var(--border); border-radius: 0 0 var(--r2) var(--r2); background: var(--soft); }
.comments-heading h2 { font-size: var(--fs-sub); }
.comments-list { gap: 0; margin-top: var(--s3); }
.comment-card { padding: var(--s4) 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: none; }
.comment-card:last-child { padding-bottom: 0; }
.comment-card-head { align-items: center; flex-wrap: wrap; }
.comment-avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--person-color); font-weight: 600; }
.comment-person-meta { min-width: 0; flex: 1; }
.comment-person { font-size: 14px; }
.comment-time { font-size: 12px; }
.comment-delta { font-size: var(--fs-sub); color: var(--text-primary); font-weight: 600; }
.comment-text { font-size: var(--fs-body); }
.comments-empty { background: none; padding: var(--s4) 0; }
.comments-reset { width: 100%; color: var(--accent); margin-top: var(--s2); }
.comment-jump { display: block; border: 0; background: none; color: var(--accent); min-height: var(--tap); margin-top: var(--s2); padding: var(--s2) 0; font-size: var(--fs-sub); cursor: pointer; text-align: left; }
.community-card.is-feed .comments-section { background: var(--surface); }
.community-card.is-feed .comment-avatar { background: var(--soft); }
.weigh-card { padding: var(--s5) var(--s4); gap: var(--s5); }
.weigh-prev { font-size: var(--fs-sub); }
.comment-compose textarea { background: var(--page); padding: var(--s3); border-radius: var(--r1); }
.private-note { text-align: center; font-size: var(--fs-sub); }
.ok-msg { background: var(--soft); color: var(--accent); border-radius: var(--r1); padding: var(--s3); }
.accordion-head { min-height: 60px; }
.private-profile { padding: var(--s5); }
.private-weight { font-size: var(--fs-num); font-weight: 600; margin: var(--s2) 0 var(--s4); line-height: 1.3; }
.private-weight small { font-size: var(--fs-body); font-weight: 400; margin-left: var(--s2); }
/* 適正体重の目安（自分タブ） */
.body-guide { padding: var(--s5); margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); }
.guide-item { display: flex; flex-direction: column; gap: 2px; padding: var(--s3); border-radius: var(--r1); background: var(--surface-sunken); min-width: 0; }
.guide-label { font-size: 12px; color: var(--text-muted); }
.guide-value { font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.guide-value small { font-size: var(--fs-sub); font-weight: 400; margin-left: var(--s1); }
.guide-note, .guide-range { font-size: var(--fs-sub); color: var(--text-secondary); overflow-wrap: anywhere; }
.height-row { display: flex; align-items: flex-end; gap: var(--s2); }
.height-row .field { flex: 1; min-width: 0; }
.height-row .btn { flex: none; }
.profile-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) 0; border-top: 1px solid var(--border); font-size: var(--fs-sub); overflow-wrap: anywhere; }
.field input, .field select, .range-field select, .inline-row input { font-size: var(--fs-input); }
.tabbar { left: 50%; right: auto; transform: translateX(-50%); width: min(100%, var(--content-width)); padding: var(--s2) var(--s4) calc(var(--s2) + env(safe-area-inset-bottom)); border-radius: var(--r2) var(--r2) 0 0; }
.tabs { gap: var(--s2); }
.tab { min-height: 64px; border-radius: var(--r1); color: var(--text-secondary); }
.tab.is-on { background: var(--soft); color: var(--accent); }
.tab-text { font-size: 12px; }
.toast { bottom: calc(var(--nav-height) + var(--s3) + env(safe-area-inset-bottom)); }
@media (min-width: 768px) {
  :root { --gutter: 24px; }
  .view { padding-top: var(--s5); }
  .community-card { padding-top: var(--s5); }
  .view[data-view="record"], .view[data-view="me"] { max-width: 608px; }
}
