:root {
  --bg: #0a0b12;
  --bg-side: #0d0e18;
  --bg-card: #141522;
  --bg-input: #12131c;
  --border: #1c1e2e;
  --text: #eef0f8;
  --muted: #8b8fa8;
  --accent: #8b5cf6;
  --accent-2: #7c3aed;
  --bubble-user: #6d28d9;
  --bubble-ai: #141522;
  --glow: rgba(139, 92, 246, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
.app {
  display: grid;
  grid-template-columns: 230px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
}
.spark {
  font-size: 22px;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 10px var(--glow));
  line-height: 1;
}
.spark.lg { font-size: 42px; }
.spark.sm { font-size: 16px; }
.spark.tiny { font-size: 14px; margin-right: 4px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  margin-bottom: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.new-chat-btn:hover { filter: brightness(1.08); }

.history-wrap {
  max-height: 160px;
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  min-height: 0;
}
.history-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0 6px 6px;
}
.icon-tiny {
  background: none; border: none; cursor: pointer; opacity: 0.7; font-size: 13px;
}
.icon-tiny:hover { opacity: 1; }
.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.history-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  text-align: left; padding: 8px 10px; border: none; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 13px; cursor: pointer;
}
.history-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.history-item.active { background: rgba(139,92,246,0.18); color: #c4b5fd; }
.history-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .x { opacity: 0; border: none; background: none; color: var(--muted); cursor: pointer; }
.history-item:hover .x { opacity: 1; }
.history-item .x:hover { color: #f87171; }
.history-empty { font-size: 12px; color: var(--muted); padding: 10px; text-align: center; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border: none; border-radius: 12px;
  background: transparent; color: var(--muted); font-size: 14px;
  font-weight: 500; cursor: pointer; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 8px 4px;
}
.foot-text { font-size: 12px; color: var(--muted); line-height: 1.4; }

.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background: radial-gradient(ellipse at 50% 30%, rgba(88, 28, 135, 0.12), transparent 55%), var(--bg);
}
.theme-float {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  z-index: 5;
}

.view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.welcome-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.welcome h1 {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -1.2px;
}
.tagline {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 36px;
}

.welcome-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(560px, 92%);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.welcome-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.welcome-input-wrap input::placeholder { color: var(--muted); }

.send-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-circle:hover { filter: brightness(1.1); }
.send-circle:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 12px;
}
.chat-area.hidden { display: none; }

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

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.message.user { flex-direction: row-reverse; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.avatar.ai {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
}
.avatar.user { background: #334155; }

.bubble-wrap {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.message.user .bubble-wrap { align-items: flex-end; }

.bubble {
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.6;
  word-break: break-word;
}
.message.user .bubble {
  background: var(--bubble-user);
  border-bottom-right-radius: 6px;
}
.message.assistant .bubble {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.time { font-size: 11px; color: var(--muted); padding: 0 4px; }

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 8px 0 8px 18px; }
.bubble li { margin-bottom: 4px; }
.bubble strong { color: #fff; }
.bubble a { color: #a78bfa; }
.bubble pre {
  background: #08090f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
}
.bubble code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.bubble p code {
  background: rgba(139,92,246,0.2);
  padding: 2px 5px;
  border-radius: 4px;
  color: #c4b5fd;
}
.bubble img.msg-image {
  max-width: 220px;
  border-radius: 10px;
  margin-top: 8px;
  display: block;
}

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: none; }
  30% { transform: translateY(-5px); }
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 800px;
  width: calc(100% - 48px);
  margin: 0 auto 20px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
}
.composer.hidden { display: none; }
.composer input[type="text"] {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
}
.composer input::placeholder { color: var(--muted); }
.attach {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 16px;
}
.attach:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.img-preview { display: flex; align-items: center; gap: 6px; }
.img-preview.hidden { display: none; }
.img-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.img-preview button { border: none; background: none; color: var(--muted); cursor: pointer; }

.panel { padding: 32px; overflow-y: auto; }
.panel h2 { font-size: 22px; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.prompt-card, .tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.prompt-card:hover, .tool-card:hover { border-color: var(--accent); }
.btn-danger {
  background: rgba(248,113,113,0.15);
  border: 1px solid rgba(248,113,113,0.35);
  color: #fca5a5;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}
.btn-danger:hover { background: rgba(248,113,113,0.25); }

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