/* style.css
   配色・フォント・レイアウトはCSS変数で管理し、後から調整しやすくしている。
   design_doc.md に沿った実装。 */

:root {
  /* --- 配色 --- */
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-primary: #06c755;      /* LINE風のアクセントグリーン */
  --color-primary-dark: #049c43;
  --color-text: #1c1c1e;
  --color-text-muted: #6b7280;
  --color-border: #e2e5e9;
  --color-bubble-user: #06c755;
  --color-bubble-user-text: #ffffff;
  --color-bubble-assistant: #ffffff;
  --color-bubble-assistant-text: #1c1c1e;
  --color-danger: #d93025;

  /* --- フォント --- */
  --font-base: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  --font-size-base: 16px;

  /* --- レイアウト --- */
  --radius-card: 16px;
  --radius-bubble: 18px;
  --header-height: 60px;
  --input-bar-height: 64px;
  --max-content-width: 1024px;
  --chat-bg-image: none;

  /* --- アニメーション --- */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* hidden属性をCSSでも確実に効かせる(JavaScriptで制御するため重要) */
[hidden] {
  display: none !important;
}

/* =============================================================================
   キャラクター選択画面 (index.html)
   ============================================================================= */

.select-screen {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 32px 20px 120px;
}

.select-header h1 {
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: 24px;
}

.suggestion-section {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--color-border);
}

.suggestion-section h2 {
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.suggestion-section > p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.suggestion-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestion-form__textarea {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.suggestion-form__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.suggestion-form__button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.suggestion-form__button:hover {
  background: var(--color-primary-dark);
}

.suggestion-form__button:disabled {
  opacity: 0.6;
  cursor: default;
}

.suggestion-message {
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  padding: 12px;
  background: rgba(6, 199, 85, 0.1);
  border-radius: 8px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (min-width: 640px) {
  .character-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.loading-text {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--color-text-muted);
}

.character-card {
  background: var(--color-surface);
  border: 2px solid transparent;
  border-radius: var(--radius-card);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.character-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.character-card--selected {
  border-color: var(--color-primary);
}

.character-card__image-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--color-bg);
}

.character-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.character-card__body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.character-card__label {
  font-weight: 600;
  font-size: 1rem;
}

.character-card__description {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slide-up var(--transition-base);
}

.entry-panel__selected {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.entry-panel__label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.entry-panel__input {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 1rem;
}

.entry-panel__button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  transition: background var(--transition-fast);
}

.entry-panel__button:hover {
  background: var(--color-primary-dark);
}

.entry-panel__button:disabled {
  opacity: 0.6;
  cursor: default;
}

.entry-panel__error {
  color: var(--color-danger);
  font-size: 0.85rem;
  margin: 0;
}

.entry-panel__close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--color-text-muted);
  padding: 0 4px;
  cursor: pointer;
  transition: color var(--transition-fast);
  flex-shrink: 0;
  margin-left: auto;
}

.entry-panel__close:hover {
  color: var(--color-text);
}

/* === カミングスーン === */
.coming-soon-section {
  margin-top: 64px;
  padding: 48px 0;
  border-top: 1px solid var(--color-border);
}

.coming-soon-section h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 24px;
}

.coming-soon-section .character-card {
  opacity: 0.75;
  pointer-events: none;
}

/* === よくある質問 === */
.section-header {
  margin-bottom: 32px;
}

.section-header h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin: 0 0 8px 0;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
}

.faq-section {
  margin-top: 64px;
  padding: 48px 0;
  border-top: 1px solid var(--color-border);
}

.faq-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .faq-grid {
    grid-template-columns: 1fr;
  }
}

.faq-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.faq-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.1);
}

.faq-card summary {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  user-select: none;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  width: 100%;
}

.faq-card summary::-webkit-details-marker {
  display: none;
}

.faq-card summary::after {
  content: '▼';
  font-size: 0.7rem;
  color: var(--color-primary);
  margin-left: 10px;
  transition: transform var(--transition-fast);
}

.faq-card[open] summary::after {
  transform: rotate(180deg);
}

.faq-card p {
  margin: 16px 0 0 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.8;
}

/* =============================================================================
   チャット画面 (chat.html)
   ============================================================================= */

.chat-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: var(--max-content-width);
  margin: 0 auto;
  background: var(--color-bg);
  overflow: hidden;
}

