/* ================================
 *  AI日記 新UI 共通スタイル
 *  （大人かわいい Dusty Green × Pink テーマ）
 * ================================ */

/* 全体 */
body {
  margin: 0;
  font-family: -apple-system, system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #f2f2ec;  /* やわらかいオフホワイト */
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================================
 *  ラリー（チャットログ）
 * ================================ */

.chat-log {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f2f2ec;
}

/* 1つのメッセージ行
   新： .chat-row.user / .chat-row.bot
   旧： .chat-item.chat-user / .chat-item.chat-ai （互換）
*/
.chat-row,
.chat-item {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 10px 0;
}

/* ユーザー（右側） */
.chat-row.user,
.chat-item.chat-user {
  justify-content: flex-end;
}

/* チャッティ（左側） */
.chat-row.bot,
.chat-item.chat-ai {
  justify-content: flex-start;
}

/* 時刻表示 */
.chat-time {
  font-size: 11px;
  opacity: 0.7;
  color: #777;
  margin-top: 2px;
}

/* ================================
 *  アバター（アイコン）
 * ================================ */

.chat-avatar,
.chat-item .avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.chat-avatar-img,
.chat-item .avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* ================================
 *  吹き出し
 * ================================ */

.chat-bubble,
.chat-item .bubble,
.chat-text {  /* 旧クラス互換用 */
  display: inline-block;
  max-width: 72vw;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid transparent;
  background: #ffffff;
  color: #333;
  /* ②案：吹き出しだけ少し丸ゴ寄りにする */
  font-family: "Yu Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

/* あなた（右側）の吹き出し：くすみピンク */
.chat-row.user .chat-bubble,
.chat-item.chat-user .bubble,
.chat-item.chat-user .chat-text {
  background: #e2d5d5;
  border-color: #d2c5c5;
}

/* チャッティ（左側）の吹き出し：くすみブルーグレー */
.chat-row.bot .chat-bubble,
.chat-item.chat-ai .bubble,
.chat-item.chat-ai .chat-text {
  background: #d5e2e2;
  border-color: #c7d4d4;
}

/* ================================
 *  チャット内の写真
 * ================================ */

.chat-photo {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

/* ================================
 *  入力エリア（下の白カード）
 * ================================ */

.composer {
  padding: 14px 14px 18px;
  background: #ffffff;
  border-top: 1px solid #d4d0c5;
}

.diary-text {
  width: 100%;
  height: 120px;
  border-radius: 14px;
  border: 2px solid #c7c1b5;
  padding: 12px;
  box-sizing: border-box;
  font-size: 16px;
}

/* 文字数カウンター */
.char-counter {
  margin-top: 4px;
  text-align: right;
  font-size: 12px;
  color: #777777;
}

/* ================================
 *  ボタン行
 * ================================ */

.btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

/* 共通ボタン（＋ 合いの手 今日の日記を見る） */
.icon-btn {
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: #e8e0d4;   /* あたたかいベージュ */
  color: #333;
  font-size: 14px;
  /* ②案：ボタンも少し丸ゴ寄りに */
  font-family: "Yu Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.icon-btn:active {
  transform: translateY(1px);
  background: #dcc9b5;
}

/* 合いの手残り回数 */
.ai-count-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-count {
  font-size: 22px;
  font-weight: 700;
  color: #637a6b;  /* くすみグリーン */
}

/* ================================
 *  サムネ（下の小さい写真たち）
 * ================================ */

.photo-thumbs {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.thumb-photo {
  width: 70px;
  height: 70px;
  border-radius: 12px;
  border: 2px solid #c7d4d4;
  object-fit: cover;
}

/* ================================
 *  モーダル（画像プレビュー）
 * ================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 96vw);
  background: #ffffff;
  border-radius: 18px;
  padding: 14px;
}

/* モーダルの画像 */
.modal-img {
  width: 100%;
  height: auto;
  border-radius: 14px;
}

/* モーダルの一言メモ */
.modal-note {
  margin: 10px 2px 0;
  font-size: 13px;
  opacity: 0.7;
}

/* モーダルのボタン */
.modal-buttons {
  width: 100%;
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

/* ================================
 *  ボタンスタイル（モーダル内）
 * ================================ */

.btn-primary,
.btn-danger,
.btn-ghost {
  border-radius: 14px;
  font-size: 16px;
  padding: 12px;
  border: none;
  /* モーダルのボタンも同じ丸ゴ系で統一 */
  font-family: "Yu Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

/* メインボタン */
.btn-primary {
  background: #2f7cff;
  color: #ffffff;
}

.btn-primary .btn-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.85;
}

/* 削除ボタン */
.btn-danger {
  background: #ff6b6b;
  color: #ffffff;
}

/* サブボタン */
.btn-ghost {
  background: #e9e9e9;
}

/* ================================
 *  汎用クラス
 * ================================ */

/* 「hidden」クラス */
.hidden {
  display: none;
}

/* ================================
 *  フォントサイズ切り替え用
 * ================================ */

/* 基本値（Mサイズ） */
.app {
  --chat-font-size: 14px;
  --diary-font-size: 16px;
}

/* S / M / L のクラスで上書き */
.app.font-small {
  --chat-font-size: 13px;
  --diary-font-size: 15px;
}

.app.font-medium {
  --chat-font-size: 14px;
  --diary-font-size: 16px;
}

.app.font-large {
  --chat-font-size: 16px;
  --diary-font-size: 18px;
}

/* 既存スタイルのうち、フォントサイズを変えたいところを変数に差し替え */

.chat-bubble,
.chat-item .bubble,
.chat-text {
  /* もともと font-size: 14px; を書いていた場所を差し替え */
  font-size: var(--chat-font-size);
}

.diary-text {
  /* もともと font-size: 16px; を書いていた場所を差し替え */
  font-size: var(--diary-font-size);
}

/* フォントサイズ切り替えボタン */

.font-size-toggle {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.font-size-btn {
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 13px;
  border-radius: 999px;
  color: #555;
}

.font-size-btn.is-active {
  background: #d5e2e2;   /* チャッティ側とおそろいのくすみブルー */
  color: #333;
}

/* フォントサイズボタン共通 */
.font-size-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 6px 8px;
  min-width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #555;
}

/* 左・真ん中・右で「Aa」の大きさを変える */
.font-size-btn[data-size="small"] {
  font-size: 12px;
}

.font-size-btn[data-size="medium"] {
  font-size: 14px;
}

.font-size-btn[data-size="large"] {
  font-size: 16px;
}

/* 選択中（今のままでもOKだけど、念のため） */
.font-size-btn.is-active {
  background: #dde5e2;
  font-weight: 600;
}

/* ===== ニックネーム設定モーダル用 ===== */

.settings-title {
  font-size: 16px;
  font-weight: 600;
  margin: 4px 2px 8px;
}

.settings-note {
  font-size: 13px;
  line-height: 1.6;
  opacity: 0.8;
  margin: 0 2px 12px;
}

.settings-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #c7c1b5;
  font-size: 14px;
  margin-bottom: 12px;
}

/* ===== 今日の日記ビュー モーダル ===== */
.diary-modal.hidden {
  display: none;
}

.diary-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.diary-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.diary-modal-content {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 8%;
  bottom: 8%;
  background: #fffdf8;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}

.diary-modal-close {
  align-self: flex-end;
  border: none;
  background: transparent;
  font-size: 20px;
}

.diary-modal-date {
  text-align: right;
  color: #777;
  font-size: 12px;
}

.diary-modal-summary h3,
.diary-modal-chatty h3,
.diary-modal-rally h3 {
  margin: 4px 0;
  font-size: 13px;
}

.diary-modal-summary p,
.diary-modal-chatty p {
  white-space: pre-wrap;
  line-height: 1.6;
}

.diary-modal-rally {
  border-top: 1px dashed #ddd;
  padding-top: 6px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rally-scroll {
  flex: 1;
  overflow-y: auto;
}

/* モーダル全体：画面が小さいときに縦スクロールできるようにする */
.diary-modal {
  overflow-y: auto;
  padding: 24px 12px;  /* 余白がキツかったらここはお好みで */
}

/* 白いカード自体に「最大高さ」とスクロールを付ける */
.diary-modal-content {
  max-height: 90vh;    /* 画面の高さの 90% まで */
  overflow-y: auto;    /* それ以上はカードの中をスクロール */
}

/* ▼ ボタン共通デザイン */
.diary-btn {
    cursor: pointer;
    /* ふわっと戻る用のアニメーション */
    transition:
        background-color 0.15s ease,
        transform        0.10s ease,
        box-shadow       0.10s ease;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.10); /* ちょっと浮いてる影 */
    transform: translateY(0) scale(1);
}

/* ▼ ホバー時（PC 向け） */
.diary-btn:hover {
    background-color: #f0e5d9;              /* すこーし濃くする */
    transform: translateY(-1px) scale(1.01);/* ふわっと 1px 浮く感じ */
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}

/* ▼ 押している間（スマホのタップでも効く） */
.diary-btn:active {
    background-color: #ecdccf;              /* さらにちょっと濃く */
    transform: translateY(3px) scale(0.96); /* 下にグッと 3px 押しこまれる */
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);/* 影を薄くして“押し込まれた感” */
}

/* ===== カレンダーモーダル（見た目だけ） ===== */
.cal-modal {
  position: fixed;
  inset: 0;
  display: none; /* ← JSで開くようになったら block にする */
  z-index: 9999;
  font-family: inherit;
}

.cal-modal.is-open {
  display: block;
}

.cal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.18);
}

.cal-panel {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  width: min(92vw, 460px);
  background: #fbfaf6;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  padding: 18px 18px 14px;
  border: 1px solid rgba(0,0,0,0.06);
}

.cal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.6);
  font-size: 20px;
  line-height: 1;
}

