/* ================================
 *  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: 520px;
  width: 100%;
  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);/* 影を薄くして“押し込まれた感” */
}

/* ================================
   Calendar Modal (REWRITE)
   ================================ */

/* modal wrapper */
.cal-modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  font-family: inherit;
}
.cal-modal.is-open{ display:block; }

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

/* panel */
.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);
  border: 1px solid rgba(0,0,0,0.06);

  padding: 18px 18px 14px;
  box-sizing: border-box;

  /* これがはみ出しの最後の砦 */
  overflow: hidden;
}

/* close button */
.cal-close{
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;

  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;
}

/* header */
.cal-header{
  position: relative;
  /* ×と同じ段に寄せる（notchも考慮） */
  padding-top: calc(12px + env(safe-area-inset-top));
}

/* title row: 1段目=年月 / 2段目=ナビ左右 */
.cal-title{
  width: 100%;
  box-sizing: border-box;

  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "center center"
    "left   right";
  align-items: center;

  row-gap: 8px;
  column-gap: 10px;

  /* 端末右の安全域 + ちょい余白 */
  padding-left: 12px;
  padding-right: calc(12px + env(safe-area-inset-right));
}

/* 2段目の左右配置 */
.cal-nav-left  { grid-area: left;  justify-content: flex-start; }
.cal-nav-right { grid-area: right; justify-content: flex-end; }

/* 1段目の中央配置 */
.cal-title-center{
  grid-area: center;
  justify-self: center;
}

/* nav containers */
.cal-nav-left,
.cal-nav-right{
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}
.cal-nav-left{ justify-content: flex-start; }
.cal-nav-right{ justify-content: flex-end; }

/* nav buttons */
.cal-nav{
  width: 34px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.6);

  display: inline-flex;
  align-items: center;
  justify-content: center;

  line-height: 1;
  flex: 0 0 auto; /* 伸びない */
}
.cal-nav:active{ transform: translateY(1px); }

/* center title */
.cal-title-center{
  justify-self: center;
  display: flex;
  align-items: baseline;
  gap: 8px;

  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.12em;
  font-weight: 600;
  max-width: 100%;          /* ★ 追加：1fr内で収まる */
  padding: 0 6px;           /* ★ 追加：左右に少し余白 */
}

/* month/year */
.cal-month{
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  opacity: 0.78;
}
.cal-year{
  font-size: 22px;
  font-weight: 700;
  opacity: 0.35;
}

/* week header */
.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;
}

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

/* day cell */
.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: #777;
}
.cal-day.is-empty{
  border: none;
  background: transparent;
}

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

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

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

/* note (hide) */
.cal-note{ display:none; }

.cal-week,
.cal-grid{
  box-sizing: border-box;
  padding-left: 12px;
  padding-right: calc(12px + env(safe-area-inset-right));
}

/* =========================
   右上ハンバーガー（見た目だけ）
========================= */
.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残り回数ボタン：中の手アイコンを小さく === */
.ai-count-btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 8px 12px;
}

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

.ai-count{
  font-size: 18px;
  line-height: 1;
}

/* ================================
 *  ハンバーガーメニュー（menuModal）
 * ================================ */

.menu-modal{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
}

.menu-modal[aria-hidden="false"]{
  display: block;
}

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

.menu-panel{
  position: absolute;
  top: 64px;
  right: 16px;
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  min-width: 160px;
}

.menu-panel button{
  width: 100%;
  border: none;
  background: #f3efe8;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 6px 0;
  font-size: 14px;
}

.hamburger{
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
}

/* =========================================
   HOTFIX (menu / nickname / hide buttons)
   add to END of new_ui2.css
========================================= */

/* --- ❶ ハンバーガーが押せない対策：最前面＆クリック保証 --- */
#hamburgerBtn.hamburger {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 99999;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

/* ハンバーガーが何かに覆われている時の保険（透明レイヤーが吸わない） */
.menu-backdrop,
.cal-backdrop,
.diary-modal-backdrop {
  pointer-events: none; /* デフォルトはクリック吸わない */
}

/* ただし開いてる時は吸う（※JSが display/hidden を切替える想定に合わせる） */
#menuModal[aria-hidden="false"] .menu-backdrop,
#calendarModal[aria-hidden="false"] .cal-backdrop,
#diaryModal:not(.hidden) .diary-modal-backdrop {
  pointer-events: auto;
}

/* --- メニューの重なり順を明示（menu > calendar > diary など調整可） --- */
#menuModal { z-index: 90000; }
#calendarModal { z-index: 80000; }
#diaryModal { z-index: 85000; } /* diaryが前に出てほしいなら calendarより上 */

/* メニューパネルが確実に見えるように */
#menuModal .menu-panel {
  position: fixed;
  top: 56px;
  right: 14px;
  z-index: 90001;
}

/* カレンダーパネルも固定（古いCSSでrelativeになってる時の保険） */
#calendarModal .cal-panel {
  position: fixed;
  z-index: 80001;
}

/* --- ❷ ニックネームカードがカード形状にならない対策 --- */
#nicknameCard.nickname-card {
  /* 表示中にカードとして成立させる */
  display: none; /* JSで表示するなら block に切り替える */
  position: fixed;
  left: 50%;
  top: 56%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);

  background: #ffffff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,.14);

  padding: 14px 14px 16px;
  z-index: 95000;            /* hamburgerより前に出す */
}

