/* =============================================================
   もふ手帳 — デザインシステム / 共通コンポーネント
   components.css : リセット・レイアウト・全部品のスタイル
   ============================================================= */

/* ---------- リセット ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }  /* No.107: 基準の明示（マーケと同値） */
body {
  margin: 0;
  font-family: var(--font-base);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--color-text);
  background: var(--color-bg-peach);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--color-coral-dark); }
h1,h2,h3,h4,p { margin: 0; }

/* ---------- 画面枠（モバイル基準・PCで中央寄せ） ---------- */
.app {
  max-width: var(--content-max);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--color-bg);
  position: relative;
  box-shadow: var(--shadow-lg);
}

/* ---------- トップバー ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  background: rgba(255, 251, 248, 0.92);
  -webkit-backdrop-filter: saturate(1.1) blur(8px);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.topbar__logo { width: 30px; height: 30px; flex: 0 0 auto; }
.topbar__name {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--color-coral-dark);
  letter-spacing: 0.02em;
}
.topbar__spacer { flex: 1; }
.topbar__action {
  width: var(--tap-min); height: var(--tap-min);
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: var(--radius-md);
  font-size: var(--fs-lg); color: var(--color-text-sub);
}
.topbar__action:hover { background: var(--color-bg-peach); }

/* ---------- ページ本体 ---------- */
.page {
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--tabbar-h) + var(--space-8));
}

/* ---------- ページ見出し ---------- */
.page-heading { margin-bottom: var(--space-5); }
.page-heading__title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: var(--lh-tight);
}
.page-heading__sub {
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--color-text-sub);
}

/* セクション見出し */
.section-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--color-text);
  margin: var(--space-6) 0 var(--space-3);
  display: flex; align-items: center; gap: var(--space-2);
}
.section-title:first-child { margin-top: 0; }
.section-title__link {
  margin-left: auto; font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none;
}

/* ---------- カード ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }
.card--flat { box-shadow: none; }
.card--peach { background: var(--color-bg-peach); border-color: transparent; }
.card__title {
  font-size: var(--fs-md); font-weight: 700; margin-bottom: var(--space-2);
  display: flex; align-items: center; gap: var(--space-2);
}
.card__body { font-size: var(--fs-sm); color: var(--color-text-sub); }

/* ---------- ボタン（4種） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-5);
  font-size: var(--fs-base); font-weight: 700;
  border-radius: var(--radius-pill);
  border: 1.5px solid transparent;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none;
  line-height: 1.3;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* 標準 */
.btn--primary { background: var(--color-coral); color: #fff; }
.btn--primary:hover { background: var(--color-coral-dark); }

/* 全幅 */
.btn--block { width: 100%; }

/* ゴースト */
.btn--ghost {
  background: transparent; color: var(--color-coral-dark);
  border-color: var(--color-border);
}
.btn--ghost:hover { background: var(--color-bg-peach); }

/* 無効 */
.btn--disabled, .btn:disabled {
  background: var(--color-border); color: #fff;
  cursor: not-allowed; pointer-events: none; box-shadow: none;
}

.btn--sm { min-height: 44px; padding: 0 var(--space-4); font-size: var(--fs-sm); }

/* ---------- フォーム ---------- */
.field { margin-bottom: var(--space-4); }
.label {
  display: block; font-size: var(--fs-sm); font-weight: 700;
  color: var(--color-text); margin-bottom: var(--space-2);
}
.label__hint { font-weight: 400; color: var(--color-text-faint); margin-left: var(--space-1); }

.input, .select, .textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-base); /* 16px — iOSズーム防止 */
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  min-height: var(--tap-min);
  line-height: 1.5;
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--color-coral);
  box-shadow: var(--shadow-focus);
}
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%237A4A35' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-8);
}
.field__help { font-size: var(--fs-xs); color: var(--color-text-faint); margin-top: var(--space-1); }

