/* ── デザイントークン (04_UI_SPEC.md §6) ───────────────────────────────── */
:root {
  --bg:          #ffffff;
  --bg-soft:     #f7f8fa;
  --bg-card:     #ffffff;
  --border:      #e3e6ea;
  --text:        #1a1d21;
  --text-soft:   #6b7280;
  --accent:      #1f6feb;
  --accent-soft: #e8f0fe;
  --ok:          #16a34a;
  --warn:        #ea580c;
  --ng:          #dc2626;
  --bubble-bot:  #f1f3f6;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .04);
  --hd-h:        104px;
}

[data-theme="dark"] {
  --bg:          #14171c;
  --bg-soft:     #1a1e24;
  --bg-card:     #1e2329;
  --border:      #2d333b;
  --text:        #e6e8eb;
  --text-soft:   #9198a1;
  --accent:      #4c8dff;
  --accent-soft: #1c2a44;
  --bubble-bot:  #252a33;
  --shadow:      0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
}

/* 日本語が既定表記なので和文フォントを先に置く。Web フォントは読み込まない(N-2) */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Hiragino Sans", "Yu Gothic", "Noto Sans JP",
               "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
ul, ol, dl { margin: 0; padding: 0; list-style: none; }
a { color: var(--accent); }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.noscript {
  margin: 24px auto; max-width: 640px; padding: 16px;
  border: 1px solid var(--ng); border-radius: var(--radius);
  background: var(--bg-card); text-align: center;
}

/* ── ヘッダー ───────────────────────────────────────────────────────────── */
.hd {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.hd-inner {
  display: flex; align-items: center; gap: 20px;
  max-width: 1560px; margin: 0 auto; padding: 12px 24px;
}

.hd-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }

.hd-logo {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
}

.hd-brand-name { font-size: 13px; font-weight: 600; color: var(--text-soft); }

