/* ===== リセット & ベース ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI',
    'Segoe UI', sans-serif;
  background: #dfe3e8;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* モバイル: コンテナを上端から配置（中央揃えだとiOSで上下に余白が生まれる） */
  min-height: 100vh;
  overflow: hidden;
}

/* ===== チャットコンテナ ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  /* モバイル: position:fixed でビューポートに固定。
     キーボード開閉時もヘッダー・フッターがずれず、iOS特有のスクロールoffsetも無効化 */
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

/* ===== ヘッダー ===== */
.chat-header {
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.header-info {
  flex: 1;
  min-width: 0; /* テキストが縮めるようにする */
}

.header-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-status {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

/* ===== SNS シェアバー ===== */
.share-bar {
  background: #0c3d8f;
  padding: 7px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.share-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.12s;
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
}
.share-btn:hover  { opacity: 0.85; transform: translateY(-1px); }
.share-btn:active { transform: scale(0.95); }

.share-btn-label { font-size: 11.5px; }

.share-copy { background: rgba(255,255,255,0.18); color: #fff; border: 1px solid rgba(255,255,255,0.35); }
.share-copy.copied { background: #34c759; border-color: #34c759; }

.share-x    { background: #000; color: #fff; border: 1px solid rgba(255,255,255,0.45); }
.share-line { background: #06c755; color: #fff; }
.share-fb   { background: #1877f2; color: #fff; }

/* ===== リセットボタン ===== */
.reset-btn {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background 0.18s, transform 0.18s;
}
.reset-btn:hover  { background: rgba(255, 255, 255, 0.32); }
.reset-btn:active { transform: rotate(180deg); }

/* ===== 注意事項トグルボタン ===== */
.notice-toggle {
  position: relative; /* バッジの絶対配置の基点 */
  margin-left: 6px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background 0.18s, transform 0.18s;
}
.notice-toggle:hover  { background: rgba(255, 255, 255, 0.32); }
.notice-toggle.active { background: rgba(255, 255, 255, 0.45); transform: rotate(20deg); }

/* ===== 注意事項パネル ===== */
.notice-panel {
  max-height: 0;
  overflow: hidden;
  background: #fffbea;
  border-bottom: 2px solid #f5c518;
  transition: max-height 0.35s ease, padding 0.35s ease;
  flex-shrink: 0;
}
.notice-panel.open {
  max-height: 1200px;
}

.notice-inner {
  padding: 14px 18px;
}

.notice-title {
  font-size: 13px;
  font-weight: 700;
  color: #7a5500;
  margin-bottom: 8px;
}

.notice-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notice-list li {
  font-size: 12.5px;
  line-height: 1.65;
  color: #4a3800;
  padding-left: 1.2em;
  position: relative;
}

.notice-list li::before {
  content: '・';
  position: absolute;
  left: 0;
  color: #c8960a;
  font-weight: 700;
}

.notice-list a {
  color: #1a73e8;
  word-break: break-all;
  text-decoration: underline;
}

/* ===== 注意リストラッパー（開閉アニメーション用） ===== */
.notice-list-wrap {
  max-height: 800px;
  overflow: hidden;
  transition: max-height 0.32s ease, opacity 0.28s ease, margin 0.28s ease;
  opacity: 1;
  margin-bottom: 0;
}
.notice-list-wrap.collapsed {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
}

/* ===== 宮田について（ネストアコーディオン） ===== */
.profile-accordion {
  margin-top: 10px;
  border-top: 1px dashed #e0c86a;
  padding-top: 8px;
}

.profile-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 197, 24, 0.15);
  border: 1px solid #e8b800;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #7a5500;
  cursor: pointer;
  transition: background 0.18s;
}
.profile-toggle:hover { background: rgba(245, 197, 24, 0.28); }

.profile-toggle .chevron {
  flex-shrink: 0;
  transition: transform 0.28s ease;
  color: #c8960a;
}
.profile-toggle.active .chevron { transform: rotate(180deg); }

.profile-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
}
.profile-panel.open { max-height: 600px; }

.profile-panel .notice-list {
  margin-top: 10px;
}

.profile-link-row {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #4a3800;
  word-break: break-all;
}

.profile-link-row a {
  display: block;
  margin-top: 2px;
  color: #1a73e8;
  text-decoration: underline;
  word-break: break-all;
}

/* ===== PWAインストールバナー ===== */
.install-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #e8f5e9;
  border-bottom: 1px solid #c8e6c9;
  flex-shrink: 0;
}
.install-banner.hidden { display: none; }

.install-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.install-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.5;
  color: #1b5e20;
}
.install-text strong {
  font-weight: 700;
}

.install-action {
  flex-shrink: 0;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.12s;
}
.install-action:hover  { background: #1b5e20; }
.install-action:active { transform: scale(0.96); }
.install-action.hidden { display: none; }

.install-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #66bb6a;
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.install-close:hover { opacity: 1; }

/* ===== 新着バッジ ===== */

/* ⓘボタン右上の赤ドット */
.notice-badge {
  display: none;
  position: absolute;
  top: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #e53935;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #1558b0; /* ヘッダー色に近い縁取り */
  animation: badgePulse 2s ease-in-out infinite;
}
.notice-badge.visible { display: block; }

/* お知らせトグル内のNEWバッジ */
.news-toggle-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.news-badge {
  display: none;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: #e53935;
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.06em;
  line-height: 1.6;
  flex-shrink: 0;
}
.news-badge.visible { display: inline-block; }

@keyframes badgePulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

/* ===== お知らせアコーディオン ===== */
.news-accordion {
  margin-top: 10px;
  border-top: 1px dashed #e0c86a;
  padding-top: 8px;
}

.news-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 197, 24, 0.12);
  border: 1px solid #e8b800;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #7a5500;
  cursor: pointer;
  transition: background 0.18s;
}
.news-toggle:hover { background: rgba(245, 197, 24, 0.28); }

.news-toggle .chevron {
  flex-shrink: 0;
  transition: transform 0.28s ease;
  color: #c8960a;
}
.news-toggle.active .chevron { transform: rotate(180deg); }

.news-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s ease;
}
.news-panel.open { max-height: 400px; }

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

