:root {
  --ink: #2f3437;
  --muted: #70777b;
  --line: #c8ced1;
  --line-soft: #edf1ee;
  --paper: #ffffff;
  --soft: #ffffff;
  --surface-muted: #f4f5f5;
  --surface-hover: #f6f8f8;
  --button: #2f6686;
  --button-dark: #244a63;
  --button-soft: #e4edf2;
  --amber: #f5ecd7;
  --rose: #f5e1df;
  --font-sans: "MS PGothic", "ＭＳ Ｐゴシック", Osaka, "Hiragino Kaku Gothic ProN", "Yu Gothic", "游ゴシック", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 280px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.widget {
  width: min(100%, 520px);
  height: min(720px, calc(100dvh - 60px));
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.status { color: var(--muted); font-size: 10px; white-space: nowrap; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #6d9b7b; }
.status.is-loading .status-dot { background: #b28a36; }
.status.is-ready .status-dot { background: #2f6686; }

.intro { padding: 31px 24px 22px; }
.intro { flex: 0 0 auto; border-bottom: 1px solid var(--line-soft); background: var(--paper); }
.intro h1 { max-width: 360px; margin: 0 0 10px; font-size: 26px; font-weight: 800; letter-spacing: -.04em; line-height: 1.2; }
.intro p:last-child { max-width: none; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.85; }

.messages { flex: 1 1 auto; min-height: 0; padding: 5px 24px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; -ms-overflow-style: none; }
.messages::-webkit-scrollbar, .suggestions::-webkit-scrollbar { display: none; width: 0; height: 0; }
.message-row { display: flex; margin: 0 0 14px; animation: appear .22s ease-out both; }
.message-row.user { justify-content: flex-end; }
.message-row.user > div { width: 78%; }
.bubble { display: block; width: 100%; max-width: 100%; min-width: 0; padding: 0; color: #35403d; font-size: 13px; line-height: 1.85; white-space: pre-wrap; writing-mode: horizontal-tb !important; text-orientation: mixed; columns: 1; column-count: 1; column-width: auto; word-break: normal; overflow-wrap: anywhere; }
.message-row.bot .bubble { width: 100%; max-width: 100%; }
.message-row > div { min-width: 0; writing-mode: horizontal-tb !important; columns: 1; column-count: 1; }
.message-row.user .bubble { width: max-content; min-width: 2em; max-width: 100%; margin-left: auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: var(--surface-muted); overflow-wrap: anywhere; }
.message-row.thinking { display: block; }
.message-row.thinking > div { width: 100%; }
.message-row.thinking .bubble { display: inline-block; width: auto; min-width: 4.5em; max-width: none; white-space: nowrap; word-break: keep-all; overflow-wrap: normal; writing-mode: horizontal-tb !important; }
.message-row.thinking .bubble { color: var(--muted); }
.message-row.thinking .bubble::after { content: "…"; display: inline-block; width: 1.5em; overflow: hidden; vertical-align: bottom; animation: thinking-dots 1.1s steps(3, end) infinite; }
.message-time { margin: 4px 0 0; color: #a8afab; font-size: 9px; }
.message-row.user .message-time { text-align: right; }
.answer-card { margin-top: 13px; padding: 12px 0 0; border-top: 1px solid var(--line-soft); }
.answer-card strong { display: block; margin-bottom: 4px; color: var(--button-dark); font-size: 10px; font-weight: 700; }
.answer-card a { color: var(--button-dark); font-weight: 600; }
.answer-card small { display: block; margin-top: 7px; color: #9aa39e; font-size: 9px; }

.suggestions { flex: 0 0 auto; display: flex; flex-wrap: nowrap; gap: 7px; overflow-x: auto; overflow-y: hidden; padding: 13px 24px 10px; border-top: 1px solid var(--line); background: var(--paper); scrollbar-width: none; -ms-overflow-style: none; }
.suggestions button { flex: 0 0 auto; min-height: 34px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: var(--paper); font-size: 11px; white-space: nowrap; transition: color .18s, border-color .18s, background .18s; }
.suggestions button:disabled, .composer button:disabled { cursor: wait; opacity: .55; }
.suggestions button:hover { color: var(--button-dark); border-color: var(--button); background: var(--button-soft); }

.composer { flex: 0 0 auto; display: flex; gap: 8px; padding: 0 24px 11px; background: var(--paper); }
.composer input { min-width: 0; flex: 1; min-height: 38px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 3px; outline: none; color: var(--ink); background: #ffffff; font-size: 12px; }
.composer input:focus { border-color: var(--button); }
.composer button { min-width: 62px; padding: 0 15px; border: 1px solid var(--button-dark); border-radius: 3px; color: white; background: var(--button); font-size: 11px; font-weight: 800; }
.composer button:hover { background: var(--button-dark); }
.disclaimer { flex: 0 0 auto; margin: 0; padding: 0 24px 13px; color: #a1aaa5; background: var(--paper); font-size: 9px; line-height: 1.5; text-align: center; }
.widget-footer { flex: 0 0 auto; display: flex; justify-content: space-between; padding: 8px 24px 18px; color: #a1aaa5; font-size: 9px; background: var(--paper); }
.footer-actions { display: flex; align-items: center; gap: 10px; }
.widget-footer a { color: var(--button-dark); font-weight: 600; text-decoration: none; }
.ai-button { padding: 0; border: 0; color: var(--button-dark); background: transparent; font-size: 9px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.ai-button:hover { color: var(--button); }
.ai-button:disabled { color: var(--muted); cursor: wait; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes thinking-dots { 0% { width: 0; } 33% { width: .5em; } 66% { width: 1em; } 100% { width: 1.5em; } }

@media (min-width: 700px) {
  body { padding: 30px 0; }
  .widget { height: calc(100dvh - 60px); max-height: 820px; border: 1px solid var(--line); border-radius: 4px; }
}

@media (max-width: 699px) {
  .widget { width: 100%; height: 100dvh; border-radius: 0; }
  .intro { padding: 25px 24px 16px; }
}
