:root {
  --wechat-blue: #576b95;
  --page: #ededed;
  --surface: #fff;
  --text: #191919;
  --muted: #777;
  --line: #e5e5e5;
  --bubble: #f4f4f4;
}

.moments-body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.moments-body.dark {
  --page: #111;
  --surface: #1c1c1e;
  --text: #f4f4f5;
  --muted: #a6a6aa;
  --line: #333;
  --bubble: #2c2c2e;
}

.tool-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.back-link {
  color: #194f45;
  font-weight: 800;
  text-decoration: none;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.save-status {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}

.primary-btn,
.secondary-btn,
.icon-btn {
  min-height: 34px;
  border-radius: 6px;
  padding: 7px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

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

.secondary-btn,
.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.phone-shell {
  width: min(430px, 100%);
  min-height: calc(100vh - 55px);
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 7px 14px 5px;
  background: rgba(245, 245, 245, .92);
  color: #111;
  font-size: .76rem;
  font-weight: 800;
}

.dark .status-bar {
  background: #18181a;
  color: #f5f5f5;
}

.moments-header {
  position: relative;
  border-bottom: 1px solid var(--line);
}

.cover-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
  background: linear-gradient(135deg, #7f9eb2, #d8c29d);
  background-size: cover;
  background-position: center;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .38);
  font: inherit;
  cursor: pointer;
}

.cover-photo.has-image span {
  display: none;
}

.profile-row {
  min-height: 46px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 12px;
  padding: 0 14px 12px;
  margin-top: -36px;
}

.profile-name {
  max-width: 280px;
  padding: 3px 0;
  color: #fff;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .42);
  font-size: 1.08rem;
  font-weight: 800;
}

.avatar {
  width: 74px;
  height: 74px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: #d9e3f0;
  background-size: cover;
  background-position: center;
  color: var(--wechat-blue);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
  cursor: pointer;
}

.avatar.has-image span {
  display: none;
}

.feed {
  max-height: calc(100vh - 176px);
  overflow-y: auto;
}

.moment {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--line);
}

.post-avatar {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #d9e3f0;
  background-size: cover;
  background-position: center;
  color: var(--wechat-blue);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.post-main {
  min-width: 0;
}

.username {
  color: var(--wechat-blue);
  font-weight: 800;
  line-height: 1.2;
}

[contenteditable="true"]:focus,
.moment-form input:focus,
.moment-form textarea:focus {
  outline: 2px solid #07c160;
  outline-offset: 2px;
  border-radius: 4px;
}

.post-text {
  margin: 5px 0 8px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 78px);
  gap: 5px;
  margin: 8px 0;
}

.photo-grid.count-1 {
  grid-template-columns: 170px;
}

.photo-grid.count-2,
.photo-grid.count-4 {
  grid-template-columns: repeat(2, 78px);
}

.post-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  background: #ddd;
  cursor: pointer;
}

.post-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.timestamp {
  margin-top: 7px;
  color: var(--muted);
  font-size: .8rem;
}

.interaction {
  position: relative;
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 3px;
  background: var(--bubble);
  color: var(--text);
  font-size: .9rem;
}

.interaction::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 18px;
  border-right: 6px solid transparent;
  border-bottom: 6px solid var(--bubble);
  border-left: 6px solid transparent;
}

.likes,
.comments {
  cursor: pointer;
}

.likes {
  color: var(--wechat-blue);
  font-weight: 700;
}

.comments {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--line);
}

.comment {
  margin-top: 2px;
}

.comment-user {
  color: var(--wechat-blue);
  font-weight: 800;
}

.empty-feed {
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header {
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.moment-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.moment-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
}

.moment-form input,
.moment-form textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.image-preview img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
}

.modal-actions {
  justify-content: flex-end;
  padding: 0;
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 60;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #191919;
  color: #fff;
  font-size: .86rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript-note {
  max-width: 430px;
  margin: 16px auto;
  color: #b42318;
  font-weight: 800;
}

@media (max-width: 680px) {
  .tool-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tool-actions {
    justify-content: flex-start;
  }

  .phone-shell {
    min-height: calc(100vh - 112px);
    box-shadow: none;
  }

  .feed {
    max-height: none;
  }
}

@media (max-width: 360px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .photo-grid.count-1 {
    grid-template-columns: minmax(0, 1fr);
  }
}
