:root {
  --bg-deep: #070b14;
  --bg-panel: #0c1220;
  --bg-card: #111827;
  --bg-hover: #1a2332;
  --border: #1e293b;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --moon: #60a5fa;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  height: 100vh;
}

/* ========== LEFT SIDEBAR ========== */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 24px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

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

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
  color: #93c5fd;
  border-left: 3px solid var(--accent);
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.promo-card {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  position: relative;
  overflow: hidden;
}

.promo-moon {
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 48px;
  opacity: 0.3;
}

.promo-card h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

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

.user-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
}

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

/* ========== MAIN ========== */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 18, 32, 0.8);
  backdrop-filter: blur(12px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  width: 420px;
  max-width: 50%;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-icon {
  font-size: 14px;
  opacity: 0.7;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.upgrade-btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 0 16px var(--accent-glow);
}

.upgrade-btn:hover {
  filter: brightness(1.1);
}

/* Views */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* Welcome Screen */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 20px;
  text-align: center;
  overflow-y: auto;
}

.moon-glow {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.4), transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

.moon-icon {
  font-size: 52px;
  filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.6));
}

.welcome h1 {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #e0f2fe, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 18px;
  color: var(--moon);
  font-weight: 500;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 480px;
  margin-bottom: 36px;
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 780px;
  width: 100%;
  margin-bottom: 36px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer;
  transition: all 0.25s;
  text-align: left;
}

.feature-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.15);
}

.fc-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

.feature-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.feature-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.suggestions {
  width: 100%;
  max-width: 700px;
}

.try-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg-hover);
}

/* Chat */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

.chat-container.hidden {
  display: none;
}

.messages {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

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

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.message.assistant .msg-avatar {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
}

.msg-bubble {
  max-width: 78%;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
}

.message.user .msg-bubble {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.message.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.assistant .msg-bubble p {
  margin: 0 0 10px 0;
}

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

.message.assistant .msg-bubble h2,
.message.assistant .msg-bubble h3,
.message.assistant .msg-bubble h4 {
  margin: 14px 0 8px;
  font-weight: 600;
  color: #93c5fd;
}

.message.assistant .msg-bubble h2 { font-size: 18px; }
.message.assistant .msg-bubble h3 { font-size: 16px; }
.message.assistant .msg-bubble h4 { font-size: 15px; }

.message.assistant .msg-bubble ul,
.message.assistant .msg-bubble ol {
  margin: 8px 0 12px 18px;
  padding: 0;
}

.message.assistant .msg-bubble li {
  margin-bottom: 5px;
}

.message.assistant .msg-bubble pre {
  background: #0a0f1a;
  border: 1px solid #1e293b;
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.5;
}

.message.assistant .msg-bubble code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
}

.message.assistant .msg-bubble p code,
.message.assistant .msg-bubble li code {
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  color: #93c5fd;
}

.message.assistant .msg-bubble .msg-link {
  color: #60a5fa;
  text-decoration: none;
  border-bottom: 1px solid rgba(96, 165, 250, 0.4);
  transition: color 0.15s, border-color 0.15s;
}

.message.assistant .msg-bubble .msg-link:hover {
  color: #93c5fd;
  border-bottom-color: #93c5fd;
}

.message.assistant .msg-bubble .msg-image {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.message.assistant .msg-bubble strong {
  color: #e0f2fe;
  font-weight: 600;
}

.message.assistant .msg-bubble em {
  color: #cbd5e1;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Input Area */
.input-area {
  padding: 16px 28px 20px;
  border-top: 1px solid var(--border);
  background: rgba(12, 18, 32, 0.6);
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  max-width: 800px;
  margin: 0 auto;
  transition: border-color 0.2s;
}

.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 140px;
  line-height: 1.5;
}

.input-box textarea::placeholder {
  color: var(--text-dim);
}


/* Image attach */
.attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.attach-btn:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
}
.image-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.image-preview.hidden { display: none; }
.image-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.image-preview .remove-img {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}
.image-preview .remove-img:hover { color: #f87171; }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, filter 0.15s;
  flex-shrink: 0;
}

.send-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.powered {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 10px;
}

/* Panel views */
.panel {
  padding: 32px 36px;
  overflow-y: auto;
  height: 100%;
}

.panel h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.panel-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.explore-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.explore-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.ei-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 12px;
}

.explore-item h3 {
  font-size: 15px;
  margin-bottom: 4px;
}

.explore-item p {
  font-size: 12px;
  color: var(--text-muted);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.tool-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-item:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.tool-item span {
  font-size: 20px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 400px;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.settings-form select,
.settings-form input[type="range"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.empty-state {
  color: var(--text-dim);
  font-size: 14px;
  padding: 40px 0;
}

/* ========== RIGHT SIDEBAR ========== */
.right-sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.rs-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.rs-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.rs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.view-all {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}

.view-all:hover {
  text-decoration: underline;
}

.rs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rs-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

.rs-item:hover {
  background: var(--bg-hover);
}

.rs-item span {
  font-size: 16px;
  margin-right: 6px;
}

.rs-item small {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 22px;
}

.tools-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-tool {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.mini-tool:hover {
  border-color: var(--accent);
  color: var(--text);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.recent-item:hover {
  background: var(--bg-hover);
}

.ri-title {
  font-size: 13px;
  color: var(--text);
}

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

/* Responsive */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 220px 1fr;
  }
  .right-sidebar {
    display: none;
  }
  .feature-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .feature-cards {
    grid-template-columns: 1fr 1fr;
  }
}
