:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e4e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --bubble-out: #2563eb;
  --bubble-in: #eef0f3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--panel);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 320px;
  text-align: center;
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 15px;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}
.login-box button:hover { background: var(--blue-dark); }
.error { color: #dc2626; font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* App */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.topbar h1 { font-size: 17px; margin: 0; }
.who-am-i { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.who-am-i select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.main {
  display: flex;
  height: calc(100vh - 56px);
}

.conversations {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.conversations-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.conversations-header h2 { font-size: 15px; margin: 0; }
#new-convo-btn {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
#convo-list { overflow-y: auto; flex: 1; }
.convo-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.convo-item:hover { background: #f9fafb; }
.convo-item.active { background: #eef2ff; }
.convo-number { font-weight: 600; font-size: 14px; }
.convo-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.convo-item.unread .convo-number::after {
  content: "•";
  color: var(--blue);
  margin-left: 6px;
}

.chat-panel { flex: 1; display: flex; flex-direction: column; }
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.chat-active { flex: 1; display: flex; flex-direction: column; }
.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: var(--panel);
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
}
.bubble.out {
  align-self: flex-end;
  background: var(--bubble-out);
  color: white;
  border-bottom-right-radius: 4px;
}
.bubble.in {
  align-self: flex-start;
  background: var(--bubble-in);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.bubble .meta {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}
.bubble img, .bubble video {
  max-width: 220px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.composer input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
}
#attach-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
#send-btn {
  background: var(--blue);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
}
#send-btn:hover { background: var(--blue-dark); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: white;
  padding: 24px;
  border-radius: 12px;
  width: 320px;
}
.modal-box h3 { margin-top: 0; }
.modal-box label { font-size: 13px; color: var(--text-muted); }
.modal-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 6px 0 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-actions button {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}
#new-convo-cancel { background: var(--bg); }
#new-convo-start { background: var(--blue); color: white; }
