/* TOWER — 모바일 우선. 키트 QR 로 들어오는 경로가 대부분이므로
   좁은 화면을 기본값으로 잡고 넓은 화면을 예외로 다룬다. */

:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --blue: #1d6fd0;
  --blue-soft: #e8f1fb;
  --sky: #8ecae6;
  --ink: #16202e;
  --muted: #64748b;
  --line: #dbe4ee;
  --bg: #f6f9fc;
  --card: #ffffff;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 37, 69, .06), 0 8px 24px rgba(11, 37, 69, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px;
  margin: 0 auto; background: var(--bg); }

/* ── 헤더 ── */
header {
  flex: 0 0 auto; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
header .mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: rgba(255, 255, 255, .12); display: grid; place-items: center; font-size: 18px;
}
header .who { flex: 1 1 auto; min-width: 0; }
/* 좁은 화면에서 제목이 여러 줄로 접히면 헤더가 뚱뚱해진다. 한 줄로 고정하고
   넘치면 말줄임으로 처리한다. */
header .who b { display: block; font-size: 15px; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header .who b #modeTag { font-size: 12.5px; }
header .who > span { display: block; font-size: 12px; opacity: .75;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header .acts { display: flex; gap: 6px; flex: 0 0 auto; }
header button {
  background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 8px;
  padding: 7px 10px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
header button:hover { background: rgba(255, 255, 255, .24); }
header button.on { background: var(--sky); color: var(--navy); font-weight: 600; }

/* ── 대화 영역 ── */
#log { flex: 1 1 auto; overflow-y: auto; padding: 16px 14px 8px;
  -webkit-overflow-scrolling: touch; }

.msg { margin: 0 0 14px; display: flex; }
.msg .bubble {
  max-width: 86%; padding: 11px 14px; border-radius: var(--radius);
  white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow);
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--card); border: 1px solid var(--line);
  border-bottom-left-radius: 4px; }
.msg.bot.demo .bubble { border-color: #cfe3f7; background: #fbfdff; }

.cite { margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 12.5px; color: var(--muted); }
.cite a { color: var(--blue); text-decoration: none; }
.cite a:hover { text-decoration: underline; }
.cite .item { display: block; margin-top: 3px; }

.rate { margin-top: 8px; display: flex; gap: 6px; }
.rate button { border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 3px 11px; font-size: 13px; cursor: pointer; color: var(--muted);
  font-family: inherit; }
.rate button:hover { border-color: var(--blue); color: var(--blue); }
.rate button.done { background: var(--blue-soft); border-color: var(--blue);
  color: var(--blue); cursor: default; }

.notice { text-align: center; font-size: 12.5px; color: var(--muted);
  margin: 6px 0 14px; }
.notice.warn { color: var(--warn); }

.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 3px;
  background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ── 추천 질문 ── */
#chips { flex: 0 0 auto; display: flex; gap: 7px; overflow-x: auto; padding: 0 14px 10px;
  scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }
#chips button {
  flex: 0 0 auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 13.5px; cursor: pointer;
  color: var(--navy-2); font-family: inherit; white-space: nowrap;
}
#chips button:hover { border-color: var(--blue); color: var(--blue); }

/* ── 입력 ── */
#composer { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
#composer textarea {
  flex: 1 1 auto; resize: none; border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 12px; font-size: 16px; font-family: inherit; line-height: 1.5;
  max-height: 120px; background: #fff; color: var(--ink);
}
#composer textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
#composer button {
  flex: 0 0 auto; background: var(--blue); color: #fff; border: 0; border-radius: 11px;
  padding: 0 18px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
}
#composer button:disabled { background: #b7c6d6; cursor: not-allowed; }

/* ── 모달 ── */
.mask { position: fixed; inset: 0; background: rgba(11, 37, 69, .45);
  display: grid; place-items: center; padding: 20px; z-index: 50; }
.mask[hidden] { display: none; }
.modal { background: var(--card); border-radius: 16px; padding: 22px; width: 100%;
  max-width: 400px; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }
.modal p { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.modal input, .modal textarea, .modal select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 16px; font-family: inherit; margin-bottom: 10px; color: var(--ink);
  background: #fff;
}
.modal textarea { min-height: 90px; resize: vertical; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.modal .row button { border-radius: 10px; padding: 9px 16px; font-size: 14px;
  cursor: pointer; font-family: inherit; border: 1px solid var(--line);
  background: #fff; color: var(--muted); }
.modal .row button.primary { background: var(--blue); color: #fff; border-color: var(--blue);
  font-weight: 600; }
.modal .err { color: #b91c1c; font-size: 13px; margin: 0 0 10px; }
.modal .err[hidden] { display: none; }

@media (min-width: 721px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
