/* 相関図AI（日本語）：会話で作る＋読み取りの確認＋本文の根拠 */
* { box-sizing: border-box; }
body.ai-chat { margin: 0; background: #f6f7fb; color: #17243d; line-height: 1.6; font-family: Inter, 'Noto Sans JP', Meiryo, system-ui, sans-serif; }
:where(.ai-chat) :where(button, input, textarea, select) { font: inherit; color: inherit; }
.ai-chat button, .ai-chat summary, .ai-chat label { cursor: pointer; }
.ai-chat button:disabled { cursor: default; opacity: .55; }
.ai-chat [hidden] { display: none !important; }
.ai-chat :focus-visible { outline: 2px solid #4f5fd6; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 画面の高さに収める全画面チャット：会話と図だけが中でスクロールし、入力欄は常に画面の下 */
body.ai-chat { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.ai-chat > header.gh { flex: none; }
.chat-main { position: relative; flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; }
.chat-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px max(20px, calc(50% - 480px)) 14px; }
.chat-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.chat-head h1 { margin: 0; font-size: 28px; line-height: 1.35; font-weight: 900; letter-spacing: -.03em; }
.chat-eyebrow { display: inline-flex; gap: 4px; align-items: center; margin-bottom: 6px; padding: 3px 10px; border-radius: 999px; background: #eef0ff; color: #3b45b8; font-size: 12px; font-weight: 800; letter-spacing: 0; }
.chat-head p { margin: 4px 0 0; color: #5b6880; font-size: 13.5px; }
.chat-head-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.about-btn { padding: 7px 13px; border-radius: 999px; border: 1px solid #dfe4ee; background: #fff; color: #334155; font-size: 12.5px; font-weight: 800; }
.about-btn:hover { background: #f8fafc; }
.chat-quota { flex: none; padding: 7px 13px; border-radius: 999px; background: #fff; border: 1px solid #e2e7f0; color: #475569; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.chat-quota.is-limit { color: #b45309; border-color: #fcd34d; background: #fffbeb; }

/* 会話 */
.chat-thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg-av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 900; color: #fff; background: linear-gradient(135deg, #1d3fe0, #8b5cf6); }
.msg-body { min-width: 0; max-width: 100%; padding: 13px 16px; border-radius: 4px 18px 18px 18px; background: #fff; border: 1px solid #e6e9f2; box-shadow: 0 6px 18px rgba(15, 23, 42, .04); font-size: 14.5px; line-height: 1.75; }
.msg-body p { margin: 0; }
.msg-body p + p, .msg-body p + .msg-actions, .msg-body .msg-actions + p { margin-top: 8px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .msg-av { background: #cbd5e1; color: #334155; font-size: 10px; }
.msg.me .msg-body { max-width: min(620px, 100%); border-radius: 18px 4px 18px 18px; background: #0b2ec7; color: #fff; border: 0; }
.msg.me .msg-body small { display: block; margin-top: 4px; opacity: .8; font-size: 12px; }
.msg-tag { display: inline-block; margin-bottom: 4px; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: 11.5px; font-weight: 800; }
.msg.is-error .msg-body { border-color: #fecaca; background: #fff7f7; }
.msg.is-warn .msg-body, .msg.is-limit .msg-body { border-color: #fde68a; background: #fffdf3; }
.msg-note { color: #64748b; font-size: 12.5px; }
.msg-names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-names span { padding: 2px 10px 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, #fff); color: #1e293b; font-size: 12.5px; font-weight: 800; border-left: 4px solid var(--c); }
.msg-actions, .msg-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-chips { margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 7px 13px; border-radius: 999px; border: 1px solid #d8def8; background: #f5f7ff; color: #1e3a8a; font-size: 13px; font-weight: 800; text-decoration: none; }
.chip.solid { background: #0b2ec7; border-color: #0b2ec7; color: #fff; }
.msg-loading { display: flex; align-items: center; gap: 10px; color: #475569; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #6366f1; animation: chat-dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.intro-tips { margin: 8px 0 0; padding-left: 18px; color: #475569; font-size: 13px; }

/* 結果 */
.chat-result { scroll-margin-top: 12px; margin-top: 16px; border-radius: 20px; background: #fff; border: 1px solid #e3e8f1; box-shadow: 0 14px 34px rgba(15, 23, 42, .06); overflow: hidden; }
.chat-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 14px 18px; border-bottom: 1px solid #eef1f6; }
.chat-result-head h2 { margin: 0; font-size: 16px; font-weight: 900; }
.chat-result-head small { display: block; color: #64748b; font-size: 12.5px; }
.result-tip { color: #64748b; font-size: 12.5px; }
.chat-split { display: grid; grid-template-columns: minmax(0, 37fr) minmax(0, 63fr); }
.chat-source { border-right: 1px solid #eef1f6; display: flex; flex-direction: column; min-height: 0; }
.chat-source h3, .chat-check h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0; padding: 12px 16px 6px; font-size: 13.5px; font-weight: 900; }
.chat-source h3 small, .chat-check h3 small { color: #64748b; font-weight: 600; font-size: 11.5px; }
#sourceView { flex: 1; max-height: 470px; overflow: auto; padding: 4px 16px 16px; font-size: 15px; line-height: 2.1; white-space: normal; word-break: break-word; }
.src-name { padding: 1px 3px; border-radius: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 11%, transparent); font-weight: 800; cursor: pointer; }
.src-name.is-on { outline: 2px solid var(--c); }
.src-ev { color: inherit; background: linear-gradient(transparent 60%, #fde68a 60%); cursor: pointer; }
.src-ev.is-on { background: #fde68a; border-radius: 4px; box-shadow: 0 0 0 2px #f59e0b; }
.chat-graph { position: relative; display: grid; place-items: center; padding: 8px; background: #fff; }
.graph-zoom { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 6px 11px; border-radius: 999px; border: 1px solid #dfe4ee; background: rgba(255, 255, 255, .94); color: #334155; font-size: 12.5px; font-weight: 800; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.graph-overlay { position: fixed; inset: 0; z-index: 1300; display: flex; flex-direction: column; background: rgba(15, 23, 42, .94); }
.graph-overlay-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: #0f172a; color: #e2e8f0; font-size: 13px; }
.graph-overlay-bar button { padding: 8px 16px; border-radius: 10px; border: 0; background: #fff; color: #0f172a; font-weight: 800; }
.graph-overlay-body { flex: 1; overflow: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }
.graph-overlay-body img { display: block; max-width: none; margin: 0 auto; border-radius: 12px; background: #fff; }
#diagram { display: block; width: 100%; height: auto; max-height: min(860px, 82vh); object-fit: contain; cursor: pointer; }
/* 図の並べ方の切り替え */
.layout-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; width: 100%; }
.layout-switch-label { margin-right: 4px; color: #64748b; font-size: 12px; font-weight: 700; }
.layout-switch button { padding: 5px 11px; border-radius: 999px; border: 1px solid #dfe4ee; background: #fff; color: #475569; font-size: 12.5px; font-weight: 800; }
.layout-switch button[aria-pressed="true"] { background: #1e293b; border-color: #1e293b; color: #fff; }
.layout-switch button:disabled { opacity: .5; }

/* 確かめる */
.chat-check { display: grid; grid-template-columns: minmax(0, 37fr) minmax(0, 63fr); border-top: 1px solid #eef1f6; }
.chat-check > section { min-width: 0; padding-bottom: 12px; }
.chat-check > section + section { border-left: 1px solid #eef1f6; }
#peopleList, #relationList { display: flex; flex-direction: column; gap: 6px; padding: 4px 12px 0; }
.ck-person, .ck-rel { display: grid; align-items: center; gap: 4px 8px; padding: 7px 8px; border-radius: 12px; border: 1px solid transparent; }
.ck-person { grid-template-columns: auto auto minmax(0, 1fr); }
.ck-person.is-sel, .ck-rel.is-sel { background: #fffbeb; border-color: #fcd34d; }
.ck-person.is-off, .ck-rel.is-off { opacity: .5; }
.ck-person.is-off .ck-name, .ck-rel.is-off .ck-label { text-decoration: line-through; }
.ck-check input { width: 17px; height: 17px; accent-color: #0b2ec7; }
.ck-dot { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--c); color: #fff; font-weight: 900; font-size: 14px; display: grid; place-items: center; }
.ck-fields { display: flex; flex-direction: column; min-width: 0; }
.ck-fields input, .ck-label, .ck-new input, .ck-new select { min-width: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; padding: 2px 6px; }
.ck-fields input:hover, .ck-fields input:focus, .ck-label:hover, .ck-label:focus { border-color: #cbd5e1; background: #fff; }
.ck-name { font-weight: 800; font-size: 14px; }
.ck-desc { color: #64748b; font-size: 12px; }
.ck-rel { grid-template-columns: auto minmax(0, auto) minmax(64px, 1fr) auto; }
.ck-cat { border: 0; border-radius: 999px; padding: 3px 8px; background: var(--c); color: #fff; font-size: 11.5px; font-weight: 800; }
.ck-who { border: 0; background: none; padding: 0; text-align: left; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ck-label { font-weight: 800; font-size: 13.5px; border-color: #e2e8f0; border-style: dashed; }
.ck-off { min-width: 34px; height: 30px; border-radius: 8px; border: 1px solid #e2e8f0; background: #fff; color: #64748b; font-size: 12px; font-weight: 800; }
.ck-rel.is-off .ck-off { color: #0b2ec7; border-color: #c7d2fe; }
.ck-ev { grid-column: 2 / -1; justify-self: start; max-width: 100%; border: 0; background: none; padding: 0; color: #64748b; font-size: 12px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-ev:hover { color: #92400e; }
.ck-ev.is-none { color: #94a3b8; }
.ck-add { align-self: flex-start; margin-top: 4px; padding: 7px 12px; border-radius: 10px; border: 1px dashed #c7d2fe; background: #f8faff; color: #1e3a8a; font-size: 12.5px; font-weight: 800; }
.ck-new { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; padding: 8px; border-radius: 12px; background: #f8fafc; }
.ck-new select, .ck-new input { border-color: #e2e8f0; background: #fff; padding: 5px 8px; font-size: 13px; }
.ck-new input { flex: 1 1 90px; }
.ck-new .ck-add { margin: 0; }
.ck-empty { margin: 4px 8px; color: #94a3b8; font-size: 13px; }

.chat-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid #eef1f6; background: #fbfcfe; }
.chat-actions .btn { padding: 10px 18px; border-radius: 11px; border: 1px solid #cbd5e1; background: #fff; font-size: 14px; font-weight: 800; }
.chat-actions .btn.primary { background: #0b2ec7; border-color: #0b2ec7; color: #fff; }
.more-export { position: relative; }
.more-export summary { list-style: none; padding: 10px 12px; color: #475569; font-size: 13px; font-weight: 700; }
.more-export summary::-webkit-details-marker { display: none; }
.export-menu { position: absolute; bottom: calc(100% + 4px); left: 0; z-index: 5; display: grid; gap: 2px; min-width: 170px; padding: 6px; border-radius: 12px; background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 12px 30px rgba(15, 23, 42, .14); }
.export-menu button { padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 13px; }
.export-menu button:hover { background: #f1f5f9; }
#actionStatus { color: #15803d; font-size: 12.5px; font-weight: 700; }
.chat-actions .note { margin-left: auto; color: #94a3b8; font-size: 11.5px; }

/* 入力欄（会話の下に張り付く） */
.chat-composer { flex: none; z-index: 20; padding: 10px max(20px, calc(50% - 480px)) 10px; background: #f6f7fb; border-top: 1px solid #e6e9f2; }
.composer-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.composer-modes { display: flex; flex-wrap: wrap; gap: 6px; border: 0; margin: 0; padding: 0; }
.composer-modes legend { float: left; margin-right: 4px; padding: 5px 0; color: #64748b; font-size: 12px; font-weight: 700; }
.composer-modes label input { position: absolute; opacity: 0; pointer-events: none; }
.composer-modes label span { display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid #dfe4ee; background: #fff; color: #475569; font-size: 12.5px; font-weight: 800; }
.composer-modes label input:checked + span { background: #1e293b; border-color: #1e293b; color: #fff; }
.composer-modes label input:focus-visible + span { outline: 2px solid #4f5fd6; outline-offset: 2px; }
.append-switch { display: inline-flex; padding: 3px; border-radius: 11px; background: #e9ecf4; }
.append-switch button { padding: 5px 11px; border: 0; border-radius: 8px; background: none; color: #475569; font-size: 12.5px; font-weight: 800; }
.append-switch button[aria-pressed="true"] { background: #fff; color: #0b2ec7; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.composer-box { display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 10px 14px; border-radius: 20px; background: #fff; border: 1px solid #d5dbe8; box-shadow: 0 12px 30px rgba(15, 23, 42, .1); }
.composer-box:focus-within { border-color: #8b9bf0; box-shadow: 0 0 0 3px #e0e7ff, 0 12px 30px rgba(15, 23, 42, .1); }
.composer-bar { display: flex; align-items: center; gap: 10px; }
.composer-bar #charCount { margin-left: auto; color: #94a3b8; font-size: 12px; }
.composer-file { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px; border-radius: 11px; border: 1px solid #e2e8f0; color: #64748b; font-size: 12.5px; font-weight: 700; }
.composer-file:hover { background: #f8fafc; }
.composer-mic { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px; border-radius: 11px; border: 1px solid #e2e8f0; background: #fff; color: #64748b; font-size: 12.5px; font-weight: 700; }
.composer-mic:hover { background: #f8fafc; }
.composer-mic[aria-pressed="true"] { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; }
.composer-mic[aria-pressed="true"] svg { animation: mic-pulse 1.2s infinite ease-in-out; }
@keyframes mic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
#inputText { width: 100%; min-height: 44px; max-height: 240px; padding: 4px 2px; border: 0; outline: 0; resize: none; background: transparent; font-size: 15px; line-height: 1.7; }
body:not(.has-result) #inputText { min-height: 84px; }
#btnGenerate { flex: none; height: 44px; padding: 0 20px; border-radius: 13px; border: 0; background: #0b2ec7; color: #fff; font-size: 14.5px; font-weight: 900; }
.composer-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; padding: 0 6px; color: #94a3b8; font-size: 11.5px; }
#charCount.is-over { color: #dc2626; font-weight: 800; }
.composer-note { margin: 6px 6px 0; color: #475569; font-size: 12px; font-weight: 700; }
.composer-note.is-over { color: #b91c1c; }
.is-busy .chat-check, .is-busy .chat-graph, .is-busy #sourceView { pointer-events: none; opacity: .7; }

/* 使い方・よくある質問（右から開くパネル。中身はページ内にそのまま残る） */
.about-panel { position: fixed; inset: 0; z-index: 1250; display: flex; justify-content: flex-end; background: rgba(15, 23, 42, .45); }
.about-sheet { display: flex; flex-direction: column; width: min(760px, 100%); height: 100%; background: #f6f7fb; box-shadow: -12px 0 40px rgba(15, 23, 42, .2); }
.about-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; background: #fff; border-bottom: 1px solid #e6e9f2; font-size: 15px; }
.about-bar button { padding: 8px 16px; border-radius: 10px; border: 1px solid #cbd5e1; background: #fff; font-weight: 800; }
.about-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 20px; }
.feedback, .seo-content, footer { max-width: 1000px; margin: 28px auto; padding: 0 20px; color: #65738b; font-size: 13px; }
.seo-content { padding-top: 30px; border-top: 1px solid #e0e6ef; }
.seo-content h2 { font-size: 20px; color: #253653; margin-top: 30px; }
.seo-content h3 { font-size: 15px; color: #354760; }
.seo-content p { line-height: 1.9; }
.seo-content a, .feedback a, footer a { color: #465aba; }
.inline-links { display: flex; flex-wrap: wrap; gap: 15px; }
.comparison-grid { display: flex; gap: 20px; }
.comparison-card { background: #fff; padding: 14px; border: 1px solid #e0e6ef; border-radius: 10px; }
footer { font-size: 11px; text-align: center; padding-bottom: 24px; }
footer a { display: inline-block; margin: 4px 8px; }

@media (max-width: 900px) {
  .chat-split, .chat-check { grid-template-columns: 1fr; }
  .chat-source { border-right: 0; border-top: 1px solid #eef1f6; order: 2; }
  .chat-graph { order: 1; }
  #sourceView { max-height: 260px; }
  .chat-check > section + section { border-left: 0; border-top: 1px solid #eef1f6; }
}
@media (max-width: 640px) {
  .chat-scroll { padding: 14px 12px 10px; }
  .chat-composer { padding: 8px 12px 8px; }
  .chat-head-side { flex-direction: row-reverse; align-items: center; flex-wrap: wrap; justify-content: flex-start; }
  .chat-head { flex-direction: column; align-items: flex-start; margin-bottom: 14px; }
  .chat-head h1 { font-size: 23px; }
  .msg-av { display: none; }
  .msg-body { font-size: 14px; }
  .chat-result { border-radius: 16px; }
  .chat-result-head { padding: 12px 14px; }
  .result-tip { display: none; }
  .composer-file span { display: none; }
  #inputText { font-size: 16px; }
  body:not(.has-result) #inputText { min-height: 64px; }
  #btnGenerate { padding: 0 14px; }
  .composer-modes legend { display: none; }
  .ck-rel { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ck-rel .ck-label { grid-column: 1 / -1; grid-row: 2; }
  .ck-ev { grid-column: 1 / -1; }
  .chat-actions .note { margin-left: 0; width: 100%; }
  .feedback, .seo-content { padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) { .dots i, .composer-mic[aria-pressed="true"] svg { animation: none; } }
