/* ============================================================
   IWAHIBA Bot — チャットUI（既存デザインシステムに準拠）
   依存トークン: style.css の :root（墨/金/和紙/緑 ほか）
   ============================================================ */

.bot-app { max-width: 920px; margin: 0 auto; padding: 0 var(--sp); }

/* ---------- コントロールバー ---------- */
.bot-bar {
  position: sticky; top: 64px; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  padding: 12px 14px; margin: 8px 0 18px;
  background: rgba(245, 241, 230, .92); backdrop-filter: blur(6px);
  border: 1px solid var(--paper-line); border-radius: 10px;
  box-shadow: 0 3px 14px rgba(80, 70, 40, .07);
}
body[data-mode="dark"] .bot-bar { background: rgba(19, 27, 19, .92); border-color: rgba(201,168,106,.2); }
.bot-bar .grp { display: flex; align-items: center; gap: 6px; }
.bot-bar .grp > .lab {
  font-family: var(--serif-en); font-size: .68rem; letter-spacing: .18em;
  text-transform: uppercase; opacity: .6; margin-right: 2px;
}
.seg { display: inline-flex; border: 1px solid var(--kin); border-radius: 999px; overflow: hidden; }
.seg button {
  font-family: var(--sans-jp); font-size: .8rem; letter-spacing: .04em;
  padding: 6px 12px; border: 0; background: transparent; color: inherit; cursor: pointer;
  transition: background .2s, color .2s; white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--green-line); }
.seg button[aria-pressed="true"] { background: var(--kin); color: var(--sumi); }
.seg button:hover:not([aria-pressed="true"]) { background: rgba(201,168,106,.18); }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans-jp); font-size: .8rem;
  padding: 6px 12px; border: 1px solid var(--kin); border-radius: 999px;
  background: transparent; color: inherit; cursor: pointer; transition: all .2s;
}
.icon-btn:hover { background: rgba(201,168,106,.18); }
.icon-btn[aria-pressed="true"] { background: var(--kin); color: var(--sumi); }
.icon-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); }
.icon-btn[data-on="1"] .dot { background: var(--wakaba); box-shadow: 0 0 6px var(--wakaba); }

/* ---------- チャットログ ---------- */
.bot-log { display: flex; flex-direction: column; gap: 20px; min-height: 40vh; padding: 4px 0 8px; }
.bot-msg { display: flex; gap: 12px; align-items: flex-start; }
.bot-msg.user { flex-direction: row-reverse; }
.bot-ava {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.1rem;
  border: 1px solid var(--kin); background: var(--sumi-2); color: var(--kin-bright);
}
.bot-msg.user .bot-ava { background: var(--shinryoku); color: var(--washi); border-color: var(--wakaba); }
.msg-body {
  max-width: 78%; font-size: .95rem; line-height: 1.9;
  padding: 14px 18px; border-radius: 12px;
}
.bot-msg.user .msg-body {
  background: var(--shinryoku); color: var(--white-soft); border-top-right-radius: 4px;
  white-space: pre-wrap; word-break: break-word;
}
.bot-msg.bot .msg-body {
  background: #fffdf6; border: 1px solid var(--paper-line); border-top-left-radius: 4px;
  box-shadow: 0 3px 14px rgba(80,70,40,.06); width: 100%; max-width: 100%;
}
body[data-mode="dark"] .bot-msg.bot .msg-body { background: var(--sumi-2); border-color: rgba(201,168,106,.2); }

/* ---------- 回答パーツ ---------- */
.ans-lead {
  background: linear-gradient(135deg, rgba(106,143,95,.14), rgba(201,168,106,.12));
  border: 1px solid rgba(106,143,95,.35); border-radius: var(--radius);
  padding: 14px 18px; margin: 0 0 14px; font-size: .97rem;
}
.ans-lead .tag { display:block; font-family: var(--serif-en); font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; color: var(--kin-deep); margin-bottom: 5px; }
body[data-mode="dark"] .ans-lead .tag { color: var(--kin-bright); }
.ans-sec-title { font-size: .82rem; letter-spacing: .14em; color: var(--kin-deep); margin: 16px 0 8px; border-left: 3px solid var(--kin); padding-left: 10px; }
body[data-mode="dark"] .ans-sec-title { color: var(--kin-bright); }

