:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-alt: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa2b1;
  --accent: #1c9ad6;
  --bubble-me: #1c9ad6;
  --bubble-other: #262b35;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, Roboto, sans-serif;
}

#app, .screen { height: 100%; }
.hidden { display: none !important; }

#connect-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

#connect-screen p { color: var(--text-dim); margin: 0 0 12px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
}

button:active { opacity: 0.8; }

#main-screen {
  display: flex;
  height: 100%;
}

#sidebar {
  width: 100%;
  max-width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

#sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

#sidebar-header button {
  background: transparent;
  color: var(--text-dim);
  padding: 4px 8px;
}

#conversation-list { overflow-y: auto; flex: 1; }

.conv-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.conv-item:hover, .conv-item.active { background: var(--panel-alt); }
.conv-item .conv-name { font-weight: 600; }
.conv-item .conv-preview { color: var(--text-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#chat-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

#message-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--bubble-other);
  align-self: flex-start;
}

.msg.me { background: var(--bubble-me); align-self: flex-end; }
.msg .sender { font-size: 12px; color: var(--text-dim); margin-bottom: 2px; }
.msg img { max-width: 100%; border-radius: 8px; margin-top: 4px; display: block; }
.msg .like-btn { cursor: pointer; font-size: 12px; margin-top: 4px; opacity: 0.8; }

#composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

#composer input[type="text"] {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 15px;
}

#attach-btn {
  background: var(--panel-alt);
  padding: 8px 12px;
}

@media (max-width: 720px) {
  #main-screen.show-chat #sidebar { display: none; }
  #main-screen:not(.show-chat) #chat-pane { display: none; }
  #sidebar { max-width: none; }
}
