/* ===== 主题变量 ===== */
:root {
  --bg: #f3f3f5;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-2: #4a4a4a;
  --muted: #9099a5;
  --line: rgba(0, 0, 0, .06);
  --accent: #4a6187;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
  --grid-gap: 4px;
  --radius: 16px;
}

html[data-theme="dark"] {
  --bg: #0e0e10;
  --card: #1b1b1e;
  --text: #ececee;
  --text-2: #c2c2c6;
  --muted: #77777d;
  --line: rgba(255, 255, 255, .08);
  --accent: #8fa6c9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 40px;
  min-height: 100vh;
}

/* ===== 封面 ===== */
.hero {
  position: relative;
  height: 190px;
  overflow: hidden;
  background: linear-gradient(135deg, #dfe6f0 0%, #e8e2d9 50%, #ead9d4 100%);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.hero-grain {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 55%, rgba(0, 0, 0, .10) 100%);
}

/* ===== 个人信息 ===== */
.profile {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 0 20px 18px;
  margin-top: -38px;
}

.avatar-ring {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 22px;
  padding: 3px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.avatar-ring img {
  width: 100%;
  height: 100%;
  border-radius: 19px;
  display: block;
  object-fit: cover;
}

.profile-text {
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: 2px;
}

.profile-text h1 {
  margin: 0 0 2px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .2px;
}

.profile-text p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: transform .3s ease, color .2s ease;
}

.theme-btn:hover { color: var(--text); transform: rotate(35deg); }

/* ===== 时间线 ===== */
.timeline { padding: 0 14px; }

.divider {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--muted);
  background: linear-gradient(to bottom, var(--bg) 62%, transparent);
  backdrop-filter: blur(6px);
}

.moment {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  animation: rise .45s cubic-bezier(.2, .7, .3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.m-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.m-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--bg);
}

.m-meta { min-width: 0; }

.m-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
}

.m-time {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.m-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.72;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== 图片九宫格 ===== */
.m-grid {
  display: grid;
  gap: var(--grid-gap);
  margin: 10px 0 2px;
  width: 100%;
}

.m-grid.n-1 { grid-template-columns: 1fr; max-width: 66%; }
.m-grid.n-2, .m-grid.n-4 { grid-template-columns: repeat(2, 1fr); max-width: 66%; }
.m-grid.n-3, .m-grid.n-5, .m-grid.n-6,
.m-grid.n-7, .m-grid.n-8, .m-grid.n-9 { grid-template-columns: repeat(3, 1fr); }

.m-grid figure {
  margin: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
}

.m-grid.n-1 figure { aspect-ratio: 4 / 3; border-radius: 10px; }

.m-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s cubic-bezier(.2, .7, .3, 1);
}

.m-grid figure:hover img { transform: scale(1.04); }

/* ===== 地点 ===== */
.m-loc {
  margin-top: 9px;
  font-size: 12px;
  color: var(--muted);
}

/* ===== 页脚 ===== */
.foot {
  padding: 26px 20px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .3px;
}

/* ===== 大图预览 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .88);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
  animation: fade .2s ease;
}

.lightbox[hidden] { display: none; }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== 空状态 ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ===== 发布按钮 ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(74, 97, 135, .35);
  cursor: pointer;
  z-index: 40;
  transition: transform .2s ease;
}

.fab:hover { transform: scale(1.06); }
.fab:active { transform: scale(.94); }

/* ===== 删除 ===== */
.m-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s ease, background .2s ease;
}

.moment:hover .m-del { opacity: 1; }
.m-del:hover { background: var(--line); color: #c34; }

/* ===== 发布弹层 ===== */
.composer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.composer[hidden] { display: none; }

.composer-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(3px);
  animation: fade .2s ease;
}

/* ===== 编辑器 ===== */
.composer { align-items: end; padding: 0; }

.composer-card {
  position: relative;
  width: min(640px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: slide-up .28s cubic-bezier(.2, .8, .3, 1);
}

.composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}

.composer-close {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

#cText {
  width: 100%;
  min-height: 110px;
  border: 0;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text);
}

#cText:focus { outline: 0; }

.composer-imgs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
}

.composer-imgs:empty { display: none; }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

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

.thumb button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.pick-btn:hover { background: var(--line); }

.loc-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

.loc-input:focus { outline: 0; border-color: var(--accent); }

.send-btn {
  padding: 8px 18px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.send-btn:disabled { opacity: .55; cursor: default; }

.composer-err { min-height: 16px; margin-top: 8px; font-size: 12.5px; color: #d9534f; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: none; }
}

@keyframes slide-up {
  from { transform: translateY(30px); opacity: .6; }
  to { transform: none; opacity: 1; }
}

@media (min-width: 720px) {
  .composer { align-items: center; }
  .composer-card { border-radius: 20px; }
}

@media (max-width: 420px) {
  .hero { height: 160px; }
  .avatar-ring { width: 68px; height: 68px; border-radius: 20px; }
  .avatar-ring img { border-radius: 17px; }
  .profile { padding: 0 16px 14px; margin-top: -34px; }
  .timeline { padding: 0 10px; }
  .moment { padding: 14px; border-radius: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
