/* ==========================================================================
   クッキーラン情報サイト - 共通スタイル (common.css)
   全ページで読み込む共通CSS。ページ固有のスタイルはここに追加しない。
   ========================================================================== */

:root {
  /* --- カラートークン（クッキー菓子っぽい、あたたかくかわいい配色） --- */
  --bg: #FFF6E9;           /* バニラクリーム */
  --surface: #FFFFFF;
  --surface-alt: #FBEAD2;  /* キャラメル寄りのベージュ */
  --border: #F0DDBF;

  --text: #4A3226;         /* チョコレートブラウン */
  --text-muted: #8A6A50;
  --text-faint: #B49A82;

  --accent: #E8637F;       /* いちご/ラズベリーピンク（サイト共通アクセント） */
  --accent-soft: #FDE7EC;
  --accent-dark: #C94764;
  --accent-visited: #B98A98; /* クリック済みリンクの色（くすんだローズ） */

  --kakao: #D98A2E;        /* カカオ版タグカラー（キャラメルゴールド） */
  --kakao-soft: #FCEED2;
  --classic: #2F9AA0;      /* クラシック版タグカラー（ミントティール） */
  --classic-soft: #DFF4F2;

  --focus: #2C7FBF;

  /* --- タイポグラフィ --- */
  --font-display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --font-body: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;

  /* --- レイアウト寸法 --- */
  --header-h: 64px;
  --header-min-h: 64px;
  --sidebar-w: 272px;
  --content-max: 760px;

  --radius-s: 8px;
  --radius-m: 16px;
  --shadow-card: 0 3px 12px rgba(74, 50, 38, .08);
}

/* ---------- リセット / 基本設定 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  overflow-x: hidden;
  overflow-x: clip;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2px; }

/* クリック済みのリンクは色を変える（本文中のリンクのみ対象。
   サイドメニュー・フッター等はそれぞれ専用の色ルールがあるため対象外） */
.content a:visited { color: var(--accent-visited); }

button { font: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   ヘッダー
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header__row {
  max-width: 1280px;
  margin: 0 auto;
  min-height: var(--header-min-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  flex-wrap: wrap;
}

/* ハンバーガーメニュー（CSSで描画。スマートフォン表示のみ出現） */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
}
.menu-toggle span,
.menu-toggle::before,
.menu-toggle::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.menu-toggle::before { top: 14px; }
.menu-toggle span     { top: 19px; }
.menu-toggle::after   { top: 24px; }

.site-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .02em;
  margin-right: auto;
  line-height: 1.3;
}
.site-brand:hover { color: var(--accent); }
.site-brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: .625rem;
  color: var(--text-faint);
  letter-spacing: .08em;
}

/* ゲーム表示切り替え（セグメントコントロール） */
.version-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: var(--surface-alt);
  gap: 2px;
}
.version-switch button {
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: .8125rem;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
/* 選択状態の見た目は aria-pressed ではなく、html[data-version] を基準に
   CSSだけで決める。aria-pressed属性自体はJS側（script.js）が引き続き
   更新し、スクリーンリーダー等への状態通知には使う（見た目には使わない）。
   こうすることで、JSの初期化（DOMContentLoaded後）を待たずに、
   headの早期スクリプトがhtmlのdata-versionを設定した瞬間に
   ボタンの色も正しく決まり、「両バージョン」表示が一瞬見えるちらつきを防ぐ。 */
html[data-version="kakao"]   .version-switch button[data-version-btn="kakao"],
html[data-version="classic"] .version-switch button[data-version-btn="classic"],
html[data-version="both"]    .version-switch button[data-version-btn="both"] {
  background: var(--accent);
  color: #fff;
}
html[data-version="kakao"]   .version-switch button[data-version-btn="kakao"]   { background: var(--kakao); }
html[data-version="classic"] .version-switch button[data-version-btn="classic"] { background: var(--classic); }

/* ==========================================================================
   レイアウト（サイドメニュー + メイン）
   ========================================================================== */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 12px 40px;
  border-right: 1px solid var(--border);
}

.sidebar-close { display: none; }

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 32px 24px 80px;
}

.content { max-width: var(--content-max); overflow-wrap: anywhere; }

