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

:root {
  --bg: #0d0d0f;
  --bg-2: #17171a;
  --bg-3: #1f1f24;
  --border: #2a2a30;
  --text: #ececec;
  --text-dim: #9a9aa3;
  --accent: #7c5cff;
  --accent-2: #5d3fff;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 260px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 14px;
}

.logo-icon {
  color: var(--accent);
  font-size: 22px;
  text-shadow: 0 0 12px var(--accent);
}

.logo-text { letter-spacing: 0.5px; }

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

.btn-new:hover { background: var(--border); }

.chat-list { flex: 1; overflow-y: auto; padding: 8px; }

.chat-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.chat-item:hover { background: var(--bg-3); color: var(--text); }
.chat-item.active { background: var(--bg-3); color: var(--text); }
.chat-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.chat-item .del {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  transition: opacity 0.15s, color 0.15s;
}

.chat-item:hover .del { opacity: 1; }
.chat-item .del:hover { color: #ff5c5c; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.btn-clear {
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-clear:hover { border-color: #ff5c5c; color: #ff5c5c; }

/* ============ MAIN ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
}

.chat-header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-menu { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }

/* ============ MESSAGES ============ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.welcome { max-width: 620px; margin: auto; text-align: center; padding: 40px 20px; }

.welcome-icon {
  font-size: 48px;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent);
  margin-bottom: 16px;
}

.welcome h2 { font-size: 26px; margin-bottom: 8px; font-weight: 700; }
.welcome p { color: var(--text-dim); margin-bottom: 28px; }

.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.suggestion {
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion:hover { background: var(--bg-3); border-color: var(--accent); }

.msg {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  gap: 14px;
  animation: fadeIn 0.25s ease;
}

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

.msg .avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.msg.user .avatar { background: var(--accent); color: white; }
.msg.ai .avatar { background: var(--bg-3); color: var(--accent); }

.msg .content {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg .content p { margin-bottom: 10px; }
.msg .content p:last-child { margin-bottom: 0; }
.msg .content pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
}
.msg .content code {
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.msg .content pre code { background: none; padding: 0; }
.msg .content ul, .msg .content ol { margin: 8px 0 8px 22px; }
.msg .content li { margin-bottom: 4px; }
.msg .content h1, .msg .content h2, .msg .content h3 { margin: 14px 0 8px; line-height: 1.3; }
.msg .content strong { color: #fff; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  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: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ============ COMPOSER ============ */
.composer { padding: 12px 16px 16px; background: var(--bg); }

.composer-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.15s;
}

.composer-inner:focus-within { border-color: var(--accent); }

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

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

.send-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover:not(:disabled) { background: var(--accent-2); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.composer-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 8px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a42; }

@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .btn-menu { display: block; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome h2 { font-size: 22px; }
}
