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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container { max-width: 600px; margin: 0 auto; }

header { text-align: center; padding: 30px 0; color: white; }
header h1 { font-size: 2em; margin-bottom: 8px; text-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.subtitle { opacity: 0.9; font-size: 1em; }

.form-card {
  background: white; border-radius: 16px; padding: 24px;
  margin-bottom: 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.form-top { display: flex; gap: 16px; margin-bottom: 12px; }

/* 头像上传 */
.avatar-upload { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  border: 3px solid #e8e8e8; display: flex; align-items: center; justify-content: center;
  background: #f5f5f5; cursor: pointer; transition: border-color 0.3s;
}
.avatar-preview:hover { border-color: #667eea; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder { font-size: 28px; }
.avatar-label {
  font-size: 12px; color: #667eea; cursor: pointer; text-align: center;
}
.avatar-label:hover { text-decoration: underline; }

.form-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.form-fields input, .form-fields textarea {
  width: 100%; padding: 12px 16px; border: 2px solid #e8e8e8;
  border-radius: 10px; font-size: 15px; transition: border-color 0.3s;
  outline: none; font-family: inherit; resize: vertical;
}
.form-fields input:focus, .form-fields textarea:focus { border-color: #667eea; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tool-btn {
  padding: 8px 14px; border: 2px solid #e8e8e8; border-radius: 20px;
  background: white; cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.tool-btn:hover { border-color: #667eea; background: #f0f2ff; }
.char-count { color: #999; font-size: 13px; margin-left: auto; }
.submit-btn {
  padding: 10px 24px; background: linear-gradient(135deg, #667eea, #764ba2);
  color: white; border: none; border-radius: 20px; cursor: pointer;
  font-size: 15px; font-weight: 600; transition: transform 0.2s, box-shadow 0.2s;
}
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(102,126,234,0.4); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.emoji-picker { margin-top: 12px; border: 2px solid #e8e8e8; border-radius: 12px; overflow: hidden; }
.emoji-tabs { display: flex; border-bottom: 1px solid #e8e8e8; background: #fafafa; }
.emoji-tab { flex: 1; padding: 8px; border: none; background: none; cursor: pointer; font-size: 18px; transition: background 0.2s; }
.emoji-tab.active { background: white; border-bottom: 2px solid #667eea; }
.emoji-tab:hover:not(.active) { background: #f0f0f0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; padding: 12px; max-height: 200px; overflow-y: auto; }
.emoji-item { display: flex; align-items: center; justify-content: center; padding: 6px; cursor: pointer; border-radius: 8px; font-size: 20px; transition: background 0.2s; }
.emoji-item:hover { background: #f0f2ff; transform: scale(1.2); }

.image-preview { margin-top: 12px; position: relative; display: inline-block; }
.image-preview img { max-width: 200px; max-height: 150px; border-radius: 10px; border: 2px solid #e8e8e8; }
.remove-img {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px;
  background: #ff4757; color: white; border: 2px solid white; border-radius: 50%;
  cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
}

.messages { display: flex; flex-direction: column; gap: 16px; }
.msg-card {
  background: white; border-radius: 16px; padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1); transition: transform 0.2s;
}
.msg-card:hover { transform: translateY(-2px); }
.msg-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.msg-avatar {
  width: 42px; height: 42px; background: linear-gradient(135deg, #667eea, #764ba2);
  color: white; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0;
  overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.msg-nickname { font-weight: 600; font-size: 15px; color: #333; }
.msg-time { font-size: 12px; color: #999; }
.msg-content { font-size: 15px; line-height: 1.6; color: #444; word-break: break-word; }
.msg-emoji { margin-top: 8px; font-size: 28px; }
.msg-image { margin-top: 10px; }
.msg-image img { max-width: 100%; max-height: 300px; border-radius: 10px; cursor: pointer; transition: transform 0.2s; }
.msg-image img:hover { transform: scale(1.02); }
.msg-id { margin-top: 10px; font-size: 11px; color: #bbb; text-align: right; }

.empty, .loading { text-align: center; padding: 40px; color: white; font-size: 16px; opacity: 0.8; }
.hidden { display: none !important; }

@media (max-width: 480px) {
  body { padding: 12px; }
  header h1 { font-size: 1.5em; }
  .form-card { padding: 16px; }
  .form-top { flex-direction: column; align-items: center; }
  .form-fields { width: 100%; }
  .toolbar { gap: 6px; }
  .tool-btn { padding: 6px 10px; font-size: 12px; }
  .submit-btn { padding: 8px 18px; font-size: 14px; }
}
