*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: #f7f3ec;
  color: #17324d;
  font-family: 'Noto Sans TC', sans-serif;
  -webkit-font-smoothing: antialiased;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: rgba(23,50,77,0.18);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

@keyframes om-blink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@keyframes om-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
.site-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 22px;
  background: rgba(247,243,236,0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(23,50,77,0.09);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-labels {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #b76d7f;
}
.site-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #17324d;
}

/* ── Avatars ── */
.avatar {
  border-radius: 50%;
  background: linear-gradient(155deg, #1d3c5a, #0f2438);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar-sm {
  width: 36px;
  height: 36px;
  box-shadow: 0 6px 16px rgba(15,36,56,0.28);
}
.avatar-lg {
  width: 64px;
  height: 64px;
  box-shadow: 0 14px 34px rgba(15,36,56,0.26);
}
.avatar-xs {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(183,109,127,0.16);
  color: #b76d7f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Reset button ── */
.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(23,50,77,0.16);
  background: rgba(255,255,255,0.6);
  color: #3a5670;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 130ms ease, border-color 130ms ease, color 130ms ease;
}
.reset-btn:hover {
  background: #fff;
  border-color: #b76d7f;
  color: #17324d;
}

/* ── Scroll area ── */
.scroll-area {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
}
.msg-col {
  max-width: 768px;
  margin: 0 auto;
  padding: 26px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Hero ── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 8px 4px;
}
.hero.hidden { display: none; }

.hero-h1 {
  font-size: 27px;
  font-weight: 900;
  margin: 20px 0 0;
  letter-spacing: 0.01em;
  color: #17324d;
}
.hero-lead {
  margin: 12px 0 0;
  max-width: 46ch;
  line-height: 1.85;
  color: #5e7183;
}
.hero-tagline {
  margin: 18px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #b76d7f;
}

/* ── Example chips ── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(23,50,77,0.13);
  background: rgba(255,255,255,0.78);
  color: #2c4a63;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.chip:hover {
  transform: translateY(-1px);
  border-color: #b76d7f;
  background: #fff;
}

/* ── Message list ── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.msg-turn {
  animation: om-rise 240ms ease;
}

/* User bubble */
.msg-user { display: flex; justify-content: flex-end; }
.msg-user-bubble {
  max-width: 80%;
  background: linear-gradient(165deg, #1d3c5a, #0f2438);
  color: #fff;
  padding: 12px 17px;
  border-radius: 18px 18px 6px 18px;
  line-height: 1.65;
  white-space: pre-wrap;
  box-shadow: 0 8px 20px rgba(15,36,56,0.16);
}

/* Assistant turn */
.msg-assistant {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}
.msg-assistant-content {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 3px;
}

/* Typing indicator */
.typing {
  display: inline-flex;
  gap: 6px;
  padding: 8px 2px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b76d7f;
  animation: om-blink 1.3s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* Summary */
.msg-summary {
  margin: 0;
  line-height: 1.9;
  color: #2c4a63;
}

/* Result groups */
.result-group { margin-top: 18px; }
.result-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 11px;
}
.result-group-icon { color: #b76d7f; display: inline-flex; }
.result-group-label { font-weight: 700; font-size: 14px; color: #17324d; }
.result-group-count {
  font-size: 12px;
  font-weight: 500;
  color: #7d8c99;
  background: rgba(23,50,77,0.06);
  padding: 1px 9px;
  border-radius: 999px;
}
.result-cards {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Result card */
.result-card {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  background: #fffdf9;
  border: 1px solid rgba(23,50,77,0.08);
  border-radius: 14px;
  padding: 13px 15px;
  transition: border-color 130ms ease, box-shadow 130ms ease, transform 130ms ease;
}
.result-card:hover {
  border-color: rgba(183,109,127,0.5);
  box-shadow: 0 8px 22px rgba(23,50,77,0.09);
  transform: translateY(-1px);
}
.result-card-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(23,50,77,0.05);
  color: #3a5670;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.result-card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.result-card-titlerow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.result-card-title { font-weight: 700; color: #0f2438; font-size: 15px; }
.result-card-tag {
  font-size: 11px;
  font-weight: 700;
  color: #b76d7f;
  background: rgba(183,109,127,0.12);
  padding: 2px 8px;
  border-radius: 999px;
}
.result-card-arrow { flex: 0 0 auto; color: #9aa7b2; margin-top: 6px; }

/* Error */
.msg-error { color: #6b7d8c; line-height: 1.9; margin: 0; }

/* ── Input dock ── */
.input-dock {
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(247,243,236,0) 0%, #f7f3ec 26%);
  padding: 6px 20px 16px;
}
.input-dock-inner {
  max-width: 768px;
  margin: 0 auto;
}
.input-pill {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #fff;
  border: 1px solid rgba(23,50,77,0.14);
  border-radius: 24px;
  padding: 8px 8px 8px 18px;
  box-shadow: 0 12px 34px rgba(23,50,77,0.1);
}
#question {
  flex: 1 1 auto;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: #17324d;
  max-height: 160px;
  padding: 9px 0;
}
#question::placeholder { color: #94a1ad; }
.send-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(165deg, #1d3c5a, #0f2438);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 130ms ease, transform 130ms ease;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.45; cursor: default; }

.footnote {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: #94a1ad;
}

@media (max-width: 640px) {
  .site-header { padding: 11px 16px; }
  .msg-col { padding: 20px 14px 24px; }
  .input-dock { padding: 6px 14px 14px; }
  .hero { padding: 24px 4px 4px; }
  .hero-h1 { font-size: 22px; }
}