/* ---------- チップ（選択式・複数可） ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm); font-weight: 700;
  background: var(--color-surface);
  color: var(--color-text-sub);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  transition: all .12s ease;
}
.chip:hover { border-color: var(--color-coral-soft); }
.chip--active, .chip[aria-pressed="true"] {
  background: var(--color-coral); color: #fff; border-color: var(--color-coral);
}

/* ---------- ピル（種別タグ・表示用） ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  font-size: var(--fs-xs); font-weight: 700;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.pill--weight  { background: var(--pill-weight-bg);  color: var(--pill-weight-fg); }
.pill--meal    { background: var(--pill-meal-bg);    color: var(--pill-meal-fg); }
.pill--poop    { background: var(--pill-poop-bg);    color: var(--pill-poop-fg); }
.pill--walk    { background: var(--pill-walk-bg);    color: var(--pill-walk-fg); }
.pill--clinic  { background: var(--pill-clinic-bg);  color: var(--pill-clinic-fg); }
.pill--vaccine { background: var(--pill-vaccine-bg); color: var(--pill-vaccine-fg); }
.pill--med     { background: var(--pill-med-bg);     color: var(--pill-med-fg); }
.pill--note    { background: var(--pill-note-bg);    color: var(--pill-note-fg); }

/* 種別タグ（犬/猫） */
.pill--dog { background: #FCEFD9; color: #9A6516; }
.pill--cat { background: #EDEAF6; color: #574A8C; }

/* ---------- バナー ---------- */
.banner {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, #FCEFD9, #FAECE7);
  border: 1px solid var(--color-border);
  font-size: var(--fs-sm);
}
.banner__icon { font-size: var(--fs-lg); flex: 0 0 auto; }
.banner__text { flex: 1; color: var(--color-text); line-height: var(--lh-tight); }
.banner__text strong { color: var(--color-coral-dark); }
.banner__action {
  flex: 0 0 auto; font-weight: 700; font-size: var(--fs-sm);
  color: var(--color-coral-dark); text-decoration: none; white-space: nowrap;
}

/* ---------- メッセージ（成功/エラー） ---------- */
.message {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm); line-height: var(--lh-tight);
}
.message__icon { flex: 0 0 auto; }
.message--success { background: var(--color-success-bg); color: var(--color-success); }
.message--error   { background: var(--color-warning-bg); color: var(--color-warning); }

/* ---------- 進捗バー ---------- */
.progress {
  display: block; width: 100%; height: 10px;
  background: var(--color-bg-peach);
  border-radius: var(--radius-pill); overflow: hidden;
}
.progress__bar {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--color-coral-soft), var(--color-coral));
  border-radius: var(--radius-pill);
  transition: width .4s ease;
}
.progress__label {
  display: flex; justify-content: space-between;
  font-size: var(--fs-sm); margin-bottom: var(--space-2);
}

/* ---------- 一覧テーブル ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td {
  text-align: left; padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.table th { font-weight: 700; color: var(--color-text-sub); font-size: var(--fs-xs); }
.table tr:last-child td { border-bottom: none; }

/* 記録リスト（テーブル代替・モバイル向け行） */
.record-list { list-style: none; margin: 0; padding: 0; }
.record-item {
  display: flex; gap: var(--space-3); padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}
.record-item:last-child { border-bottom: none; }
.record-item__thumb {
  width: 52px; height: 52px; flex: 0 0 auto;
  border-radius: var(--radius-md); object-fit: cover;
  background: var(--color-bg-peach);
}
.record-item__main { flex: 1; min-width: 0; }
.record-item__meta {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-xs); color: var(--color-text-faint);
  margin-bottom: 2px; flex-wrap: wrap;
}
.record-item__text { font-size: var(--fs-sm); color: var(--color-text); }
.record-item__link {
  font-size: var(--fs-xs); font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; margin-top: 2px;
}

/* ---------- うちの子アバター ---------- */
.pet-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm); background: var(--color-bg-peach);
}
.pet-row { display: flex; gap: var(--space-4); align-items: flex-start; overflow-x: auto; padding-bottom: var(--space-1); }
.pet-row__item { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); flex: 0 0 auto; width: 64px; }
.pet-row__name { font-size: var(--fs-xs); font-weight: 700; color: var(--color-text); text-align: center; }
.pet-row__add {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px dashed var(--color-border); background: var(--color-surface);
  color: var(--color-coral); font-size: var(--fs-lg); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- 固定タブバー（5つ・変更禁止） ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: var(--content-max);
  height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: rgba(255, 251, 248, 0.96);
  -webkit-backdrop-filter: saturate(1.1) blur(10px);
  backdrop-filter: saturate(1.1) blur(10px);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none;
  color: var(--color-text-faint); font-size: 10px; font-weight: 700;
  min-height: var(--tap-min);
}
.tabbar__icon { font-size: 22px; line-height: 1; }
.tabbar__item.is-active { color: var(--color-coral); }

