:root {
  --bg-primary: #0b0d10;
  --bg-secondary: #13161c;
  --bg-tertiary: #1b1f27;
  --bg-card: rgba(27, 31, 39, 0.7);
  --bg-input: #1a1e26;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: #6366f1;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-success: #10b981;
  
  --sidebar-width: 280px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.6;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 20;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 22px;
  background: var(--bg-tertiary);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.logo-text h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.badge-version {
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-new-chat:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

/* History container */
.sidebar-history-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.history-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 8px 6px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
}

.history-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

/* Sidebar Footer & Status */
.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(11, 13, 16, 0.5);
}

.channels-status-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.status-dot.online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.channel-dot.ok {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-success);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-profile .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

.user-tag {
  font-size: 11px;
  color: var(--text-dim);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background-color: var(--bg-primary);
}

/* Top Nav */
.top-nav {
  height: 54px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(11, 13, 16, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.btn-toggle-sidebar {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-toggle-sidebar:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.separator {
  color: var(--text-dim);
}

.engine-tag {
  color: var(--accent-indigo);
  font-weight: 600;
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-clear:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

/* Chat Viewport */
.chat-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Hero Screen */
.hero-screen {
  max-width: 760px;
  width: 100%;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.hero-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.4));
}

.hero-heading {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.hero-subtext {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 580px;
  margin-bottom: 36px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.suggestion-card:hover {
  background: var(--bg-tertiary);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card-icon {
  font-size: 22px;
}

.card-text strong {
  display: block;
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 3px;
}

.card-text span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Messages Container */
.messages-container {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-bottom: 24px;
}

.message-row {
  display: flex;
  gap: 16px;
  width: 100%;
  animation: slideUp 0.25s ease-out;
}

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

.user-bubble {
  background: #1e2430;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 20px 20px 4px 20px;
  max-width: 80%;
  font-size: 15px;
  word-break: break-word;
}

.bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.bot-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* Search Status Indicator */
.search-badge-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  color: #a5b4fc;
  width: fit-content;
}

.search-badge-step .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Source Pills Container */
.sources-carousel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.source-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
}

.source-pill:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text-main);
  transform: translateY(-1px);
}

.source-pill-num {
  font-size: 10px;
  font-weight: 700;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  padding: 1px 4px;
}

/* Markdown Content Area */
.markdown-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-main);
}

.markdown-body h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: #f1f5f9;
}

.markdown-body h2 {
  font-size: 15.5px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: #e2e8f0;
}

.markdown-body h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: #e2e8f0;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-size: 13.5px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: #cbd5e1;
}

.markdown-body h1 a,
.markdown-body h2 a,
.markdown-body h3 a {
  color: #818cf8;
  text-decoration: none;
}

.markdown-body h1 a:hover,
.markdown-body h2 a:hover,
.markdown-body h3 a:hover {
  text-decoration: underline;
}

.markdown-body p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.markdown-body blockquote {
  border-left: 3px solid #6366f1;
  background: rgba(99, 102, 241, 0.05);
  padding: 8px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 8px 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

.markdown-body blockquote * {
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
  margin: 4px 0 !important;
  color: #cbd5e1 !important;
}

.markdown-body blockquote strong,
.markdown-body blockquote b {
  font-weight: 600 !important;
  color: #f1f5f9 !important;
}

.markdown-body blockquote a {
  color: #818cf8 !important;
  text-decoration: underline;
}

.markdown-body code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.markdown-body li {
  margin-bottom: 6px;
}

.markdown-body img {
  max-width: 100%;
  max-height: 420px;
  border-radius: var(--radius-md);
  margin: 12px 0 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  display: block;
  object-fit: cover;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 18px;
  font-size: 14px;
}

.markdown-body th, .markdown-body td {
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.markdown-body th {
  background: rgba(99, 102, 241, 0.1);
  color: #c7d2fe;
  font-weight: 600;
}

.markdown-body tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Bottom Input Area */
.input-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 18px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-primary) 30%);
}

.input-wrapper {
  width: 100%;
  max-width: 820px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 10px 35px var(--accent-glow);
}

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
}

.tool-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  font-weight: 500;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.tool-pill .pill-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-success);
  border-radius: 50%;
}

.tool-hint {
  color: var(--text-dim);
  font-size: 11px;
}

.input-box-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 15px;
  resize: none;
  max-height: 180px;
  line-height: 1.5;
  padding: 4px 0;
  font-family: inherit;
}

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

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  transform: scale(1.06);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.5);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-footnote {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    height: 100%;
  }
  .suggestion-grid {
    grid-template-columns: 1fr;
  }
}
