:root {
  --bg: #0b1020;
  --bg-soft: #121a31;
  --card: rgba(18, 26, 49, 0.82);
  --border: rgba(148, 163, 184, 0.16);
  --text: #e8edf7;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --accent: #22d3ee;
  --user-bg: rgba(99, 102, 241, 0.18);
  --bot-bg: rgba(15, 23, 42, 0.72);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

body {
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.22), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(34, 211, 238, 0.12), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(79, 70, 229, 0.15), transparent 40%),
    var(--bg);
}

.container {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: rgba(11, 16, 32, 0.72);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(34, 211, 238, 0.18));
  border: 1px solid var(--border);
  font-size: 1.4rem;
}

.brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.header-links {
  display: flex;
  gap: 18px;
  font-size: 0.92rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 22px;
  padding: 28px 0 40px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-panel .card {
  padding: 20px 22px;
}

.info-panel h2,
.chat-header h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

.info-panel p {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.muted {
  color: var(--muted);
  font-size: 0.86rem !important;
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.tag {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  font-size: 0.75rem;
  font-weight: 600;
}

.sample-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: 0.18s ease;
}

.chip:hover {
  border-color: rgba(99, 102, 241, 0.55);
  background: rgba(99, 102, 241, 0.12);
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-panel {
  min-height: 680px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.chat-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.embed-container {
  flex: 1;
  min-height: 600px;
  padding: 12px;
}

.embed-container iframe {
  width: 100%;
  height: 100%;
  min-height: 600px;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 480px;
  max-height: calc(680px - 140px);
}

.message {
  display: flex;
  gap: 12px;
  max-width: 92%;
  animation: fadeIn 0.25s ease;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.message.user .avatar {
  background: rgba(99, 102, 241, 0.25);
}

.message.bot .avatar {
  background: rgba(34, 211, 238, 0.12);
}

.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bg);
}

.message.bot .bubble {
  background: var(--bot-bg);
}

.bubble.loading::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  animation: blink 1s infinite;
  vertical-align: text-bottom;
}

.citations {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

.citations strong {
  color: #cbd5e1;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 140px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}

.composer textarea:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-send {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.18s ease;
}

.btn-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), #6366f1);
}

.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.setup-notice {
  margin: 0 20px 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  font-size: 0.88rem;
}

.setup-notice code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}

.welcome {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 420px;
  padding: 40px 16px;
}

.welcome strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.hidden {
  display: none !important;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 28px;
}

.footer-inner {
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.footer-inner p {
  margin: 0 0 6px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 72vh;
  }

  .messages {
    max-height: none;
    min-height: 52vh;
  }

  .header-links {
    display: none;
  }
}
