:root{
  --kurayoshi-blue:#002F6C;
  --kurayoshi-red:#E60012;
  --kurayoshi-bg:#FFFAF0;

  --send-btn-w: 96px;   /* ボタンの最小幅 */
  --send-btn-h: 44px;   /* ボタン高さ */
  --send-inset: 8px;    /* 右下の寄せ具合 */

  --surface:#fff;
  --ink:#1f2937;
  --bubble-user:#fff;
  --bubble-assist:#f4f7ff;
  --line:rgba(0,0,0,.06);
  --line-blue:rgba(0,47,108,.16);
  --ring:rgba(0,47,108,.35);

  --avatar-size:48px;          /* くらすけくんのサイズ */
  --avatar-scale:0.9;          /* 少しだけ縮小 */
  --avatar-nudge-y:-1px;       /* 上下の微調整（マイナスで上へ） */
  --tail-offset:20px;          /* 吹き出しの三角の縦位置 */
}

/* === Reset & Base === */
*{box-sizing:border-box;}
html,body{height:100%;margin:0;}
body{
  min-height:100%;
  color:var(--ink);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans JP",sans-serif;
  background:
    radial-gradient(1200px 800px at -10% -10%, rgba(0,47,108,.05), transparent 55%),
    radial-gradient(1000px 600px at 110% 0%, rgba(230,0,18,.05), transparent 55%),
    var(--kurayoshi-bg);
}

/* === Layout === */
.container{
  height:100dvh;
  display:grid;
  grid-template-rows:auto 1fr auto;
  max-width:920px;
  margin:0 auto;
  padding:20px;
  gap:14px;
}

/* === Header === */
/* ====== ヘッダー共通 ====== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
}

.reset-btn {
  background: none;
  border: none;
  color: var(--kurayoshi-blue);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.2s ease;
}

.reset-btn:hover {
  color: #001f4f;
}

/* ====== スマホ対応（狭いときは縦配置） ====== */
@media (max-width: 520px) {
  .header {
    flex-direction: column;     /* ← 横並び → 縦並びに！ */
    align-items: flex-start;    /* 左寄せ */
    gap: 4px;                   /* タイトルとの間をちょっと詰める */
  }

  .header-left {
    width: 100%;
    justify-content: flex-start;
  }

  .title {
    font-size: 18px;
  }

  .reset-btn {
    align-self: flex-end;       /* ← 右端に寄せる */
    font-size: 13px;
  }
}

