:root {
  --bg-dark: #09090b;
  --bg-card: rgba(24, 24, 27, 0.6);
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.4);
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --border: rgba(39, 39, 42, 0.8);
  --user-bubble: #27272a;
  --ai-bubble: rgba(39, 39, 42, 0.3);
  --font-sans: 'Outfit', 'Inter', system-ui, sans-serif;
  --glass: blur(12px) saturate(180%);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Layout */
#app {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: rgba(10, 10, 12, 0.8);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  z-index: 10;
  backdrop-filter: var(--glass);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 40px;
  background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--accent-glow);
}

.nav-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

/* Main Chat Container */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at 50% -20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

.header {
  height: 72px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: var(--glass);
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #52525b;
}

.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Messages Area */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 40px 15% 100px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  scroll-behavior: smooth;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 85%;
  animation: slideUp 0.4s ease-out;
}

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

.user-wrapper { align-self: flex-end; }
.ai-wrapper { align-self: flex-start; }

.message-bubble {
  padding: 16px 24px;
  border-radius: 20px;
  line-height: 1.6;
  font-size: 16px;
  position: relative;
}

.user-bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
  color: white;
}

.ai-bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Thinking Box */
.think-container {
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  border-radius: 4px 12px 12px 4px;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}

.think-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
  margin-bottom: 6px;
  color: var(--accent);
}

/* Input Section */
.input-section {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 15%;
  background: linear-gradient(to top, var(--bg-dark) 60%, transparent);
}

.input-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  backdrop-filter: var(--glass);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s;
}

.input-container:focus-within {
  border-color: var(--accent);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-family: inherit;
  font-size: 16px;
  padding: 8px 4px;
  resize: none;
  max-height: 200px;
}

.send-button {
  background: var(--accent);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.send-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 15px var(--accent-glow);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

/* TPS & Toggle */
.tps-chip {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(139, 92, 246, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 32px;
  height: 18px;
  background: #27272a;
  border-radius: 20px;
  transition: 0.3s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: 0.3s;
}

input:checked + .toggle-switch { background: var(--accent); }
input:checked + .toggle-switch::after { left: 16px; }
input[type="checkbox"] { display: none; }

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.loader-bar {
  width: 280px;
  height: 4px;
  background: #18181b;
  border-radius: 4px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
  transition: width 0.3s ease;
}
