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

:root {
  --primary: #4361ee;
  --primary-dark: #3651d4;
  --secondary: #1a1a2e;
  --background: #0f0f1a;
  --surface: #1a1a2e;
  --surface-light: #252540;
  --text: #ffffff;
  --text-secondary: #8888aa;
  --success: #22c55e;
  --message-sent: #4361ee;
  --message-received: #252540;
  --border: #2a2a45;
}

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

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Login Screen */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--background) 100%);
}

.logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo svg {
  margin-bottom: 16px;
}

.logo h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.logo p {
  color: var(--text-secondary);
  font-size: 14px;
}

.input-group {
  width: 100%;
  max-width: 320px;
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.image-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: var(--surface-light);
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.image-upload:hover {
  border-color: var(--primary);
}

.avatar-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
}

.avatar-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload span {
  color: var(--text-secondary);
  font-size: 14px;
}

.btn-primary {
  width: 100%;
  max-width: 320px;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  width: 100%;
  max-width: 320px;
  padding: 14px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
}

.login-divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
  margin: 20px 0;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-divider span {
  padding: 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--secondary);
  border-bottom: 1px solid var(--border);
}

.app-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

/* My Code Display */
.my-code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface-light);
  margin: 16px;
  border-radius: 12px;
}

.my-code span {
  color: var(--text-secondary);
  font-size: 14px;
}

.my-code strong {
  font-size: 20px;
  font-family: monospace;
  letter-spacing: 2px;
}

.copy-btn {
  background: var(--primary);
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state span {
  color: var(--text-secondary);
  font-size: 14px;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-item:hover {
  background: var(--surface-light);
}

.chat-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-avatar svg {
  width: 24px;
  height: 24px;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.chat-preview {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-size: 12px;
  color: var(--text-secondary);
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(67, 97, 238, 0.5);
}

/* Chat Screen */
.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--secondary);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-user-info .chat-avatar {
  width: 40px;
  height: 40px;
  margin: 0;
}

.chat-user-info h3 {
  font-size: 16px;
  font-weight: 600;
}

.user-code-small {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: monospace;
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  position: relative;
}

.message.sent {
  align-self: flex-end;
  background: var(--message-sent);
  border-bottom-right-radius: 4px;
}

.message.received {
  align-self: flex-start;
  background: var(--message-received);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
  text-align: right;
}

.message-input-container {
  display: flex;
  padding: 12px 16px;
  background: var(--secondary);
  gap: 12px;
  align-items: center;
}

.message-input-container input {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface-light);
  border: none;
  border-radius: 24px;
  color: var(--text);
  font-size: 15px;
}

.message-input-container input:focus {
  outline: none;
}

.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.send-btn:hover {
  background: var(--primary-dark);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 360px;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

/* Search Result */
.search-result {
  margin: 16px 0;
  padding: 16px;
  background: var(--surface-light);
  border-radius: 12px;
}

.user-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-preview-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.user-preview-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-preview-info {
  display: flex;
  flex-direction: column;
}

.user-preview-info strong {
  font-size: 16px;
}

.user-preview-info span {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: monospace;
}

/* Profile */
.profile-info {
  text-align: center;
  padding: 20px 0;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-info h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.profile-code {
  font-family: monospace;
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#profile-age {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-item {
  animation: fadeIn 0.3s ease;
}

.message {
  animation: fadeIn 0.2s ease;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-light);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}