/* ==== リセットボタン（テキスト版） ==== */
.reset-btn {
  background: none;
  border: none;
  color: var(--kurayoshi-blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.reset-btn:hover {
  background-color: rgba(0, 47, 108, 0.08); /* 倉吉ブルーをうっすら背景に */
  color: #003a8c; /* 少し濃い青 */
}

/* === Chat card === */
.chat{
  background:var(--surface);
  border-radius:20px;
  padding:18px;
  overflow:auto;
  border:1px solid rgba(0,0,0,.03);
  box-shadow:0 10px 30px rgba(0,0,0,.06), inset 0 1px 0 rgba(255,255,255,.35);
}
.chat::-webkit-scrollbar{width:10px;}
.chat::-webkit-scrollbar-thumb{
  background:rgba(0,0,0,.12);
  border-radius:999px;
  border:2px solid transparent;
  background-clip:padding-box;
}

/* === Message rows === */
.msgRow{display:grid;grid-template-columns:1fr;margin:10px 0;}
.msgRow.assistant{display:flex;align-items:flex-start;gap:8px;}
.msgRow.user{display:grid;grid-template-columns:1fr auto;justify-items:end;}

/* === Avatar（くらすけくん） === */
.avatar{
  width: 64px;          /* ← 48px → 64px に拡大 */
  height: 64px;
  background: none;     /* ← 背景の白丸を消す */
  border: none;         /* ← 枠線も消す */
  box-shadow: none;     /* ← 影も消す */
  margin-top: calc(var(--tail-offset) - 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -5px; 
}

.msgRow.assistant .avatar img{
  display: block;
  width: 100%;          /* ← 枠ぴったりサイズに */
  height: auto;
  object-fit: contain;
  transform: translateY(var(--avatar-nudge-y));
}


/* === Bubbles === */
.bubble{
  position:relative;
  z-index:1;
  max-width:78%;
  padding:1px 20px;
  border-radius:16px;
  line-height:1.7;
  border:1px solid var(--line);
  transform:translateY(4px);
  opacity:0;
  animation:pop .18s ease-out forwards;
  word-break:break-word;
}
.bubble.user{
  background:var(--bubble-user);
  box-shadow:0 1px 2px rgba(0,0,0,.05);
}
.bubble.assistant{
  background:var(--bubble-assist);
  border-color:var(--line-blue);
  box-shadow:0 1px 2px rgba(0,47,108,.06);
}
@keyframes pop{
  from{transform:translateY(4px);opacity:0;}
  to{transform:translateY(0);opacity:1;}
}
.msgRow.assistant .bubble{margin-left:8px;}

/* === Tail (吹き出しの三角) === */
.bubble.assistant::before,
.bubble.assistant::after{
  content:"";
  position:absolute;
  z-index:2;
  pointer-events:none;
  top:var(--tail-offset);
  left:-10px;
  border-style:solid;
  border-color:transparent;
  border-width:6px 15px 6px 0;
}
.bubble.assistant::before{
  left:-13px;
  border-right-color:rgba(0,47,108,.16);
}
.bubble.assistant::after{
  border-right-color:var(--bubble-assist);
}

/* 考え中バブル：縦中央にテールを合わせる＆少し丸く */
#typingRow .bubble {
  padding: 8px 16px;          /* 小さめの高さで丸-pillに */
}

/* テールを中央に */
#typingRow .bubble.assistant::before,
#typingRow .bubble.assistant::after{
  top: 50%;
  transform: translateY(-50%);
}

/* === Input bar === */
/* 入力バー */
.inputBar{
  position: sticky;
  bottom: 0;
  padding: 12px clamp(12px, 2vw, 20px) calc(12px + env(safe-area-inset-bottom)); /* ← 少し厚めに */
  background: #FFFAF0;
  z-index: 50;
}

/* ラッパー */
.taWrap{
  position: relative;
  max-width: 920px;
  margin: 0 auto;
}

/* テキストエリア本体（高さをしっかり確保） */
.taWrap textarea{
  display: block;
  width: 100%;
  min-height: 72px;                /* ← ここを厚めに */
  max-height: 240px;
  padding: 14px 60px 14px 14px;    /* ← ボタンぶん右に余白を確保（60px） */
  line-height: 1.6;
  font-size: 16px;
  resize: vertical;                 /* 1行固定にしたいなら 'none' に */
  background: #fff;
  color: #111827;

  border: 1px solid #e5e7eb;
  border-radius: 14px;
  outline: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

/* 送信ボタン（テキストエリアの内側右下） */
.taWrap .sendBtn{
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 40px;                     /* ほんの少し大きく */
  height: 40px;
  border: none;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #0058cc;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: transform .05s ease, opacity .15s ease;
  z-index: 2;                      /* 念のためテキストエリアより前面 */
}

/* 送信ボタンホバー時に少し濃くなる */
.taWrap .sendBtn:hover {
  background-color: #0048a3;  /* ← 少し濃いブルー */
}

/* 送信ボタン：textarea の内側右下に固定 */
.taWrap .sendBtn{
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 46px;    /* ← 40 → 46 に拡大 */
  height: 46px;
  border: none;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #0058cc;  /* 倉吉ブルー */
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: transform .05s ease, opacity .15s ease;
}

/* === Send icon (arrow) === */
.taWrap .sendBtn svg{
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none; /* 押しやすく */
}



.taWrap .sendBtn:disabled{
  opacity: .5;
  cursor: default;
  box-shadow: none;
}

.taWrap .sendBtn:active{
  transform: translateY(1px);
}

/* iOS のスクロール時のチラつき対策（任意） */
@supports (backdrop-filter: blur(0)) {
  .inputBar{
    backdrop-filter: saturate(120%) blur(0px);
  }
}



/* === Typing dots === */
.typing{display:inline-flex;gap:4px;align-items:center;}
.dot{
  width:6px;height:6px;border-radius:50%;
  background:var(--kurayoshi-blue);
  animation:blink 1.2s infinite;
}
.dot:nth-child(2){animation-delay:.2s;}
.dot:nth-child(3){animation-delay:.4s;}
@keyframes blink{
  0%,80%,100%{opacity:.2;transform:translateY(0);}
  40%{opacity:1;transform:translateY(-2px);}
}

/* === Accessibility === */
:focus-visible{outline:2px solid var(--ring);outline-offset:2px;}
.logo{width:28px;height:28px;object-fit:contain;}

@media (max-width: 480px){
  :root{
    --send-btn-w: 84px;
    --send-btn-h: 40px;
    --send-inset: 6px;
  }
}

.disclaimer{
  margin: 4px 0 0;
  font-size: 12px;
  text-align: center;
  color: rgba(0,0,0,0.38);
}

.bubble a{
  color: var(--kurayoshi-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.bubble a:hover{
  color: #002F6C;
  text-decoration-thickness: 2px;
}

/* style.css のいちばん最後に置く */
.msgRow.user > .bubble{
  padding: 12px 22px;
  line-height: 1.65;
}
