/* 색상: 동신대학교 전용색상(dsu.ac.kr > 동신대소개 > UI > 색상활용) 기준
   상징색 동신청색 #0b56a6 / 보조색 동신주황(M55+Y100 계열), 동신녹색(C100+M10+Y50 계열) */
:root {
  --blue: #0b56a6;
  --blue-dark: #08437f;
  --blue-soft: #e6eef9;
  --orange: #f58220;
  --orange-soft: #fff1e3;
  --green: #0fa38b;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d5deec;
  --bg: #eef3fa;
  --card: #ffffff;
  --err-bg: #fef2f2;
  --err-border: #fca5a5;
  --panel-w: 680px;
  --panel-h: 810px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  color: var(--text);
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, rgba(11, 86, 166, 0.05) 25%, transparent 25%, transparent 75%, rgba(11, 86, 166, 0.05) 75%) 0 0 / 24px 24px,
    linear-gradient(45deg, rgba(11, 86, 166, 0.05) 25%, transparent 25%, transparent 75%, rgba(11, 86, 166, 0.05) 75%) 12px 12px / 24px 24px,
    var(--bg);
}

/* 채팅창은 고정 크기. 화면이 더 작으면 화면에 맞춘다. */
.app {
  width: min(var(--panel-w), 100vw);
  height: min(var(--panel-h), 100vh);
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 700px) and (min-height: 830px) {
  .app { border-radius: 18px; box-shadow: 0 10px 40px rgba(11, 86, 166, 0.22); }
}

.view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.hidden { display: none; }

/* ---------- 시작 화면 ---------- */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 30px 28px 0;
  background:
    linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  overflow: hidden;
}
.hero::before,
.hero::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.09);
  width: 22px;
  height: 22px;
}
.hero::before { top: 18px; right: 40%; box-shadow: 44px 22px 0 rgba(255, 255, 255, 0.07), -66px 44px 0 var(--orange); }
.hero::after { bottom: 70px; left: 28px; width: 14px; height: 14px; box-shadow: 28px -28px 0 rgba(255, 255, 255, 0.1); }

.hero-text { position: relative; z-index: 1; padding-bottom: 28px; min-width: 0; }
.eyebrow {
  display: inline-block;
  padding: 2px 10px;
  margin-bottom: 10px;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
}
.hero h1 { margin: 0 0 14px; line-height: 1.2; }
.hero h1 .name { display: block; font-size: 36px; letter-spacing: -1px; }
.hero h1 .sub { display: block; margin-top: 4px; font-size: 15px; font-weight: 400; opacity: 0.92; }
.speech {
  position: relative;
  margin: 0;
  padding: 11px 14px;
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  font-size: 14px;
}
.speech::before {
  content: '';
  position: absolute;
  right: -9px;
  bottom: 18px;
  border: 8px solid transparent;
  border-left: 10px solid #fff;
  border-right-width: 0;
}

.hero-mascot {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: auto;
  height: 215px;
  margin-bottom: -2px;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.18));
  animation: bob 1.6s steps(2, end) infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.pick { padding: 24px 28px 0; flex: 1; overflow-y: auto; }
.pick-title { margin: 0 0 12px; font-size: 16px; }
.cards { display: flex; flex-direction: column; gap: 14px; }

.card {
  --accent: var(--blue);
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  box-shadow: 4px 4px 0 var(--blue-soft);
  font: inherit;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.card.sangsang { --accent: var(--orange); box-shadow: 4px 4px 0 var(--orange-soft); }
.card:hover, .card:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 6px 6px 0 var(--accent);
  outline: none;
}
.card-badge {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
}
.card strong { display: block; font-size: 17px; margin-bottom: 2px; }
.card span.desc { color: var(--muted); font-size: 13px; }

.notice { margin: 18px 28px 0; padding: 12px 16px 12px 30px; background: var(--blue-soft); border-radius: 8px; color: #44556e; font-size: 13px; }
.notice li + li { margin-top: 4px; }

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 28px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.brand img { display: block; }

/* ---------- 채팅 화면 ---------- */
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  border-bottom: 4px solid var(--orange);
}
.head-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 3px;
  background: #fff;
  border-radius: 50%;
}
.chat-title { flex: 1; min-width: 0; line-height: 1.3; }
.chat-title strong { display: block; font-size: 19px; }
.chat-title span { display: block; font-size: 12.5px; opacity: 0.9; }
.ghost {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ghost:hover { background: rgba(255, 255, 255, 0.16); }

.system-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.badge {
  padding: 1px 8px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
#chat-view[data-system='sangsang'] .badge { background: var(--orange); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { display: flex; gap: 8px; max-width: 92%; }
.msg.user { align-self: flex-end; }
.msg.bot { align-self: flex-start; }
.avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
}
.col { min-width: 0; }

.bubble {
  padding: 10px 13px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.user .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 3px; }
.bot .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.bot.fallback .bubble { background: var(--orange-soft); border-color: #f7b878; }
.bot.error .bubble { background: var(--err-bg); border-color: var(--err-border); }

.sources {
  margin-top: 6px;
  padding: 8px 11px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.sources b { color: var(--text); }
.sources ul { margin: 4px 0 0; padding-left: 16px; }
.sources a { color: var(--blue); word-break: break-all; }

.typing { color: var(--muted); }
.typing::after { content: ''; display: inline-block; width: 1.4em; text-align: left; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.msg.pending .avatar { animation: bob 0.8s steps(2, end) infinite; }

.samples-box { background: var(--bg); }
.samples-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 14px 0;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 12.5px;
  color: var(--blue);
  cursor: pointer;
}
.samples-toggle:hover { border-color: var(--orange); background: var(--orange-soft); color: var(--blue-dark); }
.samples-toggle::after { content: '▾'; display: inline-block; font-size: 14px; line-height: 1; transition: transform 0.2s; }
.samples-box.collapsed .samples-toggle::after { transform: rotate(180deg); }
.samples-box.collapsed .samples { display: none; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 0; background: var(--bg); }
.samples:empty { display: none; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--orange); color: var(--blue-dark); background: var(--orange-soft); }

.composer { display: flex; gap: 8px; padding: 10px 14px 4px; background: var(--bg); }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 110px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
}
.composer textarea:focus { outline: 2px solid #b8cdea; border-color: var(--blue); }
.composer button {
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.composer button:hover { background: var(--blue-dark); }
.composer button:disabled { background: #9db8dc; cursor: not-allowed; }
.composer-note { margin: 0; padding: 4px 14px 10px; background: var(--bg); color: var(--muted); font-size: 12px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .hero-mascot, .msg.pending .avatar, .typing::after { animation: none; }
}

@media (max-width: 480px) {
  .hero { padding: 22px 18px 0; }
  .hero h1 .name { font-size: 30px; }
  .hero-mascot { height: 150px; }
  .pick, .brand { padding-left: 18px; padding-right: 18px; }
  .notice { margin-left: 18px; margin-right: 18px; }
}
