:root {
  --bg: #0e0f13;
  --bg2: #15171e;
  --bg3: #1c1f28;
  --line: #23262f;
  --txt: #e8ebf1;
  --sub: #98a0b3;
  --accent: #3d8bff;
  --heart: #ff3b5c;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}

button { font-family: inherit; border: 0; background: none; color: inherit; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- 个人主页 ---------- */

.profile {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  padding-bottom: 40px;
}

.banner {
  height: 150px;
  background: linear-gradient(120deg, #1b2a4a 0%, #232042 45%, #0f2f3d 100%);
  background-size: cover;
  background-position: center;
}

.pBody { padding: 0 16px; }

.pHead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: -36px;
}

.avatarWrap {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  overflow: hidden;
  position: relative;
  background: var(--bg3);
  flex-shrink: 0;
}

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

.avatarFallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #35548f, #4a3b8f);
}

.pStats { display: flex; gap: 28px; padding-bottom: 8px; }

.stat { text-align: center; }
.stat b { display: block; font-size: 17px; font-weight: 700; }
.stat span { font-size: 12px; color: var(--sub); }

.pName { font-size: 21px; font-weight: 700; margin-top: 12px; }
.pHandle { font-size: 13px; color: var(--sub); margin-top: 4px; }
.pBio { font-size: 14px; line-height: 1.6; margin-top: 10px; color: #c6cbd8; white-space: pre-wrap; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-top: 18px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.tab {
  padding: 12px 4px;
  margin-right: 24px;
  font-size: 15px;
  color: var(--sub);
  position: relative;
}

.tab.active { color: var(--txt); font-weight: 600; }

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin-top: 2px;
}

.cell {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--bg3);
  overflow: hidden;
  cursor: pointer;
}

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

.cellPlaceholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1c2333, #221f38);
}

.cellPlaceholder svg { width: 30px; height: 30px; color: #5a6478; }

.cellShade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 44px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .55));
  pointer-events: none;
}

.cellLikes {
  position: absolute;
  left: 6px;
  bottom: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

.cellLikes svg { width: 13px; height: 13px; }

.cellBadge {
  position: absolute;
  right: 6px;
  top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  border-radius: 6px;
  padding: 2px 6px;
}

.cellBadge svg { width: 12px; height: 12px; }

.cellDur {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  padding: 1px 6px;
  border-radius: 8px;
}

.empty {
  text-align: center;
  color: var(--sub);
  padding: 70px 0 30px;
  font-size: 14px;
}

.emptyIcon { width: 52px; height: 52px; margin: 0 auto 14px; color: #3a4152; }

/* ---------- 播放页 ---------- */

.player {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  overflow: hidden;
}

.topBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: linear-gradient(rgba(0, 0, 0, .45), transparent);
  pointer-events: none;
}

.topBar > * { pointer-events: auto; }

.iconBtn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.iconBtn svg { width: 24px; height: 24px; }

.feedPos { font-size: 13px; color: rgba(255, 255, 255, .75); padding-right: 6px; }

.slides { height: 100%; will-change: transform; }

.slide {
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slide::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .38) 55%, rgba(0, 0, 0, .62));
  pointer-events: none;
  z-index: 1;
}

.imgWrap {
  position: absolute;
  inset: 0;
}

.imgTrack {
  width: 100%;
  height: 100%;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
}

.imgTrack::-webkit-scrollbar { display: none; }

.imgItem {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
}

.imgItem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

.imgCounter {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  font-size: 12px;
  color: #fff;
  background: rgba(0, 0, 0, .4);
  border-radius: 12px;
  padding: 3px 10px;
  pointer-events: none;
}

.imgDots {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}

.imgDots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .35);
  transition: background .2s, transform .2s;
}

.imgDots i.on {
  background: #fff;
  transform: scale(1.25);
}

.slide video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.pauseIcon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  color: rgba(255, 255, 255, .82);
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .5));
  pointer-events: none;
}

.playGate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .25);
}

.playGateBtn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(20, 22, 30, .72);
  border: 1px solid rgba(255, 255, 255, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  backdrop-filter: blur(4px);
}

.playGateBtn svg { width: 32px; height: 32px; margin-left: 4px; }

.rail {
  position: absolute;
  right: 10px;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.railAvatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--bg3);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

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

.railAvatar .avatarFallback { font-size: 20px; }

.railBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #fff;
}

.railBtn svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .45));
  transition: transform .15s;
}