.cal-header {
  padding: 8px 4px 10px;
}

.cal-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.cal-month {
  font-size: 22px;
  opacity: 0.78;
}

.cal-year {
    font-size: 22px;
    opacity: 0.35;
    margin-right: 32px;  /* ★これを追加 */
}

.cal-sub {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.6;
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 8px 2px 6px;
  font-size: 12px;
  opacity: 0.55;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 8px 2px 10px;
}

.cal-day {
  position: relative;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.55);
  display: grid;
  place-items: center;
  font-size: 16px;
}

.cal-day .num {
    position: relative;
    z-index: 2;
    font-weight: 600;
    opacity: 0.85;
    color: #777777;  /* 平日の基本色＝グレー */
}

.cal-day.is-empty {
  border: none;
  background: transparent;
}

.cal-day.has-diary .paw {
    position: absolute;
    right: 6px;
    bottom: 5px;
    width: 14px;   /* ← ここを 14 に */
    height: 14px;  /* ← ここも 14 に */
    z-index: 1;
    opacity: 0.95;

    background-image: url("/static/paw_blue.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.cal-day.is-today {
  border: 1px solid rgba(255,105,180,0.35);
  background: rgba(255,105,180,0.14);
}

.cal-note {
  font-size: 12px;
  opacity: 0.55;
  padding: 6px 4px 2px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  margin-top: 6px;
}
/* ===== /カレンダー ===== */

/* =========================
   右上ハンバーガー（見た目だけ）
========================= */
.hamburger{
  position: fixed;
  top: 16px;
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 12px;

  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.60);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;

  z-index: 60;
  -webkit-tap-highlight-color: transparent;
}

