/* 야르한 챗봇퀸 웹 화면.
   모양 규칙(한 가지로 고정): 말풍선 18px, 카드 14px, 버튼·입력창은 알약(둥근 끝).
   색 규칙: 강조색은 학교 파랑 하나. 밝은 모드·어두운 모드 모두 지원(시스템 설정 따름).
   모션: 짧은 전환만. 움직임 줄이기 설정이면 전부 끈다. */

:root {
  --bg: #f3f4f6;
  --surface: #fcfcfd;
  --surface-2: #e9ebef;
  --text: #18181b;
  --muted: #5f6370;
  --line: #dcdfe5;
  --accent: #0a4a9b;
  --accent-ink: #f6f9ff;
  --accent-soft: #e3ecf8;
  --user: #0a4a9b;
  --user-ink: #f6f9ff;
  --danger: #a3341f;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(23, 34, 56, .06), 0 8px 24px rgba(23, 34, 56, .06);
  --r-bubble: 18px;
  --r-card: 14px;
  --r-pill: 999px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1c1d21;
    --surface-2: #26282e;
    --text: #ecedef;
    --muted: #a0a3ab;
    --line: #2e3038;
    --accent: #7fb0ea;
    --accent-ink: #0b1220;
    --accent-soft: #1f2f45;
    --user: #2d5c9e;
    --user-ink: #f3f7ff;
    --danger: #e08a74;
    --warn: #f0b060;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 상단 바: 56px, 한 줄 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto; height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 15px;
}
.brand h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.status { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.2; }
.status.ok { color: var(--accent); }
.status.bad { color: var(--danger); }
.status.warn { color: var(--warn); }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.96); }

/* 대화 영역 */
.chat {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 14px;
}
#messages { display: flex; flex-direction: column; gap: 14px; }
.intro { display: flex; flex-direction: column; gap: 12px; }
.intro[hidden] { display: none; }

.msg { display: flex; flex-direction: column; gap: 10px; max-width: 92%; scroll-margin-top: 72px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; }

.bubble {
  padding: 12px 16px; border-radius: var(--r-bubble);
  background: var(--surface); box-shadow: var(--shadow);
  word-break: keep-all; overflow-wrap: anywhere;
}
.bubble p { margin: 0; white-space: pre-wrap; }
.bubble p + p { margin-top: 8px; }
.bubble.bot { border-bottom-left-radius: 6px; }
.bubble.user {
  background: var(--user); color: var(--user-ink);
  border-bottom-right-radius: 6px; box-shadow: none;
}
.bubble.error { border: 1px solid var(--danger); }
.cite {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  margin: 0 1px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; line-height: 1; vertical-align: 2px;
}

/* 예시 고민 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip:active { transform: scale(.97); }

/* 추천 카드 */
.cards { display: grid; grid-template-columns: 1fr; gap: 10px; width: 100%; }
.cards-label { margin: 0; font-size: 13px; color: var(--muted); }
.card {
  padding: 14px 16px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.card-head { display: flex; align-items: center; gap: 8px; }
.card-n {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
}
.card-cat { font-size: 12px; color: var(--muted); }
.card-name { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; word-break: keep-all; overflow-wrap: anywhere; }
.card-meta { margin: 0; font-size: 14px; }
.card-meta strong { color: var(--accent); font-weight: 600; }
.card-dept { margin: 0; font-size: 13px; color: var(--muted); }
.card-link {
  align-self: flex-start; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
  font-size: 14px; font-weight: 600;
}
.card-link:hover { filter: brightness(1.08); }
.card-link:active { transform: translateY(1px); }
.hint { margin: 0; font-size: 14px; color: var(--muted); }

/* 로딩: 말풍선 모양 뼈대 */
.skeleton { width: min(72%, 420px); display: flex; flex-direction: column; gap: 8px; }
.skeleton span {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton span:nth-child(2) { width: 85%; } .skeleton span:nth-child(3) { width: 60%; }
.skeleton-note { font-size: 12px; color: var(--muted); margin: 0; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* 입력창: 화면 아래 고정, 알약 */
.composer {
  position: sticky; bottom: 0; z-index: 10;
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}
.composer textarea {
  flex: 1; min-height: 46px; max-height: 140px; resize: none;
  padding: 12px 18px; border-radius: 23px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; line-height: 1.4;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.send {
  width: 46px; height: 46px; flex: none; border-radius: var(--r-pill); border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 20px; cursor: pointer;
  display: grid; place-items: center;
}
.send:disabled { opacity: .5; cursor: default; }
.send:not(:disabled):active { transform: scale(.95); }

.retry {
  margin-top: 8px; padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}

.msg, .intro { animation: rise .25s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .msg, .intro { animation: none; }
  .skeleton span { animation: none; }
  * { transition: none !important; }
}
@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .msg { max-width: 80%; }
}