.railBtn:active svg { transform: scale(1.25); }

.railBtn span { font-size: 12px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

.railBtn.liked svg { color: var(--heart); fill: var(--heart); }

.meta {
  position: absolute;
  left: 14px;
  right: 76px;
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  z-index: 25;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .55);
}

.mName {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
  cursor: pointer;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .7);
}

.mCaption {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .7);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

.mTime { font-size: 12.5px; color: rgba(255, 255, 255, .82); margin-top: 7px; text-shadow: 0 1px 4px rgba(0, 0, 0, .7); }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 6px);
  z-index: 26;
  height: 18px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  cursor: pointer;
}

.progressTrack {
  width: 100%;
  height: 2.5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .22);
  overflow: hidden;
}

.progressInner {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, .9);
}

.heartBurst {
  position: absolute;
  width: 84px;
  height: 84px;
  color: var(--heart);
  pointer-events: none;
  z-index: 28;
  transform: translate(-50%, -50%) scale(0);
  animation: heartPop .8s ease forwards;
}

@keyframes heartPop {
  10% { transform: translate(-50%, -50%) scale(1.15) rotate(-8deg); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1) rotate(-8deg); opacity: 1; }
  100% { transform: translate(-50%, -55%) scale(1.25) rotate(-8deg); opacity: 0; }
}

/* ---------- 底部弹层 ---------- */

.sheetMask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 59;
}

.sheetMask.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg2);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2, .7, .3, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet.open { transform: translateY(0); }

.sheetHead {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 15px 16px 11px;
  flex-shrink: 0;
}

.sheetTitle { font-size: 14px; font-weight: 600; color: var(--txt); }

.sheetClose {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
}

.sheetClose svg { width: 19px; height: 19px; }

/* 评论抽屉 */

#commentSheet { height: 68vh; }

.commentList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 12px;
  overscroll-behavior: contain;
}

.commentItem {
  display: flex;
  gap: 11px;
  padding: 11px 0;
}

.cAvatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg3);
}

.cBody { flex: 1; min-width: 0; }

.cNick { font-size: 13px; color: var(--sub); }

.cText { font-size: 14.5px; line-height: 1.5; color: var(--txt); margin-top: 3px; word-break: break-word; }

.cInfo { font-size: 12px; color: var(--sub); margin-top: 5px; }

.cLike {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--sub);
  padding-top: 4px;
}

.cLike svg { width: 15px; height: 15px; }

.cLike span { font-size: 11px; }

.commentEmpty { text-align: center; color: var(--sub); font-size: 14px; padding: 60px 0; }

.cmFoot { text-align: center; color: var(--sub); font-size: 12px; padding: 14px 0 6px; min-height: 20px; }

.emo {
  width: 18px;
  height: 18px;
  vertical-align: -3.5px;
  display: inline-block;
  margin: 0 1px;
}

.commentInputBar {
  flex-shrink: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg2);
}

.fakeInput {
  background: var(--bg3);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--sub);
  cursor: text;
}

/* 分享面板 */

.shareRow {
  display: flex;
  gap: 8px;
  padding: 8px 16px 20px;
  overflow-x: auto;
}

.shareOpt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 72px;
  color: var(--sub);
  font-size: 12px;
}

.shareOptIcon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt);
}

.shareOptIcon svg { width: 24px; height: 24px; }

.sheetCancel {
  border-top: 1px solid var(--line);
  padding: 14px;
  font-size: 15px;
  color: var(--txt);
  flex-shrink: 0;
}

/* ---------- 通用 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 15%;
  transform: translateX(-50%);
  background: rgba(28, 31, 40, .95);
  border: 1px solid var(--line);
  color: var(--txt);
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 999;
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .4);
}

@media (min-width: 700px) {
  .player { background: #060608; }
  .slide video { max-width: min(100vw, calc(100vh * 9 / 16 + 120px)); }
  .imgWrap { left: 50%; transform: translateX(-50%); width: min(100vw, calc(100vh * 9 / 16 + 120px)); }
  .rail { right: calc(50% - min(50vw, 100vh * 9 / 32 + 90px)); }
  .meta { left: calc(50% - min(46vw, 100vh * 9 / 32 + 40px)); }
  .progress { left: calc(50% - min(46vw, 100vh * 9 / 32 + 46px)); right: calc(50% - min(46vw, 100vh * 9 / 32 + 46px)); }
}