.news-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12.5px;
  line-height: 1.65;
  color: #4a3800;
  padding-left: 0;
}

.news-date {
  flex-shrink: 0;
  font-size: 11px;
  color: #a07800;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(245, 197, 24, 0.2);
  border-radius: 4px;
  padding: 1px 6px;
}

.news-text {
  line-height: 1.65;
}

/* ===== メッセージエリア ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }

/* ===== メッセージ共通 ===== */
.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
  animation: fadeSlideIn 0.22s ease;
}

/* ===== メッセージ本体ラッパー（吹き出し＋フィードバック） ===== */
.message-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

/* ===== フィードバックエリア ===== */
.feedback-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 4px;
}

/* 評価エリア＋コメントエリアを横並びにする行 */
.feedback-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 評価エリア：Good/Bad ボタンのみを格納 */
.feedback-rating-area {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* コメントエリア：💬ボタン＋送信済みメッセージのみを格納 */
.feedback-comment-area {
  display: flex;
  align-items: center;
  gap: 6px;
}

.feedback-btn {
  background: none;
  border: 1.5px solid #d4d4d4;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #c0c0c0;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s, opacity 0.15s;
}
.feedback-btn:hover:not(:disabled) {
  border-color: #999;
  color: #666;
}
/* 👍 アクティブ */
.feedback-btn.good.active {
  border-color: #1a73e8;
  color: #1a73e8;
  background: rgba(26, 115, 232, 0.08);
}
/* 👎 アクティブ */
.feedback-btn.bad.active {
  border-color: #e53935;
  color: #e53935;
  background: rgba(229, 57, 53, 0.08);
}
/* 選択されなかった側をグレーアウト */
.feedback-btn.disabled,
.feedback-btn.dimmed {
  opacity: 0.2;
  cursor: default;
}
/* 💬 アクティブ（コメントパネル展開中） */
.feedback-btn.comment.active {
  border-color: #888;
  color: #555;
  background: rgba(0, 0, 0, 0.05);
}

/* 送信済みメッセージ */
.feedback-thanks {
  display: none;
  font-size: 11px;
  color: #999;
  margin-left: 4px;
}
.feedback-thanks.visible {
  display: inline;
}

/* コメントパネル（折りたたみアニメーション） */
.feedback-comment-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 0;
}
.feedback-comment-panel.open {
  max-height: 120px;
  opacity: 1;
}

