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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: #333;
  background: #f5f5f5;
  -webkit-font-smoothing: antialiased;
}

/* ========== 主容器 ========== */
.moments-app {
  max-width: 600px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  padding-bottom: 30px;
}

/* ========== 顶部封面 ========== */
.moments-header {
  position: relative;
  height: 300px;
  overflow: hidden;
}

.cover-bg {
  position: absolute;
  inset: 0;
}

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

.user-profile {
  position: absolute;
  bottom: -36px;
  right: 20px;
  left: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.user-info {
  margin-right: 16px;
  text-align: right;
}

.user-name {
  font-size: 18px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  font-weight: 500;
}

.user-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.user-avatar {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 4px solid #fff;
  background: #ddd;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========== 导航栏 ========== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  height: 50px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.auth-status {
  font-size: 14px;
  color: #576b95;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.auth-status:hover {
  background: #f5f5f5;
}

.auth-status.logged {
  color: #333;
  font-weight: 500;
}

.nav-title {
  font-size: 16px;
  font-weight: 500;
}

.back-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  border-radius: 4px;
}

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

.publish-btn {
  background: #07c160;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
}

.publish-btn:hover {
  background: #06ad56;
}

/* ========== 动态卡片 ========== */
.moment-card {
  background: #fff;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.moment-header {
  display: flex;
  align-items: flex-start;
  position: relative;
}

.moment-avatar {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
}

.moment-user-info {
  margin-left: 12px;
  flex: 1;
  min-width: 0;
}

.moment-username {
  font-size: 15px;
  font-weight: 500;
  color: #576b95;
  cursor: pointer;
}

.moment-username:hover {
  text-decoration: underline;
}

.moment-time {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.moment-location {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #576b95;
}

.moment-more {
  color: #999;
  cursor: pointer;
  padding: 4px;
}

.moment-content {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}

/* ========== 图片九宫格 ========== */
.image-grid {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.image-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  background: #f0f0f0;
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.image-item:hover img {
  transform: scale(1.05);
}

.grid-1 { grid-template-columns: 1fr; max-width: 240px; }
.grid-1 .image-item { aspect-ratio: auto; min-height: 120px; max-height: 300px; }
.grid-1 .image-item img { object-fit: contain; }
.grid-2 { grid-template-columns: repeat(2, 1fr); max-width: 300px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); max-width: 300px; }
.grid-5, .grid-6, .grid-7, .grid-8, .grid-9 { grid-template-columns: repeat(3, 1fr); }

/* ========== 操作栏 ========== */
.moment-actions {
  display: flex;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  gap: 30px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #f5f5f5;
  color: #576b95;
}

.action-btn.liked {
  color: #f5a623;
}

/* ========== 点赞区 ========== */
.like-section {
  display: flex;
  margin-top: 10px;
  padding: 8px 12px;
  background: #f7f7f7;
  border-radius: 4px;
  position: relative;
}

.like-section::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 40px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #f7f7f7;
}

.like-icon {
  color: #f5a623;
  margin-right: 8px;
  flex-shrink: 0;
}

.like-users {
  flex: 1;
  font-size: 13px;
  color: #576b95;
  line-height: 1.5;
}

.like-user {
  cursor: pointer;
}

.like-user:hover {
  text-decoration: underline;
}

/* ========== 评论区 ========== */
.comment-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
}

.comment-item {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  margin-right: 10px;
  flex-shrink: 0;
  object-fit: cover;
}

.comment-content {
  flex: 1;
  min-width: 0;
}

.comment-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
}

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

.comment-footer {
  display: flex;
  align-items: center;
  margin-top: 4px;
  font-size: 12px;
  color: #999;
  gap: 15px;
}

.comment-reply {
  color: #576b95;
  cursor: pointer;
}

.comment-reply:hover {
  text-decoration: underline;
}

/* 评论输入框 */
.comment-input-box {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.comment-input-box input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

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

.comment-input-box button {
  padding: 0 16px;
  background: #07c160;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.comment-input-box button:hover {
  background: #06ad56;
}

/* ========== 加载更多 ========== */
.load-more {
  text-align: center;
  padding: 20px;
  color: #999;
  cursor: pointer;
  font-size: 14px;
}

.load-more:hover {
  color: #576b95;
}

.no-more {
  text-align: center;
  padding: 20px;
  color: #ccc;
  font-size: 12px;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: #999;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  color: #ddd;
}

.empty-state p {
  font-size: 14px;
}

/* ========== 弹窗 ========== */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 500;
}

.modal-close {
  color: #999;
  cursor: pointer;
  font-size: 16px;
}

.modal-close:hover {
  color: #666;
}

.modal-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-default,
.btn-primary {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-default {
  background: #f5f5f5;
  color: #666;
}

.btn-default:hover {
  background: #eee;
}

.btn-primary {
  background: #07c160;
  color: #fff;
}

.btn-primary:hover {
  background: #06ad56;
}

.btn-primary:disabled {
  background: #9be3bf;
  cursor: not-allowed;
}

/* ========== 发布弹窗 ========== */
.publish-textarea {
  width: 100%;
  min-height: 120px;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  font-family: inherit;
}

.publish-images {
  margin-top: 16px;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 300px;
  margin-bottom: 8px;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
}

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

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

.upload-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border: 1px dashed #ddd;
  border-radius: 6px;
  color: #999;
  cursor: pointer;
  font-size: 12px;
  gap: 4px;
  transition: all 0.2s;
}

.upload-btn:hover {
  border-color: #576b95;
  color: #576b95;
}

.upload-btn i {
  font-size: 24px;
}

.publish-extra {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}

.extra-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #333;
}

.location-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
}

/* ========== 图片预览 ========== */
.image-viewer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  z-index: 10;
}

/* ========== Loading ========== */
.loading {
  text-align: center;
  padding: 30px;
  color: #999;
}

.loading i {
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========== 登录/注册 ========== */
.auth-dialog {
  max-width: 400px;
}

.auth-tabs {
  display: flex;
  gap: 24px;
}

.auth-tab {
  font-size: 16px;
  color: #999;
  cursor: pointer;
  padding-bottom: 4px;
  position: relative;
  transition: all 0.2s;
}

.auth-tab.active {
  color: #333;
  font-weight: 500;
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: #07c160;
  border-radius: 2px;
}

.form-item {
  margin-bottom: 16px;
}

.form-item label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 6px;
}

.form-item input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-item input:focus {
  border-color: #07c160;
}

.btn-block {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
}

.auth-tip {
  text-align: center;
  font-size: 13px;
  color: #999;
  margin-top: 16px;
}

.auth-tip a {
  color: #576b95;
  text-decoration: none;
}

.auth-tip a:hover {
  text-decoration: underline;
}

/* ========== 用户菜单 ========== */
.user-menu {
  position: absolute;
  top: 42px;
  right: 60px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  z-index: 200;
  min-width: 140px;
  overflow: hidden;
}

.user-menu-item {
  padding: 10px 16px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.user-menu-item:hover {
  background: #f5f5f5;
}

.user-menu-divider {
  border-top: 1px solid #f0f0f0;
  color: #e74c3c;
}

/* ========== 游客评论标识 ========== */
.guest-badge {
  display: inline-block;
  font-size: 11px;
  background: #eee;
  color: #999;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 3000;
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