.ans-theory {
  background: var(--washi); border: 1px solid var(--paper-line); border-radius: var(--radius);
  padding: 12px 16px 10px; margin: 0 0 10px; font-size: .9rem; line-height: 1.85;
}
body[data-mode="dark"] .ans-theory { background: #10180f; border-color: rgba(201,168,106,.18); }
.ans-theory h5 { font-size: .92rem; letter-spacing: .06em; margin-bottom: 5px; color: var(--koyo); }
body[data-mode="dark"] .ans-theory h5 { color: var(--kin-bright); }
.ans-theory .note { display: block; margin-top: 6px; font-size: .82rem; opacity: .8; border-top: 1px dashed var(--green-line); padding-top: 5px; }

/* 出典は既存 .src を流用。追加で右寄せまとめ枠 */
.ans-srcs { margin-top: 6px; }
.ans-srcs .src { cursor: default; }
.ans-disclaim {
  font-size: .8rem; opacity: .82; margin-top: 12px; padding: 8px 12px;
  border: 1px dashed var(--koyo); border-radius: var(--radius); color: var(--koyo);
}
body[data-mode="dark"] .ans-disclaim { color: #e0a08f; border-color: #e0a08f; }

/* ---------- 品種ミニカード & 比較表 ---------- */
.ans-cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; }
.cult-mini {
  display: flex; gap: 10px; align-items: center; width: calc(50% - 5px);
  background: var(--washi); border: 1px solid var(--paper-line); border-radius: var(--radius); padding: 8px;
}
body[data-mode="dark"] .cult-mini { background: #10180f; border-color: rgba(201,168,106,.18); }
.cult-mini img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; cursor: zoom-in; flex: 0 0 auto; }
.cult-mini .nm { font-size: .92rem; font-weight: 600; }
.cult-mini .kn { font-size: .76rem; opacity: .7; }
.cult-mini .meta { font-size: .74rem; opacity: .8; margin-top: 3px; }
.cult-mini .badge { display:inline-block; font-size:.66rem; padding:0 7px; border-radius:999px; border:1px solid var(--kin); margin-top:3px; }
.cult-mini .badge.reg { background: rgba(106,143,95,.18); }

.cmp-wrap { overflow-x: auto; margin: 10px 0; }
.cmp-table { border-collapse: collapse; width: 100%; font-size: .85rem; min-width: 420px; }
.cmp-table th, .cmp-table td { border: 1px solid var(--paper-line); padding: 8px 10px; text-align: left; vertical-align: top; }
.cmp-table thead th { background: rgba(201,168,106,.16); font-size: .9rem; }
.cmp-table th[scope="row"] { background: rgba(140,120,80,.08); white-space: nowrap; font-weight: 600; width: 7em; }
body[data-mode="dark"] .cmp-table th, body[data-mode="dark"] .cmp-table td { border-color: rgba(201,168,106,.2); }
.cmp-table .cmp-img { width: 110px; height: 84px; object-fit: cover; border-radius: 4px; cursor: zoom-in; }

/* ---------- 関連リンク ---------- */
.ans-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ans-links a {
  font-size: .8rem; text-decoration: none; padding: 5px 12px;
  border: 1px solid var(--green-line); border-radius: 999px; transition: all .2s;
}
.ans-links a:hover { border-color: var(--kin); background: rgba(201,168,106,.14); }

/* ---------- 読み上げ等 行内ボタン ---------- */
.msg-tools { display: flex; gap: 8px; margin-top: 10px; }
.msg-tools button {
  font-size: .74rem; padding: 4px 10px; border: 1px solid var(--green-line);
  border-radius: 999px; background: transparent; color: inherit; cursor: pointer;
}
.msg-tools button:hover { border-color: var(--kin); }

/* ---------- サジェストチップ ---------- */
.bot-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.bot-chips button {
  font-family: var(--sans-jp); font-size: .82rem;
  padding: 8px 14px; border: 1px solid var(--kin); border-radius: 999px;
  background: transparent; color: inherit; cursor: pointer; transition: all .2s;
}
.bot-chips button:hover { background: var(--kin); color: var(--sumi); }

/* ---------- 入力バー ---------- */
.bot-form { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 0 18px; background: linear-gradient(to top, var(--washi) 70%, transparent); }
body[data-mode="dark"] .bot-form { background: linear-gradient(to top, var(--sumi) 70%, transparent); }
.bot-form textarea {
  flex: 1; resize: none; min-height: 48px; max-height: 140px;
  font-family: var(--sans-jp); font-size: .95rem; line-height: 1.6;
  padding: 12px 14px; border: 1px solid var(--kin); border-radius: 10px;
  background: #fffdf6; color: var(--ink);
}
body[data-mode="dark"] .bot-form textarea { background: var(--sumi-2); color: var(--white-soft); }
.bot-form textarea:focus { outline: 2px solid var(--kin); outline-offset: 1px; }
.bot-send, .bot-mic {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--kin); background: var(--shinryoku); color: var(--kin-bright);
  font-size: 1.2rem; display: grid; place-items: center; transition: all .2s;
}
.bot-send:hover, .bot-mic:hover { background: var(--kin); color: var(--sumi); }
.bot-mic[data-rec="1"] { background: var(--koyo); color: #fff; animation: micpulse 1.1s infinite; }
@keyframes micpulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(168,68,50,.5);} 50%{ box-shadow: 0 0 0 7px rgba(168,68,50,0);} }