/* ---------- ロック（アップセル）オーバーレイ ---------- */
.lock {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
}
.lock__overlay {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(255, 251, 248, 0.82);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-3); text-align: center; padding: var(--space-5);
}
.lock__icon { font-size: var(--fs-2xl); }
.lock__text { font-size: var(--fs-sm); font-weight: 700; color: var(--color-text); }

/* ---------- 吹き出し（AI相談） ---------- */
.bubble { max-width: 85%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); font-size: var(--fs-sm); line-height: var(--lh-base); }
.bubble--user { margin-left: auto; background: var(--color-coral); color: #fff; border-bottom-right-radius: var(--radius-sm); }
.bubble--bot  { margin-right: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-bottom-left-radius: var(--radius-sm); }
.bubble-row { margin-bottom: var(--space-4); }
.bubble__label { font-size: var(--fs-xs); color: var(--color-text-faint); margin-bottom: 4px; }
.rate { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.rate__btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--color-border); background: var(--color-surface);
  font-size: var(--fs-base);
}
.rate__btn:hover { background: var(--color-bg-peach); }

/* ---------- ワンタップ記録 ---------- */
.quicklog { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.quicklog__name { font-weight: 700; font-size: var(--fs-sm); margin-right: var(--space-1); }

/* ---------- 写真グリッド（アルバム） ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.photo-grid__item { text-align: center; }
.photo-grid__img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: var(--radius-md); }
.photo-grid__cap { font-size: var(--fs-xs); color: var(--color-text-sub); margin-top: 4px; line-height: 1.3; }

/* ---------- カレンダー ---------- */
.calendar__nav { display: flex; align-items: center; justify-content: center; gap: var(--space-5); margin-bottom: var(--space-4); }
.calendar__nav button { width: var(--tap-min); height: var(--tap-min); border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-surface); font-size: var(--fs-lg); color: var(--color-text-sub); }
.calendar__title { font-size: var(--fs-md); font-weight: 700; min-width: 140px; text-align: center; }
.calendar__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar__dow { text-align: center; font-size: var(--fs-xs); font-weight: 700; color: var(--color-text-faint); padding: var(--space-1) 0; }
.calendar__cell {
  aspect-ratio: 1/1; border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 6px; font-size: var(--fs-sm); color: var(--color-text);
  border: 1px solid transparent;
}
.calendar__cell--muted { color: var(--color-text-faint); }
.calendar__cell--today { background: var(--color-bg-peach); }
.calendar__cell--selected { background: var(--color-coral); color: #fff; }
.calendar__emoji { font-size: 10px; line-height: 1; margin-top: 2px; }

/* ---------- 空状態 ---------- */
.empty { text-align: center; padding: var(--space-8) var(--space-5); }
.empty__img { width: 120px; height: 120px; margin: 0 auto var(--space-4); }
.empty__title { font-weight: 700; margin-bottom: var(--space-2); }
.empty__text { font-size: var(--fs-sm); color: var(--color-text-sub); }

/* ---------- 連続記録・小バッジ ---------- */
.streak {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill);
  background: var(--color-bg-peach); font-weight: 700; font-size: var(--fs-sm);
  color: var(--color-coral-dark);
}

/* ---------- 区切り ---------- */
.divider { height: 1px; background: var(--color-border); border: none; margin: var(--space-6) 0; }

/* ---------- 折りたたみ ---------- */
.collapse { border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface); }
.collapse > summary { padding: var(--space-4); font-weight: 700; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.collapse > summary::-webkit-details-marker { display: none; }
.collapse__body { padding: 0 var(--space-4) var(--space-4); }

/* ---------- ユーティリティ ---------- */
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.muted { color: var(--color-text-sub); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.center { text-align: center; }
.note-tiny { font-size: var(--fs-xs); color: var(--color-text-faint); line-height: var(--lh-tight); }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); }