/* ---------- サイドメニュー：カテゴリ（アコーディオン） ---------- */
.sidebar-category { margin-bottom: 4px; }

.category-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .875rem;
  color: var(--text);
  padding: 10px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  text-align: left;
}
.category-toggle:hover { background: var(--surface-alt); }

.category-toggle .chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  flex: 0 0 auto;
  margin-top: -3px;
}
.sidebar-category.is-open .category-toggle .chevron { transform: rotate(45deg); margin-top: 0; }

.category-pages {
  list-style: none;
  margin: 2px 0 8px 12px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border);
  display: grid;
  gap: 1px;
}
.sidebar-category:not(.is-open) .category-pages { display: none; }

.category-pages a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-s);
  font-size: .8125rem;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.5;
}
.category-pages a:hover,
.category-pages a.is-current {
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 3px 0 0 var(--accent);
}
.category-pages a.is-current { font-weight: 700; }

/* ---------- スマートフォン：ドロワー化 ---------- */
.sidebar-backdrop { display: none; }

@media (max-width: 899px) {
  .menu-toggle { display: inline-block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(84vw, 320px);
    max-height: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 14px 40px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 200;
    box-shadow: 12px 0 32px rgba(30, 22, 12, .18);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(30, 22, 12, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    z-index: 190;
  }
  .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    margin-left: auto;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
  }

  .main { padding: 24px 16px 64px; }
}

/* ==========================================================================
   本文タイポグラフィ
   ========================================================================== */
.breadcrumb {
  font-size: .75rem;
  color: var(--text-faint);
  margin: 0 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.breadcrumb a { color: var(--text-faint); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb .current { color: var(--text-muted); }
.breadcrumb .sep { color: var(--border); }

.content h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem);
  font-weight: 900;
  margin: 0 0 6px;
  line-height: 1.4;
}

.content .lead {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 24px;
}

.content h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 40px 0 12px;
  padding-left: 14px;
  border-left: 5px solid var(--accent);
  line-height: 1.5;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.content h2:first-of-type { margin-top: 8px; }

.content h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.content h3::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.content p { margin: 0 0 16px; }
.content ul, .content ol { margin: 0 0 16px; padding-left: 1.4em; }
.content li { margin-bottom: 6px; }
.content strong { color: var(--text); }

/* 外部リンクにCSSで矢印アイコンを付与（絵文字は使わない） */
.content a[href^="http"]::after,
.related-links a[href^="http"]::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, 1px);
  margin-left: 5px;
  vertical-align: middle;
}

/* ==========================================================================
   セクション単位のメタ表示（各見出し直下の「対象バージョン／情報の性質」）
   ========================================================================== */
.section-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px 14px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  font-size: .6875rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}
.meta-chip.v-common      { }
.meta-chip.v-kakao-only  { color: var(--kakao);   border-color: var(--kakao);   background: var(--kakao-soft); }
.meta-chip.v-classic-only{ color: var(--classic); border-color: var(--classic); background: var(--classic-soft); }
.meta-chip.v-mixed       { background: linear-gradient(90deg, var(--kakao-soft), var(--classic-soft)); }

/* ==========================================================================
   版別ブロック（::: kakao / ::: classic から変換）
   ========================================================================== */
.v-block {
  border-left: 4px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 14px 16px 2px;
  margin: 0 0 18px 14px;
}
.v-block .v-label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 6px;
}
.v-block.v-kakao          { border-color: var(--kakao);   background: var(--kakao-soft); }
.v-block.v-kakao .v-label { color: var(--kakao); }
.v-block.v-classic          { border-color: var(--classic);   background: var(--classic-soft); }
.v-block.v-classic .v-label { color: var(--classic); }

/* 表示切り替えの本体：html[data-version] によって出し分け */
html[data-version="kakao"]   .v-block.v-classic { display: none; }
html[data-version="classic"] .v-block.v-kakao   { display: none; }
/* both のときは両方表示（打ち消しルールなし） */

/* ==========================================================================
   注記・補足（TBD／情報不足など、版に関係なく常時表示する注意書き）
   ========================================================================== */
