/* AI アシスタント。リサーチサイトと Wix の埋め込みで共通。サイトの色（--color-*）があれば使い、無ければ下の値 */
[data-sessa-chat] {
  --c-ink: var(--color-ink, #16181d); --c-ink2: var(--color-ink-2, #5b616e); --c-line: var(--color-line, #e3e5e9);
  --c-band: var(--color-band, #f4f5f7); --c-paper: var(--color-paper, #ffffff); --c-brand: var(--color-brand, #16181d); --c-brand2: var(--color-brand-2, #33363d);
  --c-err: #a40000; --r-l: 16px; --r-m: 12px; --r-s: 8px;
  font-family: var(--font-body, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif);
  position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; color: var(--c-ink);
}
[data-sessa-chat][hidden] { display: none; }
.schat__fab { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--c-brand); color: var(--c-paper); font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,.14); transition: transform .15s ease, background-color .15s ease; }
.schat__fab:hover { background: var(--c-brand2); transform: translateY(-1px); }
.schat__fab { padding-left: 8px; }
.schat__ava { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--c-paper); border: 1px solid var(--c-line); image-rendering: pixelated; }
.schat__ava--fab { width: 36px; height: 36px; border: 0; }
.is-open .schat__fab { display: none; }
.schat__panel { width: min(420px, calc(100vw - 48px)); height: min(680px, calc(100vh - 48px)); display: flex; flex-direction: column; background: var(--c-paper); border: 1px solid var(--c-line); border-radius: var(--r-l); box-shadow: 0 6px 24px rgba(0,0,0,.14); overflow: hidden; }
.schat__panel[hidden] { display: none; }
.schat__head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 8px 8px 24px; border-bottom: 1px solid var(--c-line); }
.schat__head { padding-left: 16px; }
.schat__head h2 { font-size: 1rem; margin: 0; line-height: 1.4; }
.schat__who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.schat__pair { display: flex; }
.schat__pair .schat__ava { width: 40px; height: 40px; }
.schat__pair .schat__ava + .schat__ava { margin-left: -8px; }
.schat__names { display: flex; flex-direction: column; }
.schat__sub { font-size: .75rem; color: var(--c-ink2); }
.schat__row { display: flex; gap: 8px; align-items: flex-start; align-self: flex-start; max-width: 100%; }
.schat__row .schat__msg { max-width: calc(100% - 40px); }
.schat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
/* 考え中のひとりごと */
.schat__think { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.schat__tline { display: flex; gap: 8px; align-items: flex-end; animation: schat-in .24s ease-out both; }
.schat__tline--takuma { flex-direction: row-reverse; }
.schat__tbub { margin: 0; max-width: calc(100% - 48px); padding: 8px 16px; border-radius: var(--r-m); font-size: .875rem; line-height: 1.6; color: var(--c-ink2); background: var(--c-band); }
.schat__tline--sessa .schat__tbub { border-bottom-left-radius: 4px; }
.schat__tline--takuma .schat__tbub { background: var(--c-paper); border: 1px solid var(--c-line); border-bottom-right-radius: 4px; }
.schat__tname { display: block; font-size: .75rem; font-weight: 700; color: var(--c-ink); }
.schat__tbub .schat__dots { padding: 4px 0; }
@keyframes schat-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.schat__icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--c-ink2); cursor: pointer; }
.schat__icon:hover { background: var(--c-band); }
.schat__log { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.schat__msg { max-width: 92%; padding: 8px 16px; border-radius: var(--r-m); font-size: .9375rem; line-height: 1.75; overflow-wrap: anywhere; }
.schat__msg p { margin: 0 0 8px; } .schat__msg p:last-child { margin-bottom: 0; }
.schat__msg ul { margin: 0 0 8px; padding-left: 1.2em; } .schat__msg li { margin: 2px 0; }
.schat__msg a { color: inherit; text-decoration: underline; }
.schat__msg--ai { align-self: flex-start; background: var(--c-band); }
.schat__msg--me { align-self: flex-end; background: var(--c-brand); color: var(--c-paper); white-space: pre-wrap; }
.schat__msg--card { background: var(--c-paper); border: 1px solid var(--c-line); max-width: 100%; width: 100%; }
.schat__h { font-weight: 700; }
.schat__muted { color: var(--c-ink2); font-size: .875rem; }
.schat__dots { display: flex; gap: 4px; padding: 6px 0; }
.schat__dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--c-ink2); opacity: .35; animation: schat-dot 1s infinite ease-in-out; }
.schat__dots span:nth-child(2) { animation-delay: .15s; } .schat__dots span:nth-child(3) { animation-delay: .3s; }
@keyframes schat-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: .8; transform: translateY(-2px); } }
.schat__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px; flex: none; }
.schat__chips:empty { display: none; }
.schat__chip { min-height: 32px; padding: 4px 12px; line-height: 1.4; border: 1px solid var(--c-line); border-radius: 999px; background: var(--c-paper); color: var(--c-ink); font: inherit; font-size: .8125rem; cursor: pointer; text-align: left; }
.schat__chip:hover { border-color: var(--c-ink); }
.schat__form { display: flex; gap: 8px; align-items: flex-end; padding: 8px 16px 8px 24px; border-top: 1px solid var(--c-line); }
.schat__form textarea { flex: 1; resize: none; border: 1px solid var(--c-line); border-radius: var(--r-s); padding: 8px; font: inherit; font-size: 1rem; color: inherit; background: var(--c-paper); max-height: 160px; }
.schat__send { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--r-s); background: var(--c-brand); color: var(--c-paper); cursor: pointer; }
.schat__send:disabled { opacity: .4; cursor: default; }
.schat__foot { display: flex; flex-direction: column; gap: 4px; padding: 0 24px 16px; }
.schat__textbtn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: var(--c-ink); font: inherit; font-size: .875rem; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.schat__note { margin: 0; font-size: .75rem; line-height: 1.6; color: var(--c-ink2); }
.schat__lead { display: flex; flex-direction: column; gap: 8px; }
.schat__field { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; font-weight: 600; }
.schat__field input, .schat__field textarea { font: inherit; font-weight: 400; font-size: 1rem; padding: 8px; border: 1px solid #bbb; border-radius: var(--r-s); color: var(--c-ink); background: var(--c-paper); }
.schat__check { display: flex; gap: 8px; align-items: flex-start; font-size: .8125rem; line-height: 1.6; }
.schat__check input { margin-top: 4px; }
.schat__err { margin: 0; color: var(--c-err); font-size: .875rem; }
.schat__btn { align-self: flex-start; min-height: 44px; padding: 0 24px; border: 0; border-radius: var(--r-s); background: var(--c-brand); color: var(--c-paper); font: inherit; font-weight: 700; cursor: pointer; }
.schat__btn:disabled { opacity: .5; }
[data-sessa-chat] button:focus-visible, [data-sessa-chat] textarea:focus-visible, [data-sessa-chat] input:focus-visible, [data-sessa-chat] a:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; transition: none; }
/* ---- ChatGPT のような答え方：AI の答えは囲まずに本文として、自分の発言は右の薄い吹き出し ---- */
.schat__panel { position: relative; }
.schat__log { gap: 16px; }
.schat__row { width: 100%; }
.schat__row .schat__msg { max-width: none; flex: 1; min-width: 0; }
.schat__msg--ai { background: transparent; padding: 4px 0 0; font-size: 1rem; line-height: 1.8; }
.schat__msg--me { background: var(--c-band); color: var(--c-ink); border-radius: 18px; padding: 8px 16px; max-width: 80%; }
.schat__msg--card { padding: 16px; }
.schat__msg p { margin: 0 0 12px; }
.schat__msg h3.schat__h, .schat__msg h4.schat__h { margin: 16px 0 8px; line-height: 1.5; font-weight: 700; }
.schat__msg h3.schat__h { font-size: 1.0625rem; } .schat__msg h4.schat__h { font-size: 1rem; }
.schat__msg > :first-child { margin-top: 0; }
.schat__msg ul, .schat__msg ol { margin: 0 0 12px; padding-left: 1.4em; }
.schat__msg li { margin: 4px 0; } .schat__msg li > ul { margin: 4px 0 0; }
.schat__msg strong { font-weight: 700; }
.schat__msg hr { border: 0; border-top: 1px solid var(--c-line); margin: 16px 0; }
.schat__msg blockquote { margin: 0 0 12px; padding: 4px 0 4px 12px; border-left: 3px solid var(--c-line); color: var(--c-ink2); }
.schat__msg code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; background: var(--c-band); padding: 1px 4px; border-radius: 4px; }
.schat__msg pre { margin: 0 0 12px; padding: 12px; background: var(--c-band); border-radius: var(--r-s); overflow-x: auto; }
.schat__msg pre code { background: none; padding: 0; }
.schat__table { margin: 0 0 12px; overflow-x: auto; }
.schat__table table { border-collapse: collapse; width: 100%; font-size: .875rem; line-height: 1.6; }
.schat__table th, .schat__table td { border-bottom: 1px solid var(--c-line); padding: 6px 8px; text-align: left; vertical-align: top; }
.schat__table th { font-weight: 700; border-bottom-color: var(--c-ink2); white-space: nowrap; }
.schat__acts { display: flex; gap: 4px; margin-top: 4px; }
.schat__act { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 8px; border: 0; border-radius: var(--r-s); background: transparent; color: var(--c-ink2); font: inherit; font-size: .8125rem; cursor: pointer; }
.schat__act:hover { background: var(--c-band); color: var(--c-ink); }
.schat__tools { display: flex; gap: 0; }
/* ---- 大きさを変える：窓の上端・左端・左上の角、入力欄との境目 ---- */
.schat__grip { position: absolute; z-index: 2; touch-action: none; }
.schat__grip--top { top: 0; left: 16px; right: 0; height: 8px; cursor: ns-resize; }
.schat__grip--left { top: 16px; bottom: 0; left: 0; width: 8px; cursor: ew-resize; }
.schat__grip--corner { top: 0; left: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.schat__grip--corner::before { content: ""; position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; border-top: 2px solid var(--c-ink2); border-left: 2px solid var(--c-ink2); border-top-left-radius: 4px; opacity: .45; }
.schat__panel:hover .schat__grip--corner::before { opacity: .8; }
.schat__split { flex: none; height: 12px; margin-bottom: -12px; position: relative; z-index: 1; cursor: ns-resize; touch-action: none; display: grid; place-items: center; }
.schat__split::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--c-line); }
.schat__split:hover::before, .schat__split:focus-visible::before, .is-resizing .schat__split::before { background: var(--c-ink2); }
.schat__split:focus-visible { outline: 2px solid var(--c-brand); outline-offset: -2px; }
.schat__form { padding-top: 16px; }
.schat__form textarea.is-sized { max-height: none; }
.is-resizing, .is-resizing * { user-select: none; }
[data-sessa-chat].is-max .schat__panel { width: calc(100vw - 48px); height: calc(100vh - 48px); max-width: 1100px; }
@media (max-width: 600px) {
  .schat__grip--left, .schat__grip--corner { display: none; }
  .schat__grip--top { left: 0; height: 16px; }
  .schat__grip--top::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--c-line); }
  .schat__max { display: none; }
}
@media (max-width: 600px) {
  [data-sessa-chat] { right: 16px; bottom: 16px; }
  [data-sessa-chat].is-open { left: 0; right: 0; bottom: 0; }
  .schat__panel { width: 100% !important; height: 88vh; border-radius: var(--r-l) var(--r-l) 0 0; }
  .schat__fab span { display: none; } .schat__fab { width: 56px; height: 56px; padding: 0; justify-content: center; }
  .schat__ava--fab { width: 44px; height: 44px; }
}
/* 埋め込み（Wix の枠の中）：枠いっぱいに出す */
[data-sessa-chat].is-embed { position: static; inset: auto; display: block; height: 100vh; }
.is-embed .schat__panel { width: 100%; height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .schat__fab, .schat__dots span, .schat__tline { transition: none; animation: none; } .schat__fab:hover { transform: none; } }
@media print { [data-sessa-chat] { display: none; } }
/* 同じ人が続けて話すときは、名前と顔を最初の1回だけにする */
.schat__tline--sessa + .schat__tline--sessa .schat__tname { display: none; }
.schat__tline--sessa + .schat__tline--sessa .schat__ava { visibility: hidden; }
.schat__think { gap: 4px; }