.hamburger__bar{
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
}

/* 押した時の軽い反応（見た目のみ） */
.hamburger:active{
  transform: scale(0.98);
}

/* もし「右上の×」などに被るなら微調整用 */
@media (max-width: 420px){
  .hamburger{
    top: 14px;
    right: 14px;
  }
}

/* 曜日の色（日曜＝ピンク／土曜＝水色） */
.cal-week span:first-child {   /* S = 日曜 */
  color: #ff6fae;              /* 今のピンク系 */
}

.cal-week span:last-child {    /* S = 土曜 */
  color: #5fb7ff;              /* 水色 */
}

/* 日付の数字も色分け（日曜＝ピンク／土曜＝水色） */
.cal-grid .cal-day:nth-child(7n+1) .num {  /* 日曜列 */
  color: #ff6fae;
}

.cal-grid .cal-day:nth-child(7n) .num {    /* 土曜列 */
  color: #5fb7ff;
}

.diary-modal-footer {
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: center; /* 右寄せなら flex-end */
}

.diary-modal-footer-close {
  min-width: 140px;
}

/* 最新日記モーダルのフッター用ボタン */
.diary-modal .diary-modal-footer-close {
  background-color: #6B5A3C;   /* いつものブラウン */
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 32px;
  font-size: 16px;
  font-weight: 600;
  min-width: 140px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

/* 押したとき・ホバー時（ほんの少しだけ暗く） */
.diary-modal .diary-modal-footer-close:hover,
.diary-modal .diary-modal-footer-close:active {
  background-color: #5A4B32;   /* 一段暗いブラウン */
}

/* アクセシビリティ用フォーカス */
.diary-modal .diary-modal-footer-close:focus-visible {
  outline: 2px solid #EBD6A5;  /* ゴールド寄りの淡い色 */
  outline-offset: 2px;
}

/* 最新日記モーダルの「閉じる」ボタン専用スタイル */
#diaryModalFooterClose {
  background-color: #AB8686 !important;  /* #6B5A3C + 透明度 */
  color: #fff !important;
  border: none !important;
  border-radius: 999px;
  padding: 10px 32px;
  font-size: 16px;
  font-weight: 600;
  min-width: 140px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

/* ▼ 最新日記モーダルの「閉じる」ボタン */
button.diary-modal-close-bottom {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 40px;
  border-radius: 999px;
  border: none;
  background-color: #778899; /* 好きなブラウンに変えてOK */
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

button.diary-modal-close-bottom:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.cal-day {
  position: relative;
}

/* 足跡を置く（右下に小さく） */
.cal-day.has-diary::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  background: url("/static/paw_blue.png") no-repeat center / contain;
  opacity: 0.9;
  pointer-events: none;
}

/* textareaを基準にする箱 */
.diary-box {
  position: relative;
}

/* 猫手ボタン（右下に浮かせる） */
.btn-ai-float {
  position: absolute;
  right: 10px;
  bottom: 10px;

  width: 44px;
  height: 44px;

  border: none;
  background: transparent;
  padding: 0;
  margin: 0;

  cursor: pointer;

  transition: transform 0.12s ease;
}

/* 猫手画像サイズ */
.btn-ai-float img {
  width: 100%;
  height: 100%;
  display: block;
}

/* 押したときに一瞬大きくなる（しいちゃん仕様） */
.btn-ai-float:active {
  transform: scale(1.25);
}

/* 🐾 合いの手：浮遊猫手ボタン */
.btn-ai-float {
    position: absolute;
    right: 10px;
    bottom: 10px;

    background: none;
    border: none;
    padding: 0;
    margin: 0;

    cursor: pointer;

    /* アニメーション準備 */
    transition: transform 0.08s ease;
}

/* 画像サイズ */
.btn-ai-float img {
    width: 42px;
    height: auto;
    display: block;
}

/* 🐾 押した瞬間：ぷにっ */
.btn-ai-float:active {
    transform: scale(1.25);
}

/* iPhoneで反応を良くする */
.btn-ai-float {
    -webkit-tap-highlight-color: transparent;
}

/* 🐾 合いの手：浮遊猫手ボタン */
.btn-ai-float{
    position:absolute;
    right:10px;
    bottom:10px;

    background:none;
    border:none;
    padding:0;
    margin:0;

    cursor:pointer;
    -webkit-tap-highlight-color:transparent;

    /* “押せる感”の基本 */
    filter: drop-shadow(0 6px 10px rgba(0,0,0,.20));
    transform-origin: 85% 90%;
    transition: transform .08s ease, filter .08s ease;
}

.btn-ai-float img{
    width:42px;
    height:auto;
    display:block;
}

/* 押した瞬間：2倍＋明るく＋影変化（押し込み）＋ちょい揺れ */
.btn-ai-float:active{
    transform: scale(2.0) rotate(-6deg);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.18)) brightness(1.35) saturate(1.2);
}