.callout {
  border: 1px dashed var(--text-faint);
  border-radius: var(--radius-s);
  padding: 12px 16px;
  margin: 0 0 18px 14px;
  font-size: .9rem;
  color: var(--text-muted);
  background: var(--surface);
}
.callout strong { color: var(--text); }

/* ==========================================================================
   ページ内目次
   ========================================================================== */
.page-toc {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  margin: 0 0 28px;
  box-shadow: var(--shadow-card);
}
.page-toc summary {
  cursor: pointer;
  padding: 12px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .875rem;
  list-style: none;
}
.page-toc summary::-webkit-details-marker { display: none; }
.page-toc summary::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  margin-right: 10px;
  transition: transform .15s ease;
}
.page-toc[open] summary::before { transform: rotate(45deg); }
.page-toc ol {
  margin: 0;
  padding: 0 16px 14px 34px;
  font-size: .8125rem;
  columns: 1;
}
.page-toc li { margin-bottom: 6px; }
.page-toc a { color: var(--text-muted); text-decoration: none; }
.page-toc a:hover { color: var(--accent); }

@media (min-width: 700px) {
  .page-toc ol { columns: 2; column-gap: 24px; }
}

/* ==========================================================================
   表
   ========================================================================== */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 20px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
}
.content table { border-collapse: collapse; width: 100%; font-size: .875rem; }
.content th, .content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  color: var(--text);
}
.content thead th {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: var(--font-display);
}
.content th a, .content td a { color: var(--accent); }
.content th a:visited, .content td a:visited { color: var(--accent-visited); }
.content tbody tr { background: var(--surface); }
.content tr:last-child td { border-bottom: 0; }

/* ==========================================================================
   関連ページ・フッター
   ========================================================================== */
.related-links {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text-muted);
}
.related-links strong { color: var(--text); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 20px 40px;
  text-align: center;
  color: var(--text-faint);
  font-size: .75rem;
}
.site-footer .footer-line {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.site-footer .footer-line__group {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.site-footer .footer-line a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.site-footer .footer-line a:hover {
  color: var(--accent-dark);
  text-decoration-thickness: 2px;
}
.site-footer .footer-line .sep {
  color: var(--border);
}

/* ==========================================================================
   装飾ブロック（::: hero ... ::: から生成）
   トップページの「はじめての方はこちら」のような、目立たせたい案内に使う。
   ========================================================================== */
.hero-box {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-radius: var(--radius-m);
  padding: 24px 26px;
  margin: 0 0 32px;
  box-shadow: var(--shadow-card);
}
.hero-box::before {
  /* 丸い装飾（クッキーのモチーフ的な、ゆるい円のアクセント） */
  content: "";
  position: absolute;
  top: -36px;
  right: -36px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}
.content .hero-box h2 {
  position: relative;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #fff;
}
.content .hero-box p {
  position: relative;
  color: rgba(255, 255, 255, .92);
  margin: 0 0 6px;
}
.content .hero-box strong { color: #fff; }
.content .hero-box a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
}
.content .hero-box a:hover { background: var(--accent-soft); }
.content .hero-box a:visited { color: var(--accent-dark); }
.content .hero-box a[href^="http"]::after { border-color: var(--accent-dark); }

/* ==========================================================================
   リンクカード（連続する h3+ul をビルドツールが自動でグループ化したもの）
   カテゴリ一覧のような「リンクの列挙」を、事務的な一覧ではなくカード風に見せる。
   ========================================================================== */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin: 0 0 28px;
}
.link-group {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease, box-shadow .15s ease;
}
.link-group:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(74, 50, 38, .13);
}
.link-group h3 { margin: 0 0 12px; }
.link-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.link-group li { margin: 0; }
.link-group a { font-size: .8125rem; color: var(--accent); text-decoration: underline; }
.link-group a:hover { color: var(--accent-dark); }
.link-group a:visited { color: var(--accent-visited); }

@media (prefers-reduced-motion: reduce) {
  .link-group:hover { transform: none; }
}

/* ==========================================================================
   AIチャットウィジェット
   ========================================================================== */