/* =====================================================================
   PC レイアウト（No.101・節目K）— 1024px以上のみ。モバイルは一切不変。
   ===================================================================== */
.tabbar__brand, .tabbar__out { display: none; }

@media (min-width: 1024px) {
  body { background: #F6EBE2; }
  .app {
    max-width: none;
    margin: 0 0 0 232px;          /* サイドバー分 */
    box-shadow: none;
    min-height: 100vh;
  }
  /* ---- タブバー → 左サイドバー ---- */
  .tabbar {
    left: 0; top: 0; bottom: 0; right: auto; transform: none;
    width: 232px; max-width: none; height: auto;
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 18px 12px;
    border-top: none; border-right: 1px solid var(--color-border);
    background: var(--color-surface);
  }
  .tabbar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px 18px; text-decoration: none;
    font-weight: 900; font-size: 17px; color: var(--color-text);
  }
  .tabbar__item {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    width: 100%; min-height: 46px; padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: 14px; font-weight: 700; color: var(--color-text-sub);
  }
  .tabbar__icon { font-size: 19px; }
  .tabbar__item.is-active {
    background: var(--color-bg-peach); color: var(--color-coral-dark);
  }
  .tabbar__item:hover { background: var(--color-bg); }
  .tabbar__out {
    display: flex; flex-direction: row; align-items: center; gap: 12px;
    margin-top: auto; min-height: 46px; padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: 14px; font-weight: 700; color: var(--color-text-sub);
    text-decoration: none;
  }
  .tabbar__out:hover { background: var(--color-bg); }

  /* ---- コンテンツ幅（ページ特性別・bodyクラスで自動） ---- */
  main.page {
    max-width: 720px;               /* 既定: フォーム系の読みやすい幅 */
    margin: 0 auto;
    padding: var(--space-6) var(--space-5);
    padding-bottom: var(--space-8); /* タブバー分の下余白は不要に */
  }
  body.pg-records main.page,
  body.pg-calendar main.page,
  body.pg-album main.page { max-width: 960px; }   /* 一覧系は広く */
  body.pg-consult main.page,
  body.pg-memo main.page,
  body.pg-card main.page { max-width: 760px; }    /* チャット・作成系 */
  body.pg-home main.page { max-width: 900px; }

  /* ---- ホーム: カード2カラム（未知の子要素は全幅＝崩れない設計） ---- */
  body.pg-home main.page {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
    align-items: start;
  }
  body.pg-home main.page > * { grid-column: 1 / -1; }
  body.pg-home main.page > .card { grid-column: auto; margin: 0; }
  body.pg-home main.page > .card:first-of-type { grid-column: 1 / -1; }

  /* ---- アルバム: 列を増やして余白活用 ---- */
  body.pg-album .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  /* ---- 固定UIのPC位置調整 ---- */
  #mofuToast { bottom: 28px !important; left: calc(50% + 116px) !important; }
  .topbar { padding-left: var(--space-5); padding-right: var(--space-5); }
}

/* =====================================================================
   No.107 第2便: 見出しスケールの完備（マーケ統一レイヤーと同値）
   h1 24px(PC30) / h2 19px(PC22) / h3 16px — 各ページのクラス指定が優先
   ===================================================================== */
h1{font-size:24px;line-height:1.5;margin:0 0 14px;}
h2{font-size:19px;line-height:1.55;margin:0 0 12px;}
h3{font-size:16px;line-height:1.6;margin:0 0 8px;}
@media(min-width:1024px){
  h1{font-size:30px;}
  h2{font-size:22px;}
}

/* ===== 重い生成の待ち表示（UX改修①） ===== */
.mofu-load__box{background:#fff;border-radius:16px;box-shadow:0 6px 22px rgba(74,27,12,.22);padding:22px 26px;display:flex;align-items:center;gap:14px;font-weight:700;color:#4A1B0C;max-width:80%;line-height:1.5;}
.mofu-load__spin{width:22px;height:22px;flex:0 0 auto;border-radius:50%;border:3px solid rgba(216,90,48,.25);border-top-color:var(--color-coral,#D85A30);animation:mofuSpin .8s linear infinite;}
@keyframes mofuSpin{to{transform:rotate(360deg);}}
@media (prefers-reduced-motion:reduce){.mofu-load__spin{animation-duration:1.8s;}}
