:root {
  --bg-main: #131314;
  --bg-sidebar: #1e1f20;
  --bg-surface: #282a2c;
  --border: #333537;
  --text-primary: #e3e3e3;
  --text-muted: #9aa0a6;
  --accent: #8ab4f8;
}

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

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

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

/* Sidebar */
.sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

.sidebar.collapsed { display: none; }

.sidebar-header h2 { font-size: 1.1rem; margin-bottom: 12px; }

.btn-primary {
  width: 100%;
  padding: 10px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary:hover { background: #333639; }

label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select, input[type="email"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
}

.user-row { display: flex; gap: 6px; }
.user-row input { margin-bottom: 0; }
.user-row button {
  padding: 0 12px;
  background: var(--accent);
  color: #131314;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.chats-section { flex: 1; overflow-y: auto; }
#chat-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
#chat-list li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#chat-list li:hover, #chat-list li.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Main Chat */
.chat-main { flex: 1; display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 12%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg { max-width: 82%; line-height: 1.6; font-size: 0.96rem; }
.msg.user {
  align-self: flex-end;
  background: var(--bg-surface);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
}
.msg.assistant {
  align-self: flex-start;
  padding: 4px 0;
}

.msg img {
  max-width: 280px;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
}

.msg pre {
  background: #1e1f20;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

/* Composer */
.composer-wrap { padding: 12px 12% 20px; }

.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
}

.attach-btn { cursor: pointer; font-size: 1.2rem; margin: 0; padding-bottom: 4px; }

textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.96rem;
  resize: none;
  outline: none;
  max-height: 160px;
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #131314;
  font-weight: bold;
  cursor: pointer;
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }