/* ============================================================
   chat9-embed.css — チャットウィジェット Kawaii スタイル
   ============================================================ */

#chat9-embed {
  --line-bg: #fff2f8;
  --line-panel: #fde6f2;
  --line-text: #4a2d3c;
  --line-muted: #7d5e6e;
  --line-accent: #ff7aaa;
  --line-bubble-in: #fffafc;
  --line-bubble-out: #ffc8de;
  --line-bubble-border: rgba(200, 120, 160, 0.14);
  --line-input-bg: #fffdfd;
  --line-input-border: rgba(200, 120, 160, 0.2);
  --line-btn: linear-gradient(135deg, #ff7aaa, #e0508a);
  --line-btn-text: #fff5f9;
  --line-font-size: 16px;
  --line-line-height: 1.6;
  --line-radius: 20px;
  --line-input-height: 56px;
}

#chat9-embed * {
  box-sizing: border-box;
}

#chat9-embed {
  margin: 0;
  padding: 0;
  color: var(--line-text);
  font: var(--line-font-size)/var(--line-line-height) "M PLUS Rounded 1c", "Noto Sans JP", system-ui, sans-serif;
  background: var(--line-bg);
  border-radius: 18px;
  overflow: hidden;
}

#chat9-embed p {
  color: inherit;
}

#chat9-embed h1 {
  margin: 0 0 6px;
  font-size: 18px;
  font-family: inherit;
}

#chat9-embed textarea {
  width: 100%;
  border-radius: var(--line-radius);
  border: 1px solid var(--line-input-border);
  background: var(--line-input-bg);
  color: var(--line-text);
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
}

#chat9-embed textarea::placeholder {
  color: #b09aaa;
}

#chat9-embed button {
  border: none;
  border-radius: var(--line-radius);
  padding: 10px 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--line-btn);
  color: var(--line-btn-text);
  transition: filter 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

#chat9-embed button:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 6px 16px rgba(224, 80, 138, 0.24);
}

#chat9-embed button:active {
  transform: translateY(1px);
}

#chat9-embed button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chat9-embed .focus-toggle {
  background: transparent;
  color: var(--line-text);
  border: 1px solid var(--line-input-border);
  padding: 8px 14px;
  border-radius: var(--line-radius);
  min-width: 88px;
}

#chat9-embed .reset-guard {
  margin: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #fbbfae;
  background: #fff5f0;
  color: #a45d55;
  font-weight: 600;
}

#chat9-embed .auth-guard {
  margin: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #ebafc7;
  background: #fff5fa;
  color: #8f4766;
  font-weight: 600;
}

/* ── チャットメインレイアウト ── */
#chat9-embed #chat9-main {
  display: flex;
  flex-direction: column;
  background: var(--line-bg);
}

#chat9-embed #chat9-sections-panel {
  padding: 12px 12px 8px;
  background: var(--line-bg);
  border-bottom: 1px solid rgba(200, 120, 160, 0.12);
}

#chat9-embed #sections-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

#chat9-embed .chat9-block {
  border: 1px solid var(--line-bubble-border);
  border-radius: var(--line-radius);
  padding: 12px;
  background: #fff8fb;
}

#chat9-embed .block-header {
  font-weight: 700;
  margin-bottom: 6px;
  cursor: pointer;
}

#chat9-embed .block-header.active {
  color: var(--line-accent);
}

#chat9-embed .sys-area {
  margin-top: 6px;
}

/* ── チャットウィンドウ ── */
#chat9-embed #chat9-chat-window {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 8px 0;
  min-height: 0;
}

#chat9-embed #chat9-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 250, 252, 0.9);
  border: 1px solid var(--line-bubble-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#chat9-embed #chat9-conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

/* ── メッセージバブル ── */
#chat9-embed .chat9-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  line-height: var(--line-line-height);
  font-size: var(--line-font-size);
}

#chat9-embed .chat9-msg-section-label {
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 2px;
  align-self: flex-start;
  color: var(--line-muted);
}

#chat9-embed .msg__bubble {
  padding: 4px 4px;
  font-size: 1.1rem;
  border-radius: var(--line-radius);
  line-height: var(--line-line-height);
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line-bubble-border);
  background: var(--line-bubble-in);
  max-width: 98%;
  box-shadow: 0 2px 8px rgba(200, 100, 140, 0.07);
  color: var(--line-text);
}

/* ユーザー側（右寄せ・ピンクバブル） */
#chat9-embed .chat9-msg.user {
  align-items: flex-end;
  color: var(--line-text);
  white-space: pre-wrap;
}

#chat9-embed .chat9-msg.user .chat9-msg-section-label {
  align-self: flex-end;
  text-align: right;
}

#chat9-embed .chat9-msg.user .msg__bubble {
  background: linear-gradient(135deg, #ffc8de, #ffacd0);
  color: #5a2e44;
  border-color: rgba(200, 100, 140, 0.2);
  box-shadow: 0 3px 10px rgba(200, 100, 140, 0.14);
}

/* タイプライター表示 */
#chat9-embed .msg__bubble.typewriter-reveal {
  position: relative;
  overflow: hidden;
  animation: chat9-reveal var(--tw-duration, 1.8s) steps(var(--tw-steps, 30), end) forwards;
}

@keyframes chat9-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

#chat9-embed .chat9-msg.assistant {
  align-items: flex-start;
  color: var(--line-text);
  white-space: pre-wrap;
}

/* ── フッター入力エリア ── */
#chat9-embed #chat9-footer,
#chat9-embed .chat9-footer {
  position: static;
  padding: 6px 0 8px 0;
  border-top: 1px solid rgba(200, 120, 160, 0.12);
  background: rgba(255, 250, 252, 0.98);
  backdrop-filter: blur(8px);
  z-index: 10;
}

#chat9-embed .chat9-footer-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px;
}

#chat9-embed .chat9-active-section {
  color: var(--line-muted);
  font-size: 13px;
}

#chat9-embed .chat9-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#chat9-embed #chat9-input {
  flex: 1;
  resize: none;
  padding: 12px 14px;
  border-radius: var(--line-radius);
  border: 1.5px solid var(--line-input-border);
  background: var(--line-input-bg);
  color: var(--line-text);
  min-height: 44px;
  max-height: 120px;
  font-size: var(--line-font-size);
  line-height: var(--line-line-height);
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#chat9-embed #chat9-input:focus {
  outline: none;
  border-color: rgba(255, 122, 170, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 122, 170, 0.1);
}

#chat9-embed #chat9-send {
  flex-shrink: 0;
  padding: 10px 20px;
  border-radius: var(--line-radius);
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #ff7aaa, #e0508a);
  color: #fff5f9;
  min-height: 44px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(224, 80, 138, 0.22);
}

/* ── レスポンシブ ── */
@media (max-width: 600px) {
  #chat9-embed .chat9-input-row { flex-direction: row; }
  #chat9-embed #chat9-main { padding-bottom: 0; }
  #chat9-embed #chat9-chat-window { padding: 0 0 6px 0; }
  #chat9-embed #chat9-scroll { padding: 8px 8px; }
}

/* ── デバッグパネル ── */
#chat9-embed .debug-panels {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

#chat9-embed .debug-panel {
  flex: 1 1 0;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff8fb;
  border: 1px solid var(--line-bubble-border);
  border-radius: 12px;
  padding: 8px;
}

#chat9-embed .debug-panel h3 {
  margin: 0;
  font-size: 14px;
  color: var(--line-muted);
}

#chat9-embed .debug-panel textarea {
  min-height: 220px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: #fffdfd;
  color: var(--line-text);
  border: 1px solid var(--line-input-border);
  border-radius: 8px;
  padding: 8px;
}

#chat9-embed .tr-fileio {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

@media (max-width: 768px) {
  #chat9-embed .debug-panels { flex-direction: column; }
}

/* ── フォーカスモード ── */
#chat9-embed.focus-chat9 header,
#chat9-embed.focus-chat9 nav,
#chat9-embed.focus-chat9 .site-header,
#chat9-embed.focus-chat9 .global-nav {
  display: none !important;
}

#chat9-embed.focus-chat9 #chat9-main {
  max-width: none;
  padding: 0;
}

#chat9-embed.focus-chat9 #chat9-sections-panel {
  padding-left: 8px;
  padding-right: 8px;
}

#chat9-embed.focus-chat9 #chat9-chat-window {
  padding: 0;
}