/* ニックネーム表示中はハンバーガーを隠したい場合（bodyに状態クラス付ける方式推奨）
   いまJS未対応でも、念のためCSSだけ用意しておく */
body.is-nickname-open #hamburgerBtn { display: none !important; }

/* 見た目 */
#nicknameCard .nickname-title {
  margin: 10px 0 6px;
  font-weight: 700;
}
#nicknameCard .nickname-sub {
  margin: 0 0 10px;
  opacity: .85;
}
#nicknameCard input#nicknameInput {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
}
#nicknameCard .nickname-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
#nicknameCard .nickname-buttons button {
  flex: 1;
  border-radius: 12px;
  padding: 10px 12px;
}

/* 追加：ニックネームの背面を暗くしたいなら（任意）
   HTMLに backdrop 要素が無いので、必要ならJSで作るか別途div追加が必要 */

/* --- ❸ 「見る」「あいの手」ボタンを非表示 --- */
/* HTMLでのIDが確定しているのでこれが最強 */
#btnViewToday,
#btnAi {
  display: none !important;
}

/* =========================================================
   AINOTE / Nickname UI - CLEAN & STABLE (iPhone対応)
   - iOSの勝手な文字拡大を抑制
   - 画面全体の縮小/ズーム事故を防止
   - ニックネームカードを中央固定
   - 文字/入力/ボタンを押しやすく
   ========================================================= */

/* ---- 基本リセット ---- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

/* ---- iOSの自動文字拡大を抑制（これ重要）---- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 16px;
}

/* iPhone幅だけ少しだけ基準を上げたい場合（好みで 16 のままでもOK） */
@media (max-width: 430px){
  html { font-size: 17px; }
}

/* ---- 画面縮小(zoom/transform)事故の予防 ---- */
body {
  zoom: 1;
  transform: none;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #111;
  background: #fff;
}

/* =========================================================
   HERO（チャッティ画像 + タイトル周り）
   画像がデカすぎて下が押せない事故を防ぐ
   ========================================================= */

/* チャッティ画像：iPhoneでも収まる上限を設定 */
.hero img,
.chatty-image,
.nickname-chatty {
  width: min(72vw, 360px);
  height: auto;
  display: block;
  margin: 0 auto;
}

/* タイトル/説明：読みやすい可変サイズ */
.hero-title,
.nickname-title {
  font-size: clamp(18px, 5vw, 26px);
  line-height: 1.25;
}

.hero-sub,
.nickname-desc,
.nickname-sub {
  font-size: clamp(14px, 4vw, 18px);
  line-height: 1.5;
}

/* =========================================================
   NICKNAME CARD（中央固定で安定）
   ※HTML側に #nicknameCard と .nickname-card がある前提
   ========================================================= */

/* 背景の薄暗幕（存在する場合だけ効く） */
#nicknameOverlay,
.nickname-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.20);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90000;
}

/* ニックネームカード本体：中央固定 */
#nicknameCard,
#nicknameCard.nickname-card,
.nickname-card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  max-height: 86dvh;          /* iPhoneのバー変動に強い */
  overflow: auto;
  padding: 18px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 18px 50px rgba(0,0,0,0.20);
  z-index: 95000;
}

/* カード内の余白や整列（クラスが違っても崩れにくく） */
#nicknameCard .nickname-title,
.nickname-card .nickname-title {
  margin: 0 0 8px 0;
  text-align: center;
}

#nicknameCard .nickname-sub,
#nicknameCard .nickname-desc,
.nickname-card .nickname-sub,
.nickname-card .nickname-desc {
  margin: 0 0 14px 0;
  text-align: center;
  opacity: 0.9;
}

/* 入力欄：iOSでズームしないように font-size 16px以上必須 */
#nicknameInput,
#nicknameCard input[type="text"],
.nickname-card input[type="text"] {
  width: 100%;
  font-size: 16px;            /* ← iPhone自動ズーム回避の最低ライン */
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.18);
  outline: none;
}

/* 入力フォーカス */
#nicknameInput:focus,
#nicknameCard input[type="text"]:focus,
.nickname-card input[type="text"]:focus {
  border-color: rgba(0,0,0,0.35);
}

/* ボタン群 */
#nicknameCard .nickname-buttons,
.nickname-card .nickname-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

/* ボタン：押しやすさ最優先 */
#nicknameCard .nickname-buttons button,
.nickname-card .nickname-buttons button,
#nicknameOk,
#nicknameLater {
  flex: 1;
  padding: 12px 12px;
  font-size: 16px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
}

/* ボタンの最低限の見た目（色は好みで変えてOK） */
#nicknameOk { background: #111; color: #fff; }
#nicknameLater { background: #e9e9e9; color: #111; }

/* =========================================================
   iPhoneの下バー/キーボードで隠れにくくする保険
   ========================================================= */

/* 画面下に固定の入力UIがある場合だけ効く（無ければ無視される） */
.composer,
.bottom-composer,
#composer {
  padding-bottom: env(safe-area-inset-bottom);
}

/* iOSの“中途半端なタップで拡大”を避ける */
button, input, textarea {
  touch-action: manipulation;
}

#viewDiaryBtn { display: none !important; }