.feedback-comment-input {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.feedback-comment-input:focus {
  border-color: #1a73e8;
}

.feedback-comment-submit {
  align-self: flex-end;
  background: linear-gradient(135deg, #1a73e8, #1558b0);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 5px 16px;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}
.feedback-comment-submit:hover { opacity: 0.88; }
.feedback-comment-submit:active { transform: scale(0.96); }
.feedback-comment-submit.disabled {
  background: #ccc;
  cursor: default;
  opacity: 0.5;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ボットメッセージ（左寄せ） */
.message.bot {
  align-self: flex-start;
}

/* ユーザーメッセージ（右寄せ） */
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* ===== アバター ===== */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8eaf0;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-avatar {
  overflow: hidden;
}

.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

/* ===== 吹き出し ===== */
.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ボット吹き出し：左・白系 */
.message.bot .bubble {
  background: #ffffff;
  color: #222;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* ユーザー吹き出し：右・青系 */
.message.user .bubble {
  background: linear-gradient(135deg, #1a73e8, #1558b0);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(26, 115, 232, 0.35);
}

/* リンク */
.bubble a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}
.message.bot .bubble a { color: #1a73e8; }

/* 動画リンク（YouTube） */
.bubble a.link-video {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: #c00;
  background: rgba(200, 0, 0, 0.07);
  border: 1px solid rgba(200, 0, 0, 0.22);
  border-radius: 5px;
  padding: 2px 8px;
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
  transition: background 0.15s;
}
.bubble a.link-video:hover {
  background: rgba(200, 0, 0, 0.15);
  text-decoration: none;
}
/* ユーザー吹き出し（青背景）の上では色を反転 */
.message.user .bubble a.link-video {
  color: #ffc0c0;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 180, 180, 0.35);
}

/* ===== タイピングインジケーター ===== */
.message.typing .bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  min-width: 60px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ===== フッター（入力エリア） ===== */
.chat-footer {
  background: #fff;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 1.5px solid #ddd;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s;
  background: #f9f9f9;
}

.chat-input:focus {
  border-color: #1a73e8;
  background: #fff;
}

.chat-input::placeholder { color: #aaa; }

.send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1a73e8, #1558b0);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.4);
}

.send-button:hover  { transform: scale(1.07); box-shadow: 0 4px 12px rgba(26, 115, 232, 0.5); }
.send-button:active { transform: scale(0.95); }
.send-button:disabled { background: #ccc; box-shadow: none; cursor: default; transform: none; }

/* ===== よくある質問サジェスト ===== */
.suggest-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  width: 100%;
  max-width: 88%;
  animation: fadeSlideIn 0.25s ease;
  transition: opacity 0.2s ease, max-height 0.3s ease;
}

.suggest-row.hidden {
  display: none;
}

.suggest-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 2px;
}

.suggest-btn {
  background: #fff;
  color: #1a73e8;
  border: 1.5px solid #1a73e8;
  border-radius: 18px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  line-height: 1.45;
  transition: background 0.15s, color 0.15s, transform 0.12s;
  box-shadow: 0 1px 3px rgba(26, 115, 232, 0.12);
}

.suggest-btn:hover {
  background: #1a73e8;
  color: #fff;
  transform: translateX(3px);
}

.suggest-btn:active {
  transform: scale(0.97);
}

/* ===== レスポンシブ（PC では横に余白） ===== */
@media (min-width: 600px) {
  body {
    align-items: center;
  }
  .chat-container {
    position: relative; /* PCではfixedを解除して中央配置 */
    top: auto; left: auto; right: auto; bottom: auto;
    width: 100%;
    max-width: 600px;
    height: 90vh;
    border-radius: 16px;
  }
}
