:root {
  --navy: #10243f; --navy2: #1d3b64; --accent: #2f7de1;
  --bg: #f1f4f8; --bot: #ffffff; --user: #dbe8fb; --text: #1e2634; --muted: #6b7280; --line: #d8dee8;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: "Malgun Gothic","맑은 고딕","Apple SD Gothic Neo","Noto Sans KR",sans-serif; background: var(--bg); color: var(--text); display: flex; justify-content: center; }
.app { width: 100%; max-width: 720px; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

header { background: var(--navy); color: #fff; padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo { width: 36px; height: 36px; border-radius: 50%; background: #fff; color: var(--navy); font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ttl { min-width: 0; }
header h1 { font-size: 16px; margin: 0; font-weight: 700; line-height: 1.2; }
header p { margin: 2px 0 0; font-size: 11.5px; opacity: .8; }
.hbtn { margin-left: auto; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.hbtn:hover { background: rgba(255,255,255,.2); }

.messages { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: flex-end; gap: 6px; }
.row.user { justify-content: flex-end; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bubble { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.row.bot .bubble { background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.row.user .bubble { background: var(--user); border-bottom-right-radius: 4px; }
.time { font-size: 10.5px; color: var(--muted); flex-shrink: 0; margin-bottom: 2px; }
.related { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.related button, .cands button { font: inherit; font-size: 12.5px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--accent); background: #fff; color: var(--accent); cursor: pointer; text-align: left; }
.cands { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cands button { border-radius: 10px; }
.lbl { font-size: 12px; color: var(--muted); margin-top: 8px; }

.typing { display: inline-flex; align-items: center; gap: 8px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; display: inline-block; animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }
.typing .label { font-size: 12.5px; color: var(--muted); }

.composer { display: flex; gap: 8px; padding: 8px 12px; background: #fff; border-top: 1px solid var(--line); flex-shrink: 0; }
textarea { flex: 1; resize: none; overflow-y: hidden; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 15px; line-height: 1.4; max-height: 120px; min-height: 42px; outline: none; }
textarea:focus { border-color: var(--accent); }
.send { width: 46px; border: 0; border-radius: 12px; background: var(--navy); color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0; }
.send:disabled { background: #9ca3af; cursor: default; }
.foot { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 12px calc(8px + env(safe-area-inset-bottom)); background: #fff; flex-shrink: 0; }

.overlay { position: fixed; inset: 0; background: rgba(16,36,63,.45); display: none; align-items: flex-end; justify-content: center; z-index: 20; }
.overlay.show { display: flex; }
.panel { background: #fff; width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 86dvh; display: flex; flex-direction: column; }
@media (min-width: 600px) { .overlay { align-items: center; } .panel { border-radius: 16px; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { font-size: 16px; margin: 0; }
.xbtn { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.filter { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 14px; margin: 10px 0; }
.faqlist { overflow-y: auto; }
.faqlist h3 { font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.faqlist button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text); }
.faqlist button:hover { background: #f5f8fc; }
.err { font-size: 13px; color: #b91c1c; padding: 10px 12px; }
