/* Binnie 채팅 UI — 각진(0~4px) 단색 다크 테마. 그라데이션 없음.
   로봇 아이콘: Lucide "bot" (https://lucide.dev) — ISC License, Lucide Contributors. HTML/JS 에 인라인 SVG 로 포함. */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --bg: #0b0c0f;
  --surface: #14161b;
  --surface-2: #1b1e25;
  --code-bg: #0e1014;
  --line: #262a33;
  --line-strong: #343947;
  --text: #e6e8ee;
  --muted: #9aa0ad;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.1);
  --accent-line: rgba(59, 130, 246, 0.45);
  --on-accent: #ffffff;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --r: 4px;
  --r-sm: 2px;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
/* 어드민: 포인트 색만 앰버로 */
body[data-mode="admin"] {
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.1);
  --accent-line: rgba(245, 158, 11, 0.45);
  --on-accent: #0b0c0f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-line); color: var(--text); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 820px; margin: 0 auto; padding: 0 16px; }

/* ---- 헤더 ------------------------------------------------------------------ */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--accent);
}
.avatar svg { width: 18px; height: 18px; display: block; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; font-size: 12px; line-height: 1.2; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--muted); background: var(--surface);
}
.badge a { color: inherit; text-decoration: none; }
.badge a:hover { color: var(--text); }
.badge.admin { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ---- 메시지 ---------------------------------------------------------------- */
.messages {
  flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.row { display: flex; gap: 10px; align-items: flex-start; animation: rise 0.2s ease-out; }
.row.user { justify-content: flex-end; }
.row .avatar { width: 28px; height: 28px; margin-top: 2px; }
.row .avatar svg { width: 16px; height: 16px; }
.bubble {
  max-width: min(78%, 640px); min-width: 0; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  word-break: break-word; overflow-wrap: anywhere;
}
.row.user .bubble { background: var(--accent-soft); border-color: var(--accent-line); white-space: pre-wrap; }
.row.assistant .bubble { background: var(--surface); }
.bubble.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- 마크다운 (어시스턴트 말풍선) -------------------------------------------- */
.bubble > :first-child { margin-top: 0 !important; }
.bubble > :last-child { margin-bottom: 0 !important; }
.bubble p { margin: 0.6em 0; }
.bubble :is(h1, h2, h3, h4) { margin: 1.15em 0 0.35em; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; color: var(--text); }
.bubble h1 { font-size: 1.12em; }
.bubble h2 { font-size: 1.06em; }
.bubble :is(h1, h2) { padding-bottom: 0.3em; border-bottom: 1px solid var(--line); }
.bubble :is(h3, h4) { font-size: 1em; }
.bubble :is(h1, h2, h3, h4) + :is(p, ul, ol, .tbl, pre, blockquote) { margin-top: 0.3em; }
.bubble ul, .bubble ol { margin: 0.4em 0; padding-left: 1.3em; }
.bubble li { margin: 0.12em 0; }
.bubble li::marker { color: var(--muted); }
.bubble .tbl { margin: 0.8em 0; overflow-x: auto; }
.bubble table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 1.45; }
.bubble th, .bubble td { padding: 6px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.bubble th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.bubble code { font-family: var(--mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1px 5px; }
.bubble pre { margin: 0.8em 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; line-height: 1.5; }
.bubble pre code { background: none; border: 0; padding: 0; font-size: 12.5px; }
.bubble a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.bubble a:hover { text-decoration-color: var(--accent); }
.bubble blockquote { margin: 0.6em 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--accent); color: var(--muted); }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: 0.8em 0; }
.bubble strong { font-weight: 700; }

/* ---- 진행 상태 & 도구 칩 ------------------------------------------------------ */
.meta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-left: 38px; margin-top: -6px; }
.status {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; font-size: 12.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 1px; background: var(--accent); opacity: 0.3; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tool { font-family: var(--mono); font-size: 11.5px; color: var(--muted); padding: 3px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.tool b { color: var(--text); font-weight: 500; }

/* ---- 추천 질문 ---------------------------------------------------------------- */
/* 추천 질문: 라벨 + 포인트색 외곽선 칩. 답변 말풍선(표면색 채움)과 확실히 구분한다 */
.suggest { display: flex; flex-direction: column; gap: 8px; padding-left: 38px; animation: rise 0.25s ease-out; }
.suggest.initial { padding-left: 0; }
.suggest-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--accent); }
.suggest-label svg { width: 14px; height: 14px; }
.suggest-list { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px dashed var(--accent-line); color: var(--text); border-radius: var(--r-sm);
  padding: 7px 12px 7px 8px; font: inherit; font-size: 13px; line-height: 1.4; cursor: pointer; text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.suggest button .q { display: grid; place-items: center; width: 18px; height: 18px; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent, #fff); font-size: 11px; font-weight: 700; flex: none; }
.suggest button:hover, .suggest button:active { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

/* ---- 입력 ----------------------------------------------------------------------- */
.composer { padding: 12px 0 8px; }
form {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); transition: border-color 0.15s;
}
form:focus-within { border-color: var(--accent); }
textarea {
  flex: 1; resize: none; background: transparent; color: var(--text); border: 0; outline: none;
  padding: 8px 0; font: inherit; line-height: 1.5; min-height: 24px; max-height: 200px;
}
textarea::placeholder { color: var(--muted); }
button.send {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); transition: opacity 0.15s;
}
button.send:hover { opacity: 0.88; }
button.send:disabled { opacity: 0.35; cursor: default; }
button.send svg { width: 18px; height: 18px; display: block; }
footer { color: var(--muted); font-size: 11.5px; text-align: center; padding: 0 0 12px; }
footer a { color: inherit; }

/* ---- 모바일 ------------------------------------------------------------------- */
@media (max-width: 600px) {
  header { padding: 10px 0; }
  .avatar { width: 28px; height: 28px; }
  .avatar svg { width: 16px; height: 16px; }
  .brand h1 { font-size: 14px; }
  .brand p { display: none; }
  .badge { font-size: 10px; padding: 3px 6px; }
  .messages { gap: 12px; }
  .bubble { max-width: 92%; }
  .row .avatar { display: none; }
  .meta, .suggest { padding-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .row, .suggest { animation: none; }
  .dots i { animation: none; opacity: 0.6; }
}

/* 생성형 UI 블록이 들어간 말풍선은 가로를 넉넉히 쓴다 */
.row.assistant .bubble.has-ui { max-width: min(100%, 720px); width: 100%; }
