:root {
  --bg: #f8fafc;
  --bg-soft: rgba(255, 255, 255, 0.72);
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(148, 163, 184, 0.28);
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-strong: #4338ca;
  --chip-bg: rgba(255, 255, 255, 0.72);
  --user-bubble: linear-gradient(135deg, #2563eb, #4f46e5);
  --bot-bubble: rgba(255, 255, 255, 0.94);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

html,
body {
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--muted);
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.2), transparent 28%),
    radial-gradient(circle at bottom right, rgba(99, 102, 241, 0.18), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.bg-blob {
  position: fixed;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
}

.bg-blob-primary {
  top: -9rem;
  left: -8rem;
  background: rgba(59, 130, 246, 0.35);
}

.bg-blob-secondary {
  right: -8rem;
  bottom: -10rem;
  background: rgba(79, 70, 229, 0.3);
}

.app-shell,
.chat-window,
.chat-toggle-btn {
  position: relative;
  z-index: 1;
}

.hero-panel {
  max-width: 50rem;
}

.hero-badge,
.hero-tip,
.btn-glass {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

.hero-copy {
  max-width: 38rem;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.chat-window {
  position: fixed;
  right: 2rem;
  bottom: 6rem;
  width: min(25rem, calc(100vw - 2rem));
  height: min(40.5rem, calc(100vh - 8rem));
  overflow: hidden;
  border-radius: 1.5rem;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.chat-window:not(.d-none) {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-window.d-none {
  opacity: 0;
  transform: translateY(1rem) scale(0.96);
}

.chat-window.is-fullscreen {
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  border-radius: 0;
}

.chat-header {
  background: rgba(255, 255, 255, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.assistant-avatar {
  position: relative;
  width: 2.8rem;
  height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.35);
}

.assistant-avatar.is-thinking {
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  animation: pulse-ring 1.4s infinite;
}

.assistant-status-dot {
  position: absolute;
  right: 0.08rem;
  bottom: 0.05rem;
  width: 0.75rem;
  height: 0.75rem;
  background: #22c55e;
  border-radius: 999px;
  border: 2px solid #fff;
}

.btn-header-control {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.btn-header-control:hover {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
}

.btn-close-chat:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  min-height: 18rem;
}

.conversation-panel {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.45);
}

.conversation-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.conversation-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.conversation-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.conversation-item {
  min-width: 9rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.42rem 0.55rem;
  background: rgba(255, 255, 255, 0.7);
  text-align: left;
  display: flex;
  flex-direction: column;
  color: var(--text);
  cursor: pointer;
}

.conversation-item.active {
  border-color: rgba(37, 99, 235, 0.65);
  background: rgba(219, 234, 254, 0.45);
}

.conversation-item.muted,
.conversation-list-empty {
  min-width: 100%;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
  padding: 0.48rem 0.6rem;
  background: rgba(255, 255, 255, 0.5);
}

.conversation-item-title,
.conversation-title {
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item-meta,
.conversation-date {
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 0.16rem;
}

.message-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-avatar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #60a5fa, #4f46e5);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}

.message-content {
  max-width: 80%;
}

.message-label,
.message-time {
  display: block;
  padding: 0 0.35rem;
}

.message-label {
  margin-bottom: 0.28rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.message-time {
  margin-top: 0.28rem;
  color: rgba(100, 116, 139, 0.82);
  font-size: 0.62rem;
}

.message-bubble {
  padding: 0.85rem 1rem;
  border-radius: 1.1rem;
  line-height: 1.55;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.message-row.user .message-content {
  text-align: right;
}

.message-row.user .message-bubble {
  background: var(--user-bubble);
  color: #fff;
  border-top-right-radius: 0.35rem;
}

.message-row.assistant .message-bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border: 1px solid var(--border);
  border-top-left-radius: 0.35rem;
}

.message-row.assistant .message-bubble p {
  margin: 0 0 0.65rem;
}

.message-row.assistant .message-bubble p:last-child {
  margin-bottom: 0;
}

.message-row.assistant .message-bubble ul,
.message-row.assistant .message-bubble ol {
  margin: 0.4rem 0;
  padding-left: 1.15rem;
}

.message-row.assistant .message-bubble pre {
  margin: 0.5rem 0;
  border-radius: 0.7rem;
  padding: 0.65rem;
  overflow-x: auto;
  background: #0f172a;
  color: #e2e8f0;
}

.message-row.assistant .message-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 0.3rem;
  padding: 0.05rem 0.3rem;
  font-size: 0.84em;
}

.message-row.assistant .message-bubble pre code {
  background: transparent;
  padding: 0;
}

.streaming-answer::after {
  content: "▋";
  animation: pulse-badge 0.9s infinite;
  color: var(--primary);
  margin-left: 0.1rem;
}

.error-bubble {
  border-color: rgba(239, 68, 68, 0.45) !important;
  background: rgba(254, 226, 226, 0.72) !important;
}

.thinking-block {
  margin-bottom: 0.45rem;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 0.8rem;
  background: rgba(251, 191, 36, 0.08);
  overflow: hidden;
}

.thinking-header {
  border: 0;
  width: 100%;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.45rem 0.6rem;
}

.thinking-label.is-streaming {
  color: #d97706;
}

.thinking-chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.thinking-block.open .thinking-chevron {
  transform: rotate(180deg);
}

.thinking-body {
  display: none;
  border-top: 1px solid rgba(251, 191, 36, 0.35);
}

.thinking-block.open .thinking-body {
  display: block;
}

.thinking-prose {
  font-size: 0.73rem;
  line-height: 1.5;
  color: var(--muted);
  padding: 0.55rem 0.6rem;
  max-height: 8rem;
  overflow-y: auto;
  white-space: pre-wrap;
}

.thinking-prose:empty {
  display: none;
}

.step-row {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
}

.step-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  margin-top: 0.32rem;
  background: var(--border);
  flex-shrink: 0;
}

.step-tool-call .step-dot {
  background: #6366f1;
}

.step-tool-result .step-dot {
  background: #10b981;
}

.step-error .step-dot {
  background: #ef4444;
}

.step-content {
  min-width: 0;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  font-size: 0.7rem;
  font-weight: 600;
}

.step-detail {
  margin-top: 0.12rem;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 4rem;
  overflow-y: auto;
}

.step-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.64rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
}

.spinner {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top-color: #6366f1;
  animation: spin 0.6s linear infinite;
}

.tools-footer {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tool-chip,
.duration-chip {
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.66rem;
  font-weight: 600;
}

.tool-chip {
  color: #047857;
  border: 1px solid rgba(4, 120, 87, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.duration-chip {
  color: var(--muted);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
}

.widget-block {
  margin: 0.45rem 0;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
}

.widget-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.55rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.widget-unsupported {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.55rem;
}

.widget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.widget-table th,
.widget-table td {
  padding: 0.38rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.widget-table th {
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.widget-table tr:last-child td {
  border-bottom: 0;
}

.widget-cards {
  display: flex;
  flex-direction: column;
}

.widget-card {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.widget-card:last-child {
  border-bottom: 0;
}

.widget-card-title {
  font-size: 0.76rem;
  font-weight: 600;
}

.widget-card-title a {
  color: var(--primary);
  text-decoration: none;
}

.widget-card-subtitle {
  font-size: 0.7rem;
  color: var(--muted);
}

.widget-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.widget-tag,
.widget-badge {
  font-size: 0.64rem;
  border-radius: 999px;
  padding: 0.06rem 0.45rem;
}

.widget-tag {
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: var(--primary);
}

.widget-badge {
  border: 1px solid var(--border);
  color: var(--muted);
  align-self: flex-start;
}

.widget-stats {
  display: flex;
  border-top: 1px solid var(--border);
}

.widget-stat {
  flex: 1;
  text-align: center;
  padding: 0.6rem;
  border-right: 1px solid var(--border);
}

.widget-stat:last-child {
  border-right: 0;
}

.widget-stat-value {
  font-size: 1rem;
  font-weight: 700;
}

.widget-stat-label {
  font-size: 0.64rem;
  color: var(--muted);
}

.widget-stat-change {
  font-size: 0.65rem;
  margin-top: 0.2rem;
}

.widget-stat-change.up {
  color: #10b981;
}

.widget-stat-change.down {
  color: #ef4444;
}

.widget-stat-change.neutral {
  color: var(--muted);
}

.widget-timeline {
  padding: 0.5rem 0.6rem;
}

.widget-tl-item {
  display: flex;
  gap: 0.45rem;
  padding-bottom: 0.45rem;
}

.widget-tl-item:last-child {
  padding-bottom: 0;
}

.widget-tl-left {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.widget-tl-dot {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 999px;
  background: var(--primary);
}

.widget-tl-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin-top: 0.1rem;
}

.widget-tl-item:last-child .widget-tl-line {
  display: none;
}

.widget-tl-date {
  font-size: 0.64rem;
  color: var(--muted);
}

.widget-tl-title {
  font-size: 0.72rem;
  font-weight: 600;
}

.widget-tl-desc {
  font-size: 0.68rem;
  color: var(--muted);
}

.widget-map-container {
  width: 100%;
  height: 11rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.typing-bubble {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  min-width: 3.75rem;
  min-height: 2.7rem;
}

.typing-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--primary);
  animation: bounce-dot 0.9s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-footer {
  background: linear-gradient(to top, var(--surface-strong), transparent);
}

.suggestions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.suggestion-chip {
  background: var(--chip-bg);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.42rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
}

.suggestion-chip:hover {
  background: rgba(59, 130, 246, 0.1);
}

.chat-input-wrap {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  padding: 0.5rem;
  border-radius: 1.35rem;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#chatInput {
  resize: none;
  min-height: 2.8rem;
  max-height: 7.5rem;
  background: transparent;
  color: var(--text);
}

#chatInput::placeholder {
  color: var(--muted);
}

#chatInput:focus {
  background: transparent;
}

.chat-toggle-btn {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  width: 3.7rem;
  height: 3.7rem;
  border: 0;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
}

.chat-toggle-btn.is-open {
  background: #1e293b;
}

.chat-toggle-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.chat-unread-badge {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: #ef4444;
  border: 2px solid #4f46e5;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: pulse-badge 1.5s infinite;
}

.chat-unread-badge.d-none {
  display: none !important;
}

::-webkit-scrollbar {
  width: 0.4rem;
}

::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.5);
}

@keyframes bounce-dot {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  40% {
    transform: translateY(-0.22rem);
    opacity: 1;
  }
}

@keyframes pulse-badge {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  }

  70% {
    box-shadow: 0 0 0 0.5rem rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
  }

  70% {
    box-shadow: 0 0 0 0.8rem rgba(59, 130, 246, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

@media (max-width: 767.98px) {
  .chat-toggle-btn {
    right: 1rem;
    bottom: 1rem;
  }

  .chat-window {
    right: 1rem;
    bottom: 5.6rem;
    width: calc(100vw - 2rem);
    height: min(39rem, calc(100vh - 7rem));
  }

  .chat-window.is-fullscreen {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
  }

  .hero-panel {
    padding-top: 5rem;
    padding-bottom: 5rem;
  }

  .message-content {
    max-width: 88%;
  }

  .chat-input-wrap {
    gap: 0.5rem;
  }
}