/* ============================================================
   AI相談チャット（右下）。中身は js/consult-chat.js が作る
   ・帯：少し紫寄りの赤（#CC1452。2026-10-29 ひーさん指定）。白い文字で 5.54:1
   ・会話の画面は明るい色にする（暗い背景だと「ひーさんの分身」のロゴの黒い文字が見えないため）
   ・重なり順：本文より上、メニュー（90〜100）・起動画面（9000）・カーソル（9500）より下
   ・左下に置く（このページは相談フォームが右側にあるため。2026-10-29 ひーさん指定）
   ============================================================ */
.cc {
  --cc-bar: #CC1452;
  --cc-bar-hover: #AD1046;
  --cc-panel: #F7F5FF;
  --cc-surface: #FFFFFF;
  --cc-text: #1A1433;
  --cc-muted: #5B5577;
  --cc-line: #E3DCFF;
  --cc-violet: #6B3BFF;      /* 閲覧者の吹き出し（白い文字で 5.7:1） */
  --cc-violet-ink: #4B1FD1;  /* 選択肢の文字 */
  position: fixed; left: 20px; bottom: 0; z-index: 85;
  width: min(380px, calc(100vw - 32px));
  font-family: var(--f-jp); color: var(--cc-text);
}
/* 帯の幅と左右の位置は、閉じていても開いていても同じにする（2026-10-29 ひーさん指定） */
.cc-bar {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 14px;
  border: 0; border-radius: 12px 12px 0 0; background: var(--cc-bar); color: #fff;
  font: 700 .95rem/1.4 var(--f-jp); text-align: left; cursor: pointer;
  box-shadow: 0 -6px 22px rgba(6, 4, 26, .45);
}
.cc-bar:hover { background: var(--cc-bar-hover); }
.cc-bar:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.cc-bar-title { flex: none; white-space: nowrap; }
/* ロゴは文字のすぐ右。高さは帯の文字とそろえる（上下に筆の払いがあるので 22px） */
.cc-bar-logo { flex: none; display: block; width: auto; height: 22px; }
.cc-bar-icon { flex: none; margin-left: auto; transition: transform .25s ease; }
.cc[data-state="open"] .cc-bar-icon { transform: rotate(180deg); }

.cc-panel {
  display: flex; flex-direction: column; height: min(560px, calc(100vh - 120px));
  background: var(--cc-panel); border: 1px solid var(--cc-line); border-top: 0; border-bottom: 0;
  box-shadow: 0 18px 40px rgba(6, 4, 26, .5); overflow: hidden;
}
.cc-panel[hidden] { display: none; }
.cc-log { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.cc-msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: .92rem; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.cc-msg--bot { position: relative; align-self: flex-start; background: var(--cc-surface); border: 1px solid var(--cc-line); border-top-left-radius: 4px; }
.cc-msg--user { align-self: flex-end; background: var(--cc-violet); color: #fff; border-top-right-radius: 4px; }
.cc-msg--draft { max-width: 100%; border-left: 3px solid var(--cc-bar); }
.cc-msg-label { display: block; margin-bottom: 4px; font-size: .78rem; font-weight: 700; color: var(--cc-muted); }
.cc-msg ul, .cc-msg ol { margin: 4px 0 0; padding-left: 1.3em; }
.cc-msg li + li { margin-top: 4px; }
/* AIの吹き出しが続いたときは、いちばん下の吹き出しの左下にだけロゴを付ける（話し手の名札） */
.cc-msg--bot.is-tail { margin-bottom: 24px; }
.cc-msg--bot.is-tail::after {
  content: ""; position: absolute; left: 2px; top: calc(100% + 5px); width: 64px; height: 18px;
  background: url("../hisan-bunshin-logo-v2.webp") left center / contain no-repeat;
}
.cc-typing { align-self: flex-start; display: flex; gap: 5px; padding: 12px 14px; }
.cc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--cc-muted); opacity: .35; animation: cc-blink 1.2s infinite ease-in-out; }
.cc-typing span:nth-child(2) { animation-delay: .2s; }
.cc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cc-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

.cc-actions { padding: 10px 16px 12px; border-top: 1px solid var(--cc-line); background: var(--cc-surface); display: flex; flex-wrap: wrap; gap: 8px; max-height: 46%; overflow-y: auto; }
.cc-actions:empty { display: none; }
.cc-choice {
  min-height: 40px; padding: 6px 14px; border: 1px solid var(--cc-violet); border-radius: 999px;
  background: var(--cc-surface); color: var(--cc-violet-ink); font: 700 .86rem/1.4 var(--f-jp); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.cc-choice:hover { background: rgba(107, 59, 255, .08); }
.cc-choice[aria-pressed="true"] { background: var(--cc-violet); color: #fff; }
.cc-send { min-height: 40px; padding: 6px 18px; border: 0; border-radius: 8px; background: var(--lime); color: var(--ink); font: 800 .88rem/1.4 var(--f-jp); cursor: pointer; }
.cc-send:disabled { opacity: .45; cursor: not-allowed; }
.cc-choice:focus-visible, .cc-send:focus-visible, .cc-input:focus-visible, .cc-ref a:focus-visible { outline: 2px solid var(--cc-bar); outline-offset: 2px; }
.cc-field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.cc-input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--cc-line); border-radius: 8px; background: #fff; font: 400 .92rem/1.6 var(--f-jp); color: var(--cc-text); resize: vertical; }
.cc-field-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cc-note { margin: 0; font-size: .76rem; line-height: 1.5; color: var(--cc-muted); }
/* 制作例のLP：選ぶボタンと「開く」リンクを1行に並べる */
.cc-refs { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.cc-ref { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-ref .cc-choice { flex: 1; text-align: left; border-radius: 10px; }
.cc-ref a { flex: none; font-size: .8rem; font-weight: 700; color: var(--cc-violet-ink); text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; }
.cc-foot { margin: 0; padding: 6px 16px 10px; background: var(--cc-surface); font-size: .7rem; line-height: 1.5; color: var(--cc-muted); }
.cc-foot a { color: inherit; text-decoration: underline; }
.cc-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* フッターのいちばん下（営業時間の行）が帯に隠れないように、帯の高さ（52px）ぶん余白を足す。
   帯を上げると、すぐ上の文字をかえって隠すため、文字のほうを帯の上に来るようにする（元の下の余白は 36px） */
.footer { padding-bottom: calc(36px + 52px); }

/* 左下の「動きを止める」ボタン（動きを減らす設定の人にだけ出る）は、帯のすぐ上にずらす */
html.sys-reduce .motion-toggle, html.reduce-motion .motion-toggle { bottom: 64px; }
/* チャットを開いている間は、会話の画面に重なるので隠す（閉じれば戻る） */
html.cc-open .motion-toggle { display: none; }

/* スマホ：画面の下半分の大きさで、左右いっぱいに出す。閉じている帯も左右いっぱい */
@media (max-width: 640px) {
  .cc { left: 0; width: 100%; }
  .cc-panel { height: calc(50vh - 52px); height: calc(50dvh - 52px); border-left: 0; border-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cc-bar-icon { transition: none; }
  .cc-typing span { animation: none; opacity: .6; }
}
