/* SEPT — AI相談の会話パネル（「AIに相談」を押したときだけ読み込む）。vivitto の部品を元にしたもの。
   SEPTの紺（#071e48）・赤（#ad2349）・白に合わせる。パソコンは右下の小さな窓、スマホは画面いっぱい。 */
.vv-ai {
  --ai-ink: #ffffff; --ai-ink-2: #f4f7fb; --ai-ink-3: #e8eef6; --ai-text: #0b1530; --ai-mute: #5b6478;
  --ai-gold: #ad2349; --ai-gold-hi: #c42d57; --ai-line: #dce5f0; --ai-navy: #071e48;
  position: fixed; z-index: 90; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100vh - 112px)); height: min(640px, calc(100dvh - 112px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ai-ink); color: var(--ai-text); border: 1px solid var(--ai-line); border-radius: 18px;
  box-shadow: 0 30px 80px -24px rgba(7, 30, 72, 0.45);
  font-family: inherit;
  font-size: 14px; line-height: 1.8; letter-spacing: 0.02em; text-align: left;
  opacity: 0; transform: translateY(14px); transition: opacity 0.22s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.vv-ai.is-open { opacity: 1; transform: none; }
.vv-ai[hidden] { display: none; }
.vv-ai *, .vv-ai *::before, .vv-ai *::after { box-sizing: border-box; }
.vv-ai a { color: #1667a8; text-underline-offset: 3px; }
.vv-ai a:hover { color: var(--ai-navy); }
.vv-ai button { font: inherit; letter-spacing: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.vv-ai :focus-visible { outline: 3px solid #218ccc; outline-offset: 2px; }
.vv-ai__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.vv-ai__head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 16px; background: var(--ai-navy); color: #fff; }
.vv-ai__title { display: flex; align-items: center; gap: 9px; margin: 0; font-weight: 700; font-size: 15px; letter-spacing: 0.06em; }
.vv-ai__mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ai-gold); color: #fff; font: 800 11px/1 inherit; font-family: inherit; letter-spacing: 0; }
.vv-ai__badge { margin-right: auto; padding: 2px 9px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; color: #d9e2f2; font-size: 11px; line-height: 1.6; white-space: nowrap; }
.vv-ai__close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #fff; }
.vv-ai__close:hover { background: rgba(255, 255, 255, 0.12); }

.vv-ai__log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.vv-ai__log:focus-visible { outline-offset: -2px; }
.vv-ai__msg { max-width: 92%; padding: 11px 14px; border-radius: 14px; word-break: normal; overflow-wrap: anywhere; line-break: strict; }
.vv-ai__msg--bot { align-self: flex-start; background: var(--ai-ink-2); border: 1px solid var(--ai-line); border-top-left-radius: 4px; }
.vv-ai__msg--me { align-self: flex-end; background: #e6eefa; border: 1px solid #c9d8ee; border-top-right-radius: 4px; }
.vv-ai__msg--info { border-color: rgba(173, 35, 73, 0.4); background: #fff6f8; }
.vv-ai__msg:first-child { white-space: pre-line; }
.vv-ai__text { margin: 0; white-space: pre-line; }
.vv-ai__links { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--ai-line); }
.vv-ai__links-h { margin: 0 0 2px; color: var(--ai-mute); font-size: 12px; }
.vv-ai__links ul { margin: 0; padding: 0; list-style: none; }
.vv-ai__links li { margin: 2px 0; padding-left: 1.1em; text-indent: -1.1em; font-size: 13px; line-height: 1.7; }
.vv-ai__links li::before { content: "→ "; color: var(--ai-gold); }
.vv-ai__contact { display: inline-block; margin-top: 8px; font-weight: 500; }
.vv-ai__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.vv-ai__chip { min-height: 40px; padding: 6px 13px; border: 1px solid #b9cbe6; border-radius: 999px; background: #fff; color: var(--ai-navy); font-size: 13px; font-weight: 700; line-height: 1.4; }
.vv-ai__chip:hover { background: #eef4fc; border-color: var(--ai-navy); }

.vv-ai__handoff, .vv-ai__cancel { min-height: 42px; margin-top: 10px; padding: 8px 16px; border-radius: 999px; font-size: 13px; line-height: 1.4; font-weight: 700; }
.vv-ai__handoff { border: 0; background: var(--ai-gold); color: #fff; }
.vv-ai__handoff:hover { background: var(--ai-gold-hi); }
.vv-ai__cancel { border: 1px solid #b9cbe6; background: #fff; color: var(--ai-navy); font-weight: 700; }
.vv-ai__handoff--link { display: inline-flex; align-items: center; text-decoration: none; }
.vv-ai a.vv-ai__handoff { color: #fff; }
.vv-ai a.vv-ai__cancel { color: var(--ai-navy); }
.vv-ai__copied { margin: 8px 0 0; color: var(--ai-navy); font-size: 13px; font-weight: 700; }
.vv-ai__copied:empty { display: none; }
.vv-ai__draft { max-width: 100%; width: 100%; }
.vv-ai__draft-text { display: block; width: 100%; margin-top: 10px; padding: 10px 12px; border: 1px solid #b9cbe6; border-radius: 10px; background: #fff; color: var(--ai-text); font: inherit; font-size: 16px; line-height: 1.7; resize: vertical; }
.vv-ai__draft-row { display: flex; gap: 8px; flex-wrap: wrap; }

.vv-ai__thinking { padding: 14px 18px; }
.vv-ai__dots, .vv-ai__dots::before, .vv-ai__dots::after { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ai-gold); animation: vv-ai-dot 1.1s infinite ease-in-out; }
.vv-ai__dots { position: relative; margin: 0 12px; animation-delay: 0.15s; }
.vv-ai__dots::before, .vv-ai__dots::after { content: ""; position: absolute; top: 0; }
.vv-ai__dots::before { left: -11px; animation-delay: 0s; }
.vv-ai__dots::after { left: 11px; animation-delay: 0.3s; }
@keyframes vv-ai-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.vv-ai__form { position: relative; display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 10px 12px 20px; border-top: 1px solid var(--ai-line); background: var(--ai-ink-2); }
.vv-ai__input { flex: 1; min-height: 44px; max-height: 132px; padding: 10px 12px; border: 1px solid var(--ai-line); border-radius: 12px; background: var(--ai-ink); color: var(--ai-text); font: inherit; font-size: 15px; line-height: 1.6; resize: none; }
.vv-ai__input::placeholder { color: #8a93a6; }
.vv-ai__input:focus { border-color: var(--ai-navy); outline: none; }
.vv-ai__input:focus-visible { outline: 3px solid #218ccc; outline-offset: 1px; }
.vv-ai__send { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--ai-gold); color: #fff; }
.vv-ai__send:hover { background: var(--ai-gold-hi); }
.vv-ai__send:disabled, .vv-ai__wrap:disabled, .vv-ai__input:disabled { opacity: 0.45; cursor: not-allowed; }
.vv-ai__count { position: absolute; right: 70px; bottom: 2px; color: #8a93a6; font-size: 10px; line-height: 1.4; }

.vv-ai__foot { padding: 8px 14px 12px; background: var(--ai-ink-2); }
.vv-ai__wrap { width: 100%; min-height: 42px; padding: 6px 12px; border: 1px solid #b9cbe6; border-radius: 999px; background: #fff; color: var(--ai-navy); font-size: 13px; font-weight: 700; line-height: 1.4; }
.vv-ai__wrap:hover:not(:disabled) { background: #eef4fc; }
.vv-ai__wrap span { display: inline-block; }
.vv-ai__note { margin: 8px 0 0; color: var(--ai-mute); font-size: 11px; line-height: 1.65; letter-spacing: 0.01em; }
.vv-ai__note a { margin-left: 4px; color: var(--ai-mute); }

/* スマホ：画面いっぱい（下のボタンや「上へ戻る」に重ならない・後ろのページは動かさない） */
@media (max-width: 767px) {
  .vv-ai { inset: 0; width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .vv-ai__input { font-size: 16px; }       /* iPhone で入力欄が拡大されないように */
  .vv-ai__msg { max-width: 94%; font-size: 15px; }
  .vv-ai__form { padding-bottom: 20px; }   /* 入力欄の枠（フォーカス時）が字数の表示にかからないように */
  .vv-ai__foot { padding: 6px 12px max(10px, env(safe-area-inset-bottom)); }
  html.vv-ai-lock, html.vv-ai-lock body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .vv-ai { transition: none; transform: none; }
  .vv-ai__dots, .vv-ai__dots::before, .vv-ai__dots::after { animation: none; opacity: 0.7; }
}
@media print { .vv-ai { display: none; } }