.cr-chat-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 250;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95em;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease, background .15s ease;
  /* 長押しで画像保存・コピーメニューが出るのを抑える（JS側のcontextmenu/
     dragstart抑止と合わせて対応。iOS Safari向けに-webkit-touch-calloutが必要）。 */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.cr-chat-toggle:hover { background: var(--accent-dark); transform: translateY(-2px); }
.cr-chat-toggle__icon { font-size: 1.2em; }

.cr-chat-panel {
  position: fixed;
  z-index: 260;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(74, 50, 38, .25);
  /* スマホでソフトキーボードが開いた際、JS側(chat-widget.js)がvisualViewportの
     高さ・スクロール位置に合わせてheight/transformを直接書き換える。それまでの
     初期値としてもvhではなく100%を指定し、アドレスバー等の可変UIに巻き込まれにくく
     している。transformはキーボード表示時のレイアウトビューポートのスクロール分だけ
     パネルを追従させるためのもの（通常時は空文字でtranslateYなし）。 */
  height: 100%;
  transform: translateY(0);
  transition: transform .12s ease-out;
  /* 長押しでの画像保存・コピーメニュー、テキスト選択を抑制する（JS側の
     contextmenu/dragstart抑止と合わせて対応）。入力欄(textarea)だけは
     通常の編集操作が必要なので下で個別に解除する。 */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.cr-chat-panel[hidden] { display: none; }

/* PC: 画面右側に固定幅のパネルとして開く */
@media (min-width: 900px) {
  .cr-chat-panel {
    top: 0;
    right: 0;
    bottom: 0;
    height: auto;
    width: 380px;
    max-width: 90vw;
    border-left: 1px solid var(--border);
  }
}

/* スマホ: 画面いっぱいに開く */
@media (max-width: 899px) {
  .cr-chat-panel {
    top: 0;
    left: 0;
    right: 0;
    width: auto;
  }
  /* パネルが全画面表示になっている間は、右下の起動ボタンは隠す */
  .cr-chat-panel:not([hidden]) ~ .cr-chat-toggle {
    display: none;
  }
}

.cr-chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  /* ヘッダー・フォームは常に画面内に固定表示し、伸び縮みしない
     （中央の.cr-chat-panel__messagesだけがスクロール・伸縮する） */
  flex-shrink: 0;
}
.cr-chat-panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
}
.cr-chat-panel__close {
  border: none;
  background: transparent;
  font-size: 1.5em;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}
.cr-chat-panel__close:hover { color: var(--text); }

.cr-chat-panel__messages {
  flex: 1;
  min-height: 0; /* flexアイテムがはみ出さず正しく内部スクロールするために必要 */
  overflow-y: auto;
  overscroll-behavior: contain; /* メッセージ欄の端まで達しても背後のページへスクロールが伝播しないようにする */
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cr-chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.cr-chat-row--user {
  justify-content: flex-end;
}
.cr-chat-row--bot {
  justify-content: flex-start;
}

.cr-chat-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft, var(--surface-alt));
  font-size: 1em;
}

.cr-chat-msg {
  margin: 0;
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--radius-m);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cr-chat-msg--user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cr-chat-msg--bot {
  background: var(--surface-alt);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.cr-chat-row--thinking .cr-chat-msg--bot {
  color: var(--text-muted);
  font-style: italic;
}
.cr-chat-msg--error {
  max-width: 100%;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9em;
  text-align: center;
  width: 100%;
}

.cr-chat-panel__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.cr-chat-panel__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.95em;
  max-height: 120px;
  /* 親(.cr-chat-panel)のuser-select:none / touch-calloutを入力欄だけ解除する。
     テキストの選択・コピー・貼り付けは通常の入力操作として必要なため。 */
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}
.cr-chat-panel__input:focus { outline: 3px solid var(--focus); }
.cr-chat-panel__send {
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-s);
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85em;
  line-height: 1.3;
  cursor: pointer;
  max-width: 130px;
}
.cr-chat-panel__send:hover { background: var(--accent-dark); }
.cr-chat-panel__send:disabled { background: var(--text-faint); cursor: not-allowed; }

.cr-chat-panel__disclaimer {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 0.75em;
  color: var(--text-faint);
  text-align: center;
}
