.ai-wrap { padding-bottom: clamp(24px, 4vh, 48px); }
.ai-head { display: flex; align-items: center; gap: clamp(14px, 2vw, 24px); margin: clamp(22px, 4vh, 44px) 0 clamp(14px, 2vh, 22px); }
.ai-face { width: clamp(76px, 9vw, 112px); flex: none; animation: bob 5s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.ai-head h1 { margin: 0 0 4px; font-size: var(--t-h2); line-height: 1.3; letter-spacing: .04em; }
.ai-head p { margin: 0; color: var(--muted); }

/* 会話の枠：画面の高さに合わせ、中だけをスクロールする */
.chat { position: relative; display: flex; flex-direction: column; height: clamp(460px, calc(100svh - 270px), 900px); overflow: hidden;
  background: linear-gradient(180deg, #f6fbfe 0%, #fff 40%); }
.log { flex: 1; overflow-y: auto; padding: clamp(18px, 3vw, 36px) clamp(16px, 4vw, 56px) 12px; scroll-behavior: smooth; }
.hello { min-height: 100%; display: grid; align-content: center; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 680px; margin: 0 auto; }
.chips button {
  border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 999px; padding: 10px 18px;
  font: inherit; font-size: 14.5px; font-weight: 500; line-height: 1.4; cursor: pointer;
  box-shadow: 0 1px 2px rgba(14, 27, 62, .05); transition: transform .15s, border-color .15s;
}
.chips button:hover { border-color: var(--blue); transform: translateY(-1px); }

.msg { display: flex; gap: 12px; margin: 0 0 22px; animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--navy); color: #fff; border-radius: 22px 22px 6px 22px; padding: 11px 18px; max-width: min(80%, 34em); white-space: pre-wrap; }
.m-ava { width: 46px; flex: none; margin-top: 2px; }
.m-ava img { display: block; width: 100%; }
.thinking .m-ava img { animation: puff 1.4s ease-in-out infinite; }
@keyframes puff { 50% { transform: scale(1.05, .95) translateY(2px); } }
.msg.bot .bubble { background: #fff; border-radius: 6px 22px 22px 22px; padding: 16px 22px; box-shadow: var(--shadow); min-width: 0; flex: 1; max-width: 46em; line-height: 1.85; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .8em; }
.bubble ol, .bubble ul { margin: 0 0 .9em; padding-left: 1.4em; }
.bubble li { margin: .2em 0; }
.bubble strong { color: var(--navy); }
.bubble h1, .bubble h2, .bubble h3 { font-size: 16px; margin: 1em 0 .4em; color: var(--navy); }
.bubble table { border-collapse: collapse; margin: 0 0 1em; font-size: 14px; display: block; overflow-x: auto; max-width: 100%; }
.bubble th, .bubble td { border-bottom: 1px solid var(--line); padding: 7px 12px; text-align: left; white-space: nowrap; }
.bubble th { background: #f2f6fb; color: var(--navy); }
.bubble code { background: #f1f5f9; border-radius: 6px; padding: 1px 6px; font-size: .92em; }
.ref {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: 1px; margin: 0 2px; padding: 0 9px;
  background: #faf3d8; color: var(--gold-ink); border: 1px solid #eedc9c; border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 700; line-height: 1.7; cursor: pointer;
}
.ref:hover { background: #f4e7b4; }
.ref svg { width: 11px; height: 11px; }
.err { background: #fff4f2; border: 1px solid #f3cfc7; color: #8a2f1d; border-radius: 14px; padding: 10px 14px; }
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9cb5cc; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 40% { opacity: 1; transform: translateY(-3px); } 0%, 80%, 100% { opacity: .35; } }

.composer { padding: 10px clamp(12px, 3vw, 40px) 14px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .9); }
.field { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 26px; padding: 7px 7px 7px 20px; transition: border-color .15s, box-shadow .15s; }
.field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(32, 82, 159, .1); }
.field textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font: inherit; font-size: 16px; line-height: 1.6; padding: 8px 0; max-height: 160px; }
.field textarea::placeholder { color: #9aabbd; }
#send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; cursor: pointer; background: var(--navy); color: #fff; display: grid; place-items: center; transition: background .15s; }
#send:hover { background: var(--blue); }
#send:disabled { background: #b8c6d4; cursor: default; }
#send svg { width: 20px; height: 20px; }
.fine { margin: 8px 6px 0; font-size: 11.5px; color: var(--muted); text-align: center; }

/* 合言葉 */
.gate { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 24px;
  background: linear-gradient(180deg, #eef7fd, #fff 70%); text-align: center; }
.gate[hidden] { display: none; }
.gate img { width: 120px; margin-bottom: 6px; }
.gate label { font-weight: 700; color: var(--navy); letter-spacing: .08em; }
.gate-row { display: flex; gap: 8px; width: min(380px, 84vw); }
.gate input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line); outline: 0; }
.gate input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(32, 82, 159, .1); }
.gate .fine { max-width: 26em; }
.gate .fine.bad { color: #a3361f; }

/* 元の写真 */
.scan { border: 0; border-radius: 20px; padding: 18px; width: min(760px, 94vw); max-height: 92vh; box-shadow: 0 30px 80px -20px rgba(14, 27, 62, .5); }
.scan::backdrop { background: rgba(14, 27, 62, .5); backdrop-filter: blur(3px); }
.scan img { display: block; margin: 0 auto; max-width: 100%; max-height: calc(92vh - 90px); width: auto; height: auto; border-radius: 10px; }
.scan-t { margin: 0 0 12px; font-weight: 700; color: var(--navy); }
.close { position: absolute; right: 14px; top: 8px; border: 0; background: none; font-size: 28px; color: var(--muted); cursor: pointer; }

@media (max-width: 600px) {
  .ai-head { margin-top: 18px; }
  .chat { height: calc(100svh - 200px); min-height: 420px; border-radius: 22px; }
  .m-ava { display: none; }
  .msg.bot .bubble { padding: 14px 16px; }
}
