:root {
  --bg: #f6efe4;
  --ink: #2a211b;
  --muted: #7a6a5c;
  --dark: #1e1a17;
  --accent: #c2502c;
  --me: #c2502c;
  --me-ink: #fff;
  --bot: #ffffff;
  --line: #e4d8c6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Noto Sans SC", "Noto Sans KR", sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
}
.top {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--dark); color: #fff; padding: 10px 16px; gap: 8px;
}
.brand { font-size: 13px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand b { font-size: 18px; margin-left: 4px; }
#lang { font-size: 14px; padding: 4px 6px; border-radius: 8px; border: 0; }

.stage {
  position: relative; display: flex; align-items: flex-end; gap: 4px;
  padding: 6px 16px 0; background: linear-gradient(#efe3cf, var(--bg));
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
#kohaku { width: 112px; height: 168px; object-fit: contain; object-position: bottom; flex: 0 0 auto; transition: opacity .15s; }
#kohaku.swap { opacity: .3; }
.hello {
  background: #fff; border-radius: 14px; padding: 10px 12px; margin-bottom: 14px;
  font-size: 15px; line-height: 1.5; box-shadow: 0 1px 3px #0002; position: relative;
}
.hello::before { content: ""; position: absolute; left: -8px; bottom: 16px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }

#log { flex: 1 1 auto; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 12px; border-radius: 14px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--me); color: var(--me-ink); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.err { align-self: center; background: #fff3f0; color: #8a2b14; font-size: 13px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: b 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 8px; flex: 0 0 auto; scrollbar-width: none; }
.chips button { flex: 0 0 auto; border: 1px solid var(--accent); color: var(--accent); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 14px; }

.bar { display: flex; gap: 8px; padding: 8px 16px; background: #fff; border-top: 1px solid var(--line); flex: 0 0 auto; }
#input { flex: 1; resize: none; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 20px; max-height: 120px; font-family: inherit; }
#send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 18px; }
#send:disabled { background: #c9b9a8; }
.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 0 16px calc(6px + env(safe-area-inset-bottom)); background: #fff; }

.blocked { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; }
.blocked[hidden] { display: none; }
.blocked img { width: 160px; height: 240px; object-fit: contain; }
.blocked p { font-size: 16px; line-height: 1.6; max-width: 420px; white-space: pre-wrap; }