/* “ぷるっ”を足す（押してる間だけ） */
.btn-ai-float:active img{
    animation: paw-jiggle .12s ease-in-out infinite;
}

@keyframes paw-jiggle{
    0%   { transform: translate(0,0) rotate(0deg); }
    50%  { transform: translate(-1px,-1px) rotate(2deg); }
    100% { transform: translate(0,0) rotate(0deg); }
}

.btn-ai-float:active::before{
    content:"";
    position:absolute;
    inset:-18px;
    border-radius:999px;
    background: rgba(255, 220, 120, .35);
    filter: blur(6px);
    z-index:-1;
}

/* =========================
   猫手：ぷにっ＋輪郭発光（B案）
   ========================= */

.btn-ai-float{
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transform-origin: center center;
}

.btn-ai-float img{
    display: block;
    width: 100%;
    height: 100%;
    /* 画像自体の色は変えない */
}

/* 押した瞬間：少し潰れる（ぷにっ） */
.btn-ai-float.is-squish{
    transform: scale(0.92, 0.84);
    filter:
        drop-shadow(0 0 10px rgba(255, 210, 90, 0.85))
        drop-shadow(0 0 18px rgba(255, 210, 90, 0.55));
}

/* つぎ：少し大きく（ぽん） */
.btn-ai-float.is-pop{
    transform: scale(1.25);
    filter:
        drop-shadow(0 0 12px rgba(255, 210, 90, 0.90))
        drop-shadow(0 0 22px rgba(255, 210, 90, 0.60));
}

/* 戻る */
.btn-ai-float.is-back{
    transform: scale(1.0);
    filter: none;
}

.btn-ai-float.is-pop {
  transform: scale(1.25, 0.9);
  filter: drop-shadow(0 0 6px rgba(120, 190, 255, 0.9))
          drop-shadow(0 0 12px rgba(120, 190, 255, 0.6));
  transition: transform 0.12s ease-out, filter 0.12s ease-out;
}

.btn-ai-float.is-pop-back {
  transform: scale(1, 1);
  filter: drop-shadow(0 0 0 rgba(120,190,255,0));
  transition: transform 0.16s ease-out, filter 0.16s ease-out;
}

.ai-count-btn{
    display:inline-flex;
    align-items:center;
    gap:6px;
    padding:0;
    border:none;
    background:transparent;
    cursor:pointer;
    -webkit-tap-highlight-color: transparent;
}

.ai-count-icon{
    width:22px;
    height:22px;
    display:block;
}

.ai-count{
    font-weight:700;
    font-size:22px;
    line-height:1;
}

/* 合いの手ボタン（内部用）を隠す */
#btnAi {
  display: none !important;
}