/* ---------- 設定モーダル ---------- */
.bot-modal { position: fixed; inset: 0; z-index: 90; display: none; place-items: center;
  background: rgba(8,12,8,.6); padding: 20px; }
.bot-modal.open { display: grid; }
.bot-modal .box {
  background: var(--washi); color: var(--ink); border: 1px solid var(--kin);
  border-radius: 12px; max-width: 460px; width: 100%; padding: 22px 24px;
  box-shadow: var(--shadow); max-height: 86vh; overflow: auto;
}
body[data-mode="dark"] .bot-modal .box { background: var(--sumi-2); color: var(--white-soft); }
.bot-modal h3 { font-size: 1.1rem; letter-spacing: .1em; margin-bottom: 4px; }
.bot-modal label { display: block; font-size: .82rem; margin: 14px 0 5px; letter-spacing: .04em; }
.bot-modal input[type="password"], .bot-modal input[type="text"], .bot-modal select {
  width: 100%; padding: 10px 12px; font-family: var(--sans-jp); font-size: .9rem;
  border: 1px solid var(--paper-line); border-radius: 6px; background: #fffdf6; color: var(--ink);
}
body[data-mode="dark"] .bot-modal input, body[data-mode="dark"] .bot-modal select { background: #10180f; color: var(--white-soft); border-color: rgba(201,168,106,.25); }
.bot-modal .hint { font-size: .78rem; opacity: .8; margin-top: 6px; line-height: 1.7; }
.bot-modal .row { display: flex; gap: 10px; margin-top: 18px; }
.bot-modal .row .btn { flex: 1; text-align: center; padding: 11px 0; }
.bot-modal .status { font-size: .8rem; margin-top: 10px; }
.bot-modal .status.ok { color: var(--wakaba); }
.bot-modal .status.err { color: var(--koyo); }

/* ---------- thinking ---------- */
.thinking .msg-body { display: inline-flex; gap: 6px; align-items: center; }
.thinking .d { width: 7px; height: 7px; border-radius: 50%; background: var(--kin); animation: blink 1.2s infinite; }
.thinking .d:nth-child(2){ animation-delay: .2s; } .thinking .d:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{ opacity:.25;} 40%{ opacity:1;} }

/* ---------- mode badge (engine状態) ---------- */
.engine-badge { font-size: .72rem; opacity: .7; margin-left: auto; display: flex; align-items: center; gap: 5px; }
.engine-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); }
.engine-badge[data-engine="api"] .dot { background: var(--wakaba); box-shadow: 0 0 6px var(--wakaba); }

/* ---------- foot note ---------- */
.bot-note {
  font-size: .8rem; line-height: 1.8; opacity: .82;
  margin: 16px 2px 0; padding-top: 12px; border-top: 1px solid var(--green-line);
}
.bot-note span[lang="en"] { display: block; font-family: var(--serif-en); font-style: italic; opacity: .9; margin-top: 5px; }

@media (max-width: 620px) {
  .msg-body { max-width: 100%; }
  .bot-msg.user .msg-body { max-width: 85%; }
  .cult-mini { width: 100%; }
  .bot-bar { top: 56px; }
}