.hd-title {
  flex: 1; min-width: 0;
  padding-left: 20px; border-left: 1px solid var(--border);
}
.hd-title h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-title p  { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hd-tools { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.hd-ver {
  font-size: 11px; color: var(--text-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* LIVE バッジ 4状態 */
.live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  white-space: nowrap;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); flex-shrink: 0; }

.live[data-state="connecting"] { color: var(--text-soft); }
.live[data-state="connecting"] .live-dot { animation: pulse 1.4s ease-in-out infinite; }

.live[data-state="ok"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.live[data-state="ok"] .live-dot { background: var(--ok); animation: pulse 2s ease-in-out infinite; }

.live[data-state="degraded"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.live[data-state="degraded"] .live-dot { background: var(--warn); animation: pulse .8s ease-in-out infinite; }

.live[data-state="down"] { color: var(--ng); border-color: color-mix(in srgb, var(--ng) 40%, transparent); background: color-mix(in srgb, var(--ng) 8%, transparent); }
.live[data-state="down"] .live-dot { background: var(--ng); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  padding: 4px 10px; border: 0; background: transparent;
  font-size: 11px; font-weight: 600; color: var(--text-soft);
}
.seg-btn.is-on { background: var(--accent); color: #fff; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  display: grid; place-items: center; font-size: 14px;
}
.icon-btn:hover { background: var(--bg-soft); }

/* タブ */
.tabs { display: flex; gap: 4px; max-width: 1560px; margin: 0 auto; padding: 0 24px; }
.tabs button {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 16px; border: 0; background: transparent;
  border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 500; color: var(--text-soft);
}
.tabs button i { font-style: normal; font-size: 12px; opacity: .8; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── レイアウト ─────────────────────────────────────────────────────────── */
.wrap { max-width: 1560px; margin: 0 auto; padding: 20px 24px 40px; }
.panel { display: none; }
.panel.is-on { display: block; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }

.card-t {
  font-size: 12px; font-weight: 700; letter-spacing: .4px;
  color: var(--text-soft); text-transform: uppercase;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sub-t { font-size: 12px; font-weight: 700; color: var(--text-soft); margin: 16px 0 8px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text-soft); white-space: nowrap; }
.kv dd { margin: 0; text-align: right; font-weight: 500; word-break: break-all; }
.kv-mono dd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }

.chat-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.side { position: sticky; top: calc(var(--hd-h) + 20px); }

/* ── 統計・チャート ─────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat {
  display: flex; flex-direction: column; gap: 1px;
  padding: 10px; border-radius: 8px; background: var(--bg-soft);
}
.stat-n { font-size: 19px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 11px; color: var(--text-soft); }

.chart-cap { font-size: 11px; color: var(--text-soft); margin: 14px 0 4px; }
.chart-box { min-height: 40px; }
.chart-empty {
  padding: 22px 8px; text-align: center;
  font-size: 12px; color: var(--text-soft);
  background: var(--bg-soft); border-radius: 8px;
}

.chart-donut { width: 100%; max-width: 168px; display: block; margin: 4px auto 10px; }
.donut-center { font-size: 20px; font-weight: 700; fill: var(--text); }
.donut-sub    { font-size: 8px; fill: var(--text-soft); }

/* 再描画ごとにノードが新規になるため、transition ではなく animation を使う */
.donut-seg { animation: donut-in .7s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes donut-in { from { stroke-dasharray: 0 9999; } }

/* viewBox 幅(460)を超えて拡大させない。文字だけ巨大化するのを防ぐ */
.chart-hbar { width: 100%; max-width: 460px; display: block; }
.hbar-label { font-size: 10.5px; fill: var(--text); }
.hbar-value { font-size: 10.5px; fill: var(--text-soft); font-weight: 600; }
.hbar-fill  { animation: hbar-in .7s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes hbar-in { from { width: 0; } }

.chart-spark { width: 100%; height: 64px; display: block; overflow: visible; }
.spark-line {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; animation: spark-in .9s ease-out both;
}
@keyframes spark-in { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.spark-area { fill: var(--accent); opacity: .1; stroke: none; }
.spark-dot  { fill: var(--accent); animation: fade-in .4s ease-out both; }
@keyframes fade-in { from { opacity: 0; } }

.legend { display: grid; gap: 6px; font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.legend span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-variant-numeric: tabular-nums; }

.card-notice .notice-list { display: grid; gap: 8px; font-size: 12px; color: var(--text-soft); }
.card-notice .notice-list li { padding-left: 14px; position: relative; }
.card-notice .notice-list li::before { content: "•"; position: absolute; left: 2px; }

.contact {
  margin-top: 12px; padding: 11px;
  border-radius: 8px; background: var(--accent-soft);
  font-size: 12px;
}
.contact .contact-l { color: var(--text-soft); }
.contact .contact-tel { font-size: 17px; font-weight: 700; letter-spacing: .5px; display: block; }

/* ── 質問例 ─────────────────────────────────────────────────────────────── */
.samples {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.samples-hd { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.samples-hd h2 { font-size: 13px; }
.samples-hd span { font-size: 11px; color: var(--text-soft); }
.samples-list { display: flex; flex-wrap: wrap; gap: 7px; }

.sample {
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 12px; text-align: left;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft);
  transition: border-color .15s, background .15s;
}
.sample:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.sample:disabled { opacity: .45; cursor: not-allowed; }
.sample-t { font-size: 12.5px; }
.sample-c { font-size: 10px; color: var(--text-soft); }

/* ── チャット ───────────────────────────────────────────────────────────── */
.chatbox {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}

.chatbox-hd {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-soft); font-size: 13px;
}
.chatbox-hd strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.chatbox-hd-tag {
  padding: 1px 7px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 700;
}
.chatbox-hd-turn { margin-left: auto; font-size: 11px; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.chatlog {
  min-height: 380px; max-height: min(64vh, 720px);
  overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 86%; animation: msg-in .3s ease-out both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }

.msg-bot { align-self: flex-start; }
.msg-you { align-self: flex-end; align-items: flex-end; }

.msg-meta { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--text-soft); padding: 0 4px; }
.msg-who { font-weight: 700; letter-spacing: .5px; }
.msg-latency { font-variant-numeric: tabular-nums; }

.msg-body {
  padding: 11px 14px; border-radius: 12px;
  font-size: 13.5px; word-break: break-word;
}
.msg-bot .msg-body { background: var(--bubble-bot); border-top-left-radius: 3px; }
.msg-you .msg-body { background: var(--accent); color: #fff; border-top-right-radius: 3px; }

.block-text + .block-text,
.block-text + .block-note { margin-top: 10px; }
.block-note {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px; color: var(--text-soft);
}

/* 出典カード — 本プロジェクトの差別化点(F-11) */
.source-card {
  margin-top: 12px; padding: 10px 12px;
  border-left: 4px solid var(--cat-color, var(--accent));
  border-radius: 0 8px 8px 0;
  background: var(--bg-card);
}
.source-head { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: var(--text-soft); }
.source-label { font-size: 12.5px; font-weight: 600; margin: 2px 0 7px; }

.cat-badge {
  padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--cat-color, var(--accent));
  background: transparent; color: var(--cat-color, var(--accent));
  font-size: 11px; font-weight: 600;
  transition: background .15s, color .15s;
}
.cat-badge:hover { background: var(--cat-color, var(--accent)); color: #fff; }

/* 関連質問チップ */
.chips-block { margin-top: 12px; }
.chips-title { font-size: 11px; font-weight: 600; color: var(--text-soft); margin-bottom: 7px; }
.chips-list { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  font-size: 12px; text-align: left;
  transition: border-color .15s, background .15s;
}
.chip:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.chip-link { text-decoration: none; }

/* 未対応 output[].type の原文表示(R-2) */
.raw-block {
  margin-top: 12px; border: 1px dashed var(--border);
  border-radius: 8px; background: var(--bg-soft);
  font-size: 11.5px;
}
.raw-block summary { padding: 7px 10px; cursor: pointer; color: var(--text-soft); }
.raw-json {
  margin: 0; padding: 10px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; line-height: 1.6;
  border-top: 1px dashed var(--border);
}

/* タイピングインジケータ */
.msg-typing .msg-body { padding: 12px 16px; }
.typing { display: flex; align-items: center; gap: 5px; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-soft); animation: typing 1.3s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typing { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.typing-elapsed { margin-left: 8px; font-size: 11px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.typing-slow { margin-top: 7px; font-size: 11px; color: var(--warn); }

/* エラーカード */
.error-card {
  align-self: stretch; padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--ng) 45%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ng) 6%, transparent);
  animation: msg-in .3s ease-out both;
}
.error-title  { font-size: 13px; font-weight: 600; color: var(--ng); }
.error-detail { font-size: 12px; color: var(--text-soft); margin: 3px 0 9px; word-break: break-all; }
.btn-retry {
  padding: 5px 14px; border-radius: 7px;
  border: 1px solid var(--ng); background: transparent; color: var(--ng);
  font-size: 12px; font-weight: 600;
}
.btn-retry:hover { background: var(--ng); color: #fff; }

/* 入力 */
.inputbar {
  display: flex; gap: 9px; align-items: flex-end;
  padding: 12px 14px; border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.inputbar textarea {
  flex: 1; resize: none; max-height: 132px;
  padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font: inherit; font-size: 13.5px; line-height: 1.55;
}
.inputbar textarea:disabled { opacity: .55; }

.btn-send {
  padding: 9px 20px; border-radius: 9px; border: 0;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn-send:disabled { opacity: .5; cursor: not-allowed; }

.input-locked {
  padding: 9px 14px; font-size: 12px; color: var(--warn);
  border-top: 1px solid var(--border); background: var(--bg-soft);
}

/* API 断のときだけ生成する iframe 退避路(R-4) */
.fallback-note {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}
.fallback-note strong { display: block; font-size: 13px; color: var(--warn); }
.fallback-note p { font-size: 12px; color: var(--text-soft); margin: 3px 0 9px; }
.fallback-note button {
  padding: 5px 14px; border-radius: 7px;
  border: 1px solid var(--warn); background: transparent; color: var(--warn);
  font-size: 12px; font-weight: 600;
}
.fallback-frame { width: 100%; height: 620px; border: 0; display: block; }

/* ── ナレッジ ───────────────────────────────────────────────────────────── */
.kb-hd { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.kb-hd h2 { font-size: 16px; }
.kb-hd a { font-size: 12px; }
.kb-count { font-size: 13px; color: var(--text-soft); font-weight: 500; }

.kb-top { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.kb-top .card + .card { margin-top: 0; }

.kb-catlist { display: grid; gap: 4px; font-size: 12.5px; }
.kb-catlist li { display: flex; align-items: center; gap: 9px; padding: 4px 0; }
.kb-catlist i { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.kb-catlist .kb-cat-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; color: var(--text-soft); }
.kb-catlist .kb-cat-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-catlist b { font-variant-numeric: tabular-nums; }

.kb-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.kb-controls input {
  flex: 0 0 280px; padding: 8px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font: inherit; font-size: 13px;
}
.kb-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-filters button {
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  font-size: 11.5px; color: var(--text-soft);
}
.kb-filters button:hover { border-color: var(--accent); color: var(--accent); }
.kb-filters button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.kb-hits { font-size: 12px; color: var(--text-soft); margin-bottom: 10px; }

.kb-list {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.kb-item { border-bottom: 1px solid var(--border); }
.kb-item:last-child { border-bottom: 0; }

.kb-item-hd { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; }
.kb-item-q {
  flex: 1; text-align: left; border: 0; background: transparent;
  font-size: 13px; line-height: 1.6; padding: 0;
}
.kb-item-q:hover { color: var(--accent); }
.kb-item-tag {
  flex-shrink: 0; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--cat-color, var(--border));
  color: var(--cat-color, var(--text-soft));
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.kb-item-id { flex-shrink: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; color: var(--text-soft); }

.kb-ask {
  flex-shrink: 0; padding: 4px 12px; border-radius: 7px;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.kb-ask:hover { background: var(--accent); color: #fff; }

.kb-item-a {
  padding: 0 16px 14px 16px; font-size: 12.5px; color: var(--text-soft);
  line-height: 1.8; border-top: 1px dashed var(--border); margin-top: 2px; padding-top: 12px;
}
.kb-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; font-size: 11.5px; }

.kb-empty { padding: 34px; text-align: center; color: var(--text-soft); font-size: 13px; }

/* ── システム構成 ───────────────────────────────────────────────────────── */
.sys-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.sys-two .card + .card { margin-top: 0; }

/* 図はCSSで作る。画像は使わない */
.flow { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.flow li {
  flex: 1 1 130px; min-width: 130px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--bg-soft);
  position: relative; margin-right: 22px;
}
.flow li:last-child { margin-right: 0; }
.flow li:not(:last-child)::after {
  content: "▶"; position: absolute;
  right: -17px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--text-soft);
}
.flow-step { font-size: 10px; font-weight: 700; color: var(--accent); }
.flow-label { font-size: 13px; font-weight: 600; }
.flow-detail { font-size: 11px; color: var(--text-soft); word-break: break-all; }
.flow-owner {
  display: inline-block; margin-top: 6px;
  padding: 0 7px; border-radius: 4px;
  font-size: 9.5px; font-weight: 700;
}
.flow li[data-owner="self"]  { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.flow li[data-owner="self"]  .flow-owner { background: var(--accent-soft); color: var(--accent); }
.flow li[data-owner="catai"] .flow-owner { background: var(--bg-card); color: var(--text-soft); border: 1px solid var(--border); }

.sys-note { font-size: 12.5px; color: var(--text-soft); line-height: 1.85; }
.sys-note-sm { font-size: 11.5px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }

.endpoints { display: grid; gap: 6px; }
.endpoints li {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 7px 10px; border-radius: 7px; background: var(--bg-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
}
.ep-method {
  padding: 0 6px; border-radius: 4px;
  background: var(--accent); color: #fff;
  font-size: 9.5px; font-weight: 700; flex-shrink: 0;
}
.ep-path { flex: 1; min-width: 0; word-break: break-all; }
.ep-desc {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Malgun Gothic", sans-serif;
  font-size: 11px; color: var(--text-soft);
}

/* ── レスポンシブ (04_UI_SPEC.md §7) ────────────────────────────────────── */
@media (max-width: 1179px) {
  .chat-layout { grid-template-columns: 300px 1fr; }
  .hd-inner, .tabs, .wrap { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 899px) {
  :root { --hd-h: 148px; }
  .hd-inner { flex-wrap: wrap; gap: 12px; }
  .hd-title { flex-basis: 100%; padding-left: 0; border-left: 0; order: 3; }
  .hd-tools { margin-left: auto; }
  .tabs { overflow-x: auto; }

  /* 1段組。左パネルは会話の下へ回す */
  .chat-layout { grid-template-columns: 1fr; }
  .side { position: static; order: 2; }
  .chat-main { order: 1; }

  .kb-top, .sys-two { grid-template-columns: 1fr; }
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kb-controls input { flex-basis: 100%; }
  .msg { max-width: 94%; }
  .flow li { margin-right: 0; }
  .flow li:not(:last-child)::after { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .chatlog { scroll-behavior: auto; }
}
