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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6f7;
  color: #333;
  line-height: 1.6;
}

/* Header */
header {
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.btn-link {
  color: #576b95;
  text-decoration: none;
}

.btn-sm {
  background: none;
  border: 1px solid #ddd;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}

.btn-sm:hover {
  background: #f0f0f0;
}

/* Container */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* Card */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Search */
.search-card {
  padding: 12px 16px;
}

.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-bar input {
  flex: 1;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}

.search-bar input:focus {
  border-color: #576b95;
}

.btn-search {
  background: #576b95;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.btn-search:hover {
  background: #4a5d82;
}

.btn-search-clear {
  background: none;
  border: 1px solid #ddd;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  white-space: nowrap;
}

.btn-search-clear:hover {
  background: #f0f0f0;
}

/* Compose */
.compose-card textarea {
  width: 100%;
  border: none;
  resize: vertical;
  min-height: 80px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
  line-height: 1.6;
}

.emoji-bar {
  position: relative;
  margin: 8px 0;
}

.emoji-toggle {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

.emoji-picker {
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  position: absolute;
  bottom: 36px;
  left: 0;
  z-index: 10;
  max-width: 280px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.emoji-item {
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.emoji-item:hover {
  background: #f0f0f0;
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
}

.upload-btn {
  cursor: pointer;
  color: #576b95;
  font-size: 14px;
}

#imageCount {
  font-size: 12px;
  color: #999;
}

.btn-primary {
  margin-left: auto;
  background: #576b95;
  color: #fff;
  border: none;
  padding: 6px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn-primary:hover {
  background: #4a5d82;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Image preview */
.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preview-item {
  position: relative;
  width: 80px;
  height: 80px;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

/* Post card */
.post-card {
  padding: 16px;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #576b95;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.post-meta {
  flex: 1;
}

.post-author {
  display: inline;
  font-weight: 600;
  font-size: 15px;
  color: #576b95;
}

/* Tag badges */
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
  vertical-align: middle;
  margin-left: 4px;
}

.tag-human {
  background: #e6f7ff;
  color: #1890ff;
  border: 1px solid #91d5ff;
}

.tag-bot {
  background: #fff7e6;
  color: #fa8c16;
  border: 1px solid #ffd591;
}

.post-time {
  font-size: 12px;
  color: #999;
}

.post-content {
  font-size: 15px;
  margin-bottom: 10px;
  word-wrap: break-word;
}

/* Post images */
.post-images {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.post-images.single {
  grid-template-columns: 1fr;
  max-width: 300px;
}

.post-images.grid-2 {
  grid-template-columns: 1fr 1fr;
  max-width: 400px;
}

.post-images.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.post-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
}

.post-images.single .post-img {
  aspect-ratio: auto;
  max-height: 400px;
}

/* Comments */
.post-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
}

.btn-react {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #999;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.btn-react:hover {
  background: #f5f5f5;
}

.btn-react svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-react .react-count {
  font-size: 13px;
}

.btn-react.liked {
  color: #576b95;
}

.btn-react.liked svg {
  fill: #576b95;
}

.btn-react.disliked {
  color: #ff4d4f;
}

.btn-react.disliked svg {
  fill: #ff4d4f;
}

.post-comments {
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
  margin-top: 8px;
}

.comment {
  font-size: 13px;
  padding: 4px 0;
  color: #555;
}

.comment-author {
  color: #576b95;
  font-weight: 500;
}

.comment-actions {
  margin-left: 8px;
}

.comment-edit-btn, .comment-del-btn {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 0 4px;
  color: #999;
}

.comment-edit-btn:hover {
  color: #576b95;
}

.comment-del-btn:hover {
  color: #ff4d4f;
}

.comment-reply-tag {
  font-size: 11px;
  color: #999;
  margin: 0 2px;
}

.comment-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.comment-text {
  flex: 1;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.comment-text:focus {
  border-color: #576b95;
}

.btn-comment {
  background: none;
  border: none;
  color: #576b95;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.btn-delete {
  background: none;
  border: none;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.btn-delete:hover {
  color: #ff4d4f;
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
}

/* Loading */
.loading, .no-more {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 14px;
}

/* Login page */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  background: #fff;
  padding: 40px 32px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 360px;
  text-align: center;
  position: relative;
}

.help-icon {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid #bbb;
  color: #999;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.help-icon:hover {
  border-color: #576b95;
  color: #576b95;
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0 16px;
  color: #ccc;
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e8e8e8;
}

.login-divider span {
  padding: 0 12px;
}

.btn-guest {
  width: 100%;
  padding: 10px;
  background: #fff;
  color: #576b95;
  border: 1px solid #576b95;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

.btn-guest:hover {
  background: #f0f4ff;
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.subtitle {
  color: #999;
  font-size: 14px;
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  font-size: 15px;
  outline: none;
}

.login-card input:focus {
  border-color: #576b95;
}

.login-card button {
  width: 100%;
  padding: 10px;
  background: #576b95;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 4px;
}

.login-card button:hover {
  background: #4a5d82;
}

.error {
  color: #ff4d4f;
  font-size: 13px;
  margin-top: 8px;
}

.success {
  color: #52c41a;
  font-size: 13px;
  margin-top: 8px;
}

/* Admin page */
.admin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-form input, .admin-form select {
  padding: 8px 12px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  flex: 1;
  min-width: 120px;
}

.admin-form input:focus, .admin-form select:focus {
  border-color: #576b95;
}

.card h2 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #333;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.user-item:last-child {
  border-bottom: none;
}

.user-detail {
  font-size: 12px;
  color: #999;
  margin-left: 8px;
}

.user-item .btn-delete {
  font-size: 13px;
  color: #ff4d4f;
  padding: 4px 8px;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-edit {
  background: none;
  border: none;
  color: #576b95;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-edit:hover {
  color: #4a5d82;
}

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

.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.modal-card h2 {
  font-size: 17px;
  margin-bottom: 16px;
  text-align: center;
}

.modal-card input, .modal-card select {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.modal-card input:focus, .modal-card select:focus {
  border-color: #576b95;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions .btn-sm {
  flex: 1;
  text-align: center;
  padding: 8px;
}

.modal-actions .btn-primary {
  flex: 1;
  margin-left: 0;
  padding: 8px;
  text-align: center;
}
