/* =============================================================
   Yosuga Chat – Chill & Cute Chat Room
   ============================================================= */

/* ---------- チャットログ ------------------------------ */
.chat-log {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
}

/* ---------- チャット行 -------------------------------- */
.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  /* エントリーアニメーション */
  animation: bubble-in 0.3s ease both;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-row.is-user {
  justify-content: flex-end;
}

.chat-row.is-animal {
  justify-content: flex-start;
}

.chat-avatar {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  max-width: 72px;
  max-height: 72px;
  flex: 0 0 72px;
  margin: 0;
  align-self: flex-start;
  overflow: hidden;
  border-radius: 9999px;
}

.chat-avatar img {
  display: block;
  width: 72x;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  max-width: 72px;
  max-height: 72px;
  border-radius: inherit;
  object-fit: cover;
  border: 1.5px solid rgba(255, 215, 200, 0.72);
  background: rgba(255, 246, 241, 0.92);
}

/* ---------- チャットバブル基本 ------------------------ */
.chat-bubble {
  position: relative;
  max-width: min(76%, 560px);
  border-radius: 20px;
  border: 1.5px solid var(--border);
  padding: 10px 14px;
  background: rgba(255, 246, 241, 0.9);
  backdrop-filter: blur(10px) saturate(0.95);
  -webkit-backdrop-filter: blur(10px) saturate(0.95);
  box-shadow: 0 4px 16px rgba(28, 22, 34, 0.16);
  transition: box-shadow 0.2s ease;
}

/* ユーザーバブル：夜空の布にローズを足した、読める濃さの藤色 */
.chat-row.is-user .chat-bubble {
  border-color: rgba(255, 215, 200, 0.38);
  background: rgba(118, 73, 112, 0.95);
  box-shadow: 0 4px 18px rgba(28, 18, 36, 0.28);
}

/* 動物バブル：白フロストガラス */
.chat-row.is-animal .chat-bubble {
  border-color: rgba(222, 178, 160, 0.38);
}

/* ---------- 発言者名 ---------------------------------- */
.chat-speaker {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #b45d78;
}

.chat-row.is-user .chat-speaker {
  color: #ffe1d6;
}

/* ---------- チャットテキスト -------------------------- */
.chat-text {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
  font-size: 0.97rem;
  line-height: 1.6;
}

.chat-row.is-user .chat-text {
  color: #fff8ec;
}

/* ---------- 履歴ロード -------------------------------- */
.chat-history-trigger {
  height: 1px;
}

.chat-history-load-button {
  justify-self: center;
}

.chat-history-load-button[hidden],
.chat-history-end-label[hidden] {
  display: none !important;
}

.chat-history-end-label {
  justify-self: center;
  margin-bottom: 14px;
  font-size: 0.88rem;
  color: var(--text-on-photo);
  text-shadow: 0 1px 2px rgba(15, 12, 20, 0.55);
}

/* ---------- 履歴ステータス表示 ------------------------ */
.chat-history-status {
  margin-top: 8px;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--text-on-photo);
  text-shadow: 0 1px 2px rgba(15, 12, 20, 0.55);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ---------- スピナー ---------------------------------- */
.chat-history-spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 246, 241, 0.72);
  border-top-color: #ffb8cc;
  animation: chat-history-spin 0.8s linear infinite;
  display: none;
}

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

/* ---------- 入力フォーム -------------------------------- */
.chat-message-label-row {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
}

.chat-message-label-row .label {
  margin: 0;
}

.chat-star-status {
  color: #ffe7dc;
  text-shadow: 0 2px 8px rgba(14, 12, 22, 0.58);
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-align: left;
}

.chat-limit-action {
  display: flex;
  justify-content: center;
}

.chat-limit-button {
  align-items: center;
  display: inline-flex;
  gap: 0.65rem;
  justify-content: center;
  min-height: auto;
  height: auto;
  max-width: min(100%, 420px);
  white-space: normal;
  text-align: center;
  line-height: 1.5;
}

.chat-limit-button__face {
  display: block;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  border: 1.5px solid rgba(255, 215, 200, 0.72);
  border-radius: 9999px;
  background: rgba(255, 246, 241, 0.92);
  object-fit: cover;
}

.chat-limit-button__unlock {
  line-height: 1;
}

/* ---------- レスポンシブ ------------------------------ */
@media (max-width: 640px) {
  .chat-avatar {
    width: 72px;
    height: 72px;
    min-width: 72px;
    min-height: 72px;
    max-width: 72px;
    max-height: 72px;
    flex-basis: 72px;
  }

  .chat-avatar img {
    width: 72px;
    height: 72px;
    min-width: 72px;
    min-height: 72px;
    max-width: 72px;
    max-height: 72px;
  }

  .chat-bubble {
    max-width: 90%;
  }
}