.chat-header {
  height: var(--header-height);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.chat-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-header__name {
  font-size: 1.05rem;
  margin: 0;
  flex: 1;
}

.chat-header__leave {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  transition: background var(--transition-fast);
}

.chat-header__leave:hover {
  background: var(--color-bg);
}

.chat-message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background-image: var(--chat-bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.chat-bubble-row {
  display: flex;
  margin-bottom: 10px;
}

.chat-bubble-row:last-child {
  margin-bottom: 0;
}

.chat-bubble-row--assistant {
  justify-content: flex-start;
}

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

.chat-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.chat-bubble--assistant {
  background: var(--color-bubble-assistant);
  color: var(--color-bubble-assistant-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.chat-bubble--user {
  background: var(--color-bubble-user);
  color: var(--color-bubble-user-text);
  border-bottom-right-radius: 4px;
}

.chat-bubble--typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted);
  opacity: 0.6;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.chat-error {
  color: var(--color-danger);
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
  padding: 6px 16px;
}

.chat-input-bar {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 2;
  min-height: var(--input-bar-height);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.chat-input-bar__textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.4;
}

.chat-input-bar__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-input-bar__send {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.chat-input-bar__send:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.chat-input-bar__send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --- メッセージ表示アニメーション(フェードイン・スライドイン) --- */
.message-pop-enter-active {
  animation: message-in var(--transition-base);
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================================================
   レスポンシブ調整
   ============================================================================= */

@media (max-width: 480px) {
  .chat-bubble {
    max-width: 85%;
  }
}

/* --- モーション低減設定を尊重 --- */
@media (prefers-reduced-motion: reduce) {
  .message-pop-enter-active,
  .entry-panel,
  .character-card,
  .typing-dot {
    animation: none !important;
    transition: none !important;
  }

  .typing-dot {
    opacity: 1;
  }
}

/* =============================================================================
   キャラ情報ボタン & ポップアップ
   ============================================================================= */

/* カード右上のⓘボタン */
.character-card__info-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  z-index: 1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.character-card__info-btn:hover {
  background: rgba(0, 0, 0, 0.65);
}

/* カード自体をrelativeに（ⓘボタン位置基準） */
.character-card {
  position: relative;
}

/* オーバーレイ背景 */
.char-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlay-in 0.2s ease;
}

.char-info-overlay.closing {
  animation: overlay-out 0.2s ease forwards;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ポップアップ本体 */
.char-info-popup {
  background: var(--color-surface);
  border-radius: 20px;
  max-width: 380px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: popup-spring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.char-info-popup.closing {
  animation: popup-shrink 0.2s ease forwards;
}

@keyframes popup-spring {
  0%   { opacity: 0; transform: scale(0.7) translateY(20px); }
  60%  { opacity: 1; transform: scale(1.04) translateY(-4px); }
  80%  { transform: scale(0.98) translateY(2px); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes popup-shrink {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.85) translateY(10px); }
}

/* ポップアップ内のキャラ画像ヘッダー */


/* テキストエリア */
.char-info-popup__body {
  padding: 20px 22px 24px;
}

.char-info-popup__name {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--color-text);
}

.char-info-popup__desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 14px 0;
}

.char-info-popup__info {
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.75;
  margin: 0;
  white-space: pre-wrap;
}

/* 閉じるボタン */
.char-info-popup__close {
  align-self: flex-end;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.char-info-popup__close:hover {
  background: rgba(0, 0, 0, 0.6);
}

/* モーション低減 */
@media (prefers-reduced-motion: reduce) {
  .char-info-popup {
    animation: none;
  }
  .char-info-overlay {
    animation: none;
  }
}

/* ポップアップヘッダー（名前 + 閉じるボタン横並び） */
.char-info-popup__body {
  display: flex;
  flex-direction: column;
}

.char-info-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* =============================================================================
   ご意見フォーム (review-section)
   ============================================================================= */

.review-section {
  margin-top: 64px;
  padding: 48px 0;
  border-top: 1px solid var(--color-border);
}

.review-section h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin: 0 0 12px 0;
}

.review-section__lead {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin: 0 0 24px 0;
}

.review-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 星評価エリア */
.review-form__stars {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.review-form__stars-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  flex-shrink: 0;
}

.review-stars {
  display: flex;
  gap: 4px;
}

.review-star {
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--color-border);
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition-fast), transform var(--transition-fast);
  cursor: pointer;
}

.review-star:hover,
.review-star.hovered {
  color: #f5c518;
  transform: scale(1.15);
}

.review-star.selected {
  color: #f5c518;
}

.review-form__stars-value {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* コメント欄 */
.review-form__textarea {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
  transition: border-color var(--transition-fast);
}

.review-form__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* 送信ボタン */
.review-form__button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.review-form__button:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.review-form__button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* 送信完了メッセージ */
.review-message {
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  padding: 12px;
  background: rgba(6, 199, 85, 0.1);
  border-radius: 8px;
  margin-top: 8px;
}

/* =============================================================================
   お知らせセクション (news-section)
   ============================================================================= */

.news-section {
  margin-top: 48px;
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
}

.news-section h2 {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin: 0 0 16px 0;
  font-weight: 600;
}

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.news-item {
  display: flex;
  gap: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.news-item__date {
  color: var(--color-text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.news-item__text {
  color: var(--color-text);
}

/* =============================================================================
   物語投稿ボタン・ポップアップ・完了トースト
   ============================================================================= */

/* ヘッダーの投稿ボタン */
.chat-header__story {
  background: transparent;
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--color-primary);
  font-weight: 600;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.chat-header__story:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
}

.chat-header__story:disabled {
  border-color: var(--color-border);
  color: var(--color-text-muted);
  cursor: default;
}

/* 確認ポップアップ オーバーレイ */
.story-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlay-in 0.2s ease;
}

/* ポップアップ本体 */
.story-popup {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 28px 24px 24px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: popup-spring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.story-popup__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 14px 0;
  color: var(--color-text);
}

.story-popup__body {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.75;
  margin: 0 0 22px 0;
}

.story-popup__buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.story-popup__cancel {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.story-popup__cancel:hover {
  background: var(--color-bg);
}

.story-popup__ok {
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.story-popup__ok:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.story-popup__ok:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 完了トースト */
.story-done-toast {
  position: fixed;
  bottom: calc(var(--input-bar-height) + 12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px 12px 20px;
  font-size: 0.88rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 40px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  z-index: 150;
  /*
   * v6修正: 以前は共用の popup-spring を使っていたが、popup-spring の @keyframes は
   * transform に scale()/translateY() しか書いておらず、アニメーション中はこの
   * translateX(-50%) が上書きされて消えてしまっていた(left:50%だけが効き、
   * 中央寄せがアニメ中だけ外れて右寄りに見え、終了と同時に中央へスナップする不具合)。
   * このトーストだけ left:50%+transform中央寄せという特殊な位置指定をしているため、
   * 他の2箇所(.char-info-popup / .story-popup、どちらもflexで中央寄せ)とは
   * 事情が異なる。それらは popup-spring のままで問題ないので、
   * このトースト専用のアニメーションに分離して対応する。
   */
  animation: toast-spring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toast-spring {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.7) translateY(20px); }
  60%  { opacity: 1; transform: translateX(-50%) scale(1.04) translateY(-4px); }
  80%  { transform: translateX(-50%) scale(0.98) translateY(2px); }
  100% { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}

.story-done-toast p {
  margin: 0;
}

.story-done-toast button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.story-done-toast button:hover {
  color: #fff;
}

.character-card--custom {
  text-decoration: none;
  color: inherit;
  border: 2px dashed var(--color-primary);
  background: rgba(6, 199, 85, 0.04);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.character-card--custom:hover {
  background: rgba(6, 199, 85, 0.1);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(6, 199, 85, 0.15);
}

.character-card__image-wrap--custom {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 199, 85, 0.06);
}

.character-card__custom-icon {
  font-size: 3.5rem;
  line-height: 1;
}

/* =============================================================================
   最新作品セクション (index.php)
   ============================================================================= */

.recent-stories-section {
  margin-top: 64px;
  padding: 48px 0;
  border-top: 1px solid var(--color-border);
}

.recent-stories-section h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin: 0 0 8px 0;
}

.recent-stories__lead {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 20px 0;
}

.recent-stories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .recent-stories-grid { grid-template-columns: repeat(5, 1fr); }
}

.recent-story-card {
  text-decoration: none;
  color: inherit;
  background: var(--color-surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.recent-story-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.recent-story-card__header {
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
}

.recent-story-card__avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.6);
  flex-shrink: 0;
}

.recent-story-card__char {
  font-size: 0.78rem;
  font-weight: 600;
}

.recent-story-card__body {
  padding: 8px 10px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-story-card__title {
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recent-story-card__likes {
  font-size: 0.75rem;
  color: #e57373;
  margin: 0;
}


/* チャット制限バナー（往復回数上限・1日利用上限） */

.chat-limit-banner {
  margin: 12px 16px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--color-text);
}

.chat-limit-banner p {
  margin: 0 0 12px;
}

.chat-limit-banner__btn {
  display: inline-block;
  padding: 8px 20px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.875rem;
}

.chat-limit-banner__btn:hover {
  background: var(--color-primary-dark);
}
