.nav-user-chip {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0 !important;
    margin: 0 2px;
    box-sizing: border-box;
    border-radius: 50%;
    color: var(--txt-b-pure) !important;
}

.nav-user-avatar {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: cover;
    border: 1.5px solid var(--theme-color);
    border-radius: 50%;
    background: var(--black-a-5);
}

.nav-user-name {
    display: none;
}

.user-modal {
    position: fixed;
    inset: 0;
    z-index: 2500;
    pointer-events: none;
}

.user-modal[hidden] {
    display: none !important;
}

.user-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 8, 16, .08);
    pointer-events: auto;
}

.user-modal-card {
    position: fixed;
    top: var(--drawer-top, 72px);
    right: var(--drawer-right, 18px);
    width: min(348px, calc(100vw - 24px));
    max-height: calc(100vh - 84px);
    overflow: auto;
    padding: 18px;
    border: .5px solid var(--black-a-10);
    border-radius: 14px;
    background: var(--container-1);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
    color: var(--txt-b-pure);
    text-align: left;
    box-sizing: border-box;
    pointer-events: auto;
    backdrop-filter: blur(26px);
    animation: userDrawerIn .18s ease-out;
}

@keyframes userDrawerIn {
    from { opacity: 0; transform: translateY(-7px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-modal-close {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--black-a-50);
    font-size: 20px;
    cursor: pointer;
}

.user-modal-close:hover {
    background: var(--black-a-5);
    color: var(--txt-b-pure);
}

.user-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 28px;
}

.user-modal-avatar {
    display: block;
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    object-fit: cover;
    border: 2px solid var(--theme-color);
    border-radius: 50%;
    background: var(--black-a-5);
}

.user-modal-name {
    margin: 0;
    color: var(--txt-b-pure);
    font-family: "思源宋体 SemiBold", "Songti SC", "STSong", "SimSun", serif;
    font-size: 20px;
    font-weight: 600;
}

.user-modal-count {
    margin: 4px 0 0;
    color: var(--black-a-50);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.user-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}

.user-modal-actions button {
    min-height: 42px;
    padding: 0 10px;
    border: .5px solid var(--black-a-10);
    border-radius: 8px;
    background: transparent;
    color: var(--txt-b-pure);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.user-modal-actions .user-checkin {
    border-color: var(--theme-color);
    background: var(--theme-color);
    color: #07111f;
}

.user-modal-actions button:hover {
    filter: brightness(1.06);
}

.user-modal-actions button:disabled {
    opacity: .48;
    cursor: default;
}

.user-edit-form {
    margin-top: 14px;
    padding-top: 13px;
    border-top: .5px solid var(--black-a-10);
}

.user-edit-form[hidden] {
    display: none !important;
}

.user-edit-label {
    margin: 0 0 6px;
    color: var(--black-a-50);
    font-size: 12px;
}

.user-avatar-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.user-avatar-option {
    display: block;
    padding: 2px;
    border: 1.5px solid transparent;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.user-avatar-option img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 50%;
}

.user-avatar-option.is-selected {
    border-color: var(--theme-color);
}

.user-edit-form input {
    width: 100%;
    height: 40px;
    padding: 0 10px;
    border: .5px solid var(--black-a-10);
    border-radius: 7px;
    background: var(--black-a-5);
    color: var(--txt-b-pure);
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}

.user-edit-buttons {
    display: flex;
    gap: 6px;
    margin-top: 9px;
}

.user-edit-buttons button,
.user-logout,
.user-logout-confirm button {
    min-height: 38px;
    padding: 0 12px;
    border: .5px solid var(--black-a-10);
    border-radius: 7px;
    background: transparent;
    color: var(--txt-b-pure);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.user-edit-buttons button[type="submit"] {
    border-color: var(--theme-color);
    background: var(--theme-color);
    color: #07111f;
}

.user-logout {
    width: 100%;
    margin-top: 12px;
    color: var(--black-a-60);
}

.user-logout:hover {
    border-color: rgba(255, 120, 130, .5);
    color: #ff9da7;
}

.user-logout-confirm {
    margin-top: 12px;
    padding: 11px;
    border: .5px solid rgba(255, 110, 120, .25);
    border-radius: 8px;
    background: rgba(255, 80, 95, .07);
}

.user-logout-confirm[hidden] {
    display: none !important;
}

.user-logout-confirm p {
    margin: 0 0 9px;
    color: #ffb3bd;
    font-size: 12px;
}

.user-logout-confirm button {
    margin-right: 6px;
}

.user-logout-confirm .user-logout-yes {
    border-color: rgba(255, 90, 105, .4);
    background: #c93d4d;
    color: #fff;
}

.user-modal-note {
    min-height: 17px;
    margin: 9px 0 0;
    color: #ffb3bd;
    font-size: 12px;
    line-height: 1.5;
}

@media screen and (max-width: 760px) {
    .user-modal-card {
        top: 66px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 78px);
        padding: 16px;
    }

    .user-modal-actions {
        grid-template-columns: 1fr;
    }
}

.nav-user-avatar[data-frame="ring"],
.user-modal-avatar[data-frame="ring"] {
    border-color: #cfeaff;
    box-shadow: 0 0 0 2px rgba(207, 234, 255, .75), 0 0 18px rgba(132, 199, 254, .45);
}

.nav-user-avatar[data-frame="spark"],
.user-modal-avatar[data-frame="spark"] {
    border-color: transparent;
    background: linear-gradient(var(--container-1), var(--container-1)) padding-box,
                conic-gradient(from 20deg, #84c7fe, #ffd6ea, #b8ffe6, #84c7fe) border-box;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .55), 0 0 18px rgba(255, 214, 234, .5);
}

.mobile-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 48px);
    margin: 4px auto 10px;
    padding: 10px 4px 13px;
    border-bottom: .5px solid var(--black-a-10);
    color: var(--txt-b-pure);
    text-decoration: none;
}

.mobile-user-card img {
    display: block;
    width: 38px;
    height: 38px;
    object-fit: cover;
    border: 1.5px solid var(--theme-color);
    border-radius: 50%;
}

.mobile-user-card strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.mobile-user-card small {
    display: block;
    margin-top: 2px;
    color: var(--black-a-50);
    font-size: 11px;
}

.mobile-user-card img[data-frame="ring"] {
    box-shadow: 0 0 0 2px rgba(207, 234, 255, .75);
}

.mobile-user-card img[data-frame="spark"] {
    border-color: transparent;
    background: linear-gradient(var(--container-1), var(--container-1)) padding-box,
                conic-gradient(from 20deg, #84c7fe, #ffd6ea, #b8ffe6, #84c7fe) border-box;
}

#navbox .mobile-user-card {
    width: calc(100% - 40px);
}

.site-nav-user-slot,
.nav-mobile-user {
    display: none !important;
}

@media screen and (max-width: 760px) {
    .site-nav-user-slot.nav-user-chip {
        display: inline-flex !important;
        margin-left: 2px;
    }

    .nav-mobile-user.nav-user-chip {
        position: absolute;
        top: 31.5px;
        right: 152px;
        display: inline-flex !important;
        z-index: 1002;
    }
}

.site-nav-user-slot:empty,
.nav-mobile-user:empty {
    display: none !important;
}

@media screen and (max-width: 760px) {
    .nav-mobile-user,
    .site-nav-user-slot {
        display: none !important;
    }
}

@media screen and (max-width: 760px) {
    .nav-mobile-user.nav-user-chip,
    .site-nav-user-slot.nav-user-chip {
        display: none !important;
    }
}

body.menu-open .btn-menu {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.avatar-frame-option.is-locked {
    opacity: .42;
    cursor: not-allowed;
}

.profile-auth-art .avatar-frame-options {
    flex-wrap: wrap;
    row-gap: 5px;
}

.profile-mobile-frames {
    display: none;
}

.profile-mobile-frames-title {
    margin: 0 0 8px;
    color: rgba(255, 255, 255, .6);
    font-size: 12px;
}

.profile-mobile-frame-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.profile-mobile-frame-list .avatar-frame-option {
    min-height: 38px;
    padding: 0 6px;
    font-size: 11px;
}

@media screen and (max-width: 820px) {
    .profile-mobile-frames {
        display: block;
        margin: 0 0 16px;
    }
}

[data-frame="gold"] .frame-swatch,
.frame-swatch[data-frame="gold"] { background: linear-gradient(135deg, #fff2ad, #ffb300, #fff2ad); }
[data-frame="sakura"] .frame-swatch,
.frame-swatch[data-frame="sakura"] { background: linear-gradient(135deg, #ffe2ef, #ff8fbe, #ffe2ef); }
[data-frame="ocean"] .frame-swatch,
.frame-swatch[data-frame="ocean"] { background: linear-gradient(135deg, #9de8ff, #138fd6, #9de8ff); }
[data-frame="forest"] .frame-swatch,
.frame-swatch[data-frame="forest"] { background: linear-gradient(135deg, #c8ffd9, #2ba86a, #c8ffd9); }
[data-frame="sunset"] .frame-swatch,
.frame-swatch[data-frame="sunset"] { background: linear-gradient(135deg, #ffe0a8, #ff7448, #a837ff); }
[data-frame="neon"] .frame-swatch,
.frame-swatch[data-frame="neon"] { background: linear-gradient(135deg, #69f7ff, #a95cff, #ff6ad5); }
[data-frame="cloud"] .frame-swatch,
.frame-swatch[data-frame="cloud"] { background: linear-gradient(135deg, #ffffff, #b9ddff, #ffffff); }
[data-frame="flame"] .frame-swatch,
.frame-swatch[data-frame="flame"] { background: linear-gradient(135deg, #fff0a8, #ff4e35, #8d1200); }
[data-frame="aurora"] .frame-swatch,
.frame-swatch[data-frame="aurora"] { background: linear-gradient(135deg, #7bffd8, #349cff, #d071ff); }
[data-frame="royal"] .frame-swatch,
.frame-swatch[data-frame="royal"] { background: linear-gradient(135deg, #fff1a8, #d9a72e, #8b5cff); }

.nav-user-avatar[data-frame="gold"], .user-modal-avatar[data-frame="gold"], .mobile-user-card img[data-frame="gold"] { border-color: #ffd76a; box-shadow: 0 0 0 2px #ffd76a, 0 0 16px #ffb300; }
.nav-user-avatar[data-frame="sakura"], .user-modal-avatar[data-frame="sakura"], .mobile-user-card img[data-frame="sakura"] { border-color: #ffa9c9; box-shadow: 0 0 0 2px #ffa9c9, 0 0 18px #ff8fbe; }
.nav-user-avatar[data-frame="ocean"], .user-modal-avatar[data-frame="ocean"], .mobile-user-card img[data-frame="ocean"] { border-color: #63d5ff; box-shadow: 0 0 0 2px #63d5ff, 0 0 18px #138fd6; }
.nav-user-avatar[data-frame="forest"], .user-modal-avatar[data-frame="forest"], .mobile-user-card img[data-frame="forest"] { border-color: #74e29b; box-shadow: 0 0 0 2px #74e29b, 0 0 18px #2ba86a; }
.nav-user-avatar[data-frame="sunset"], .user-modal-avatar[data-frame="sunset"], .mobile-user-card img[data-frame="sunset"] { border-color: #ff9a62; box-shadow: 0 0 0 2px #ff9a62, 0 0 18px #a837ff; }
.nav-user-avatar[data-frame="neon"], .user-modal-avatar[data-frame="neon"], .mobile-user-card img[data-frame="neon"] { border-color: #b689ff; box-shadow: 0 0 0 2px #b689ff, 0 0 20px #69f7ff; }
.nav-user-avatar[data-frame="cloud"], .user-modal-avatar[data-frame="cloud"], .mobile-user-card img[data-frame="cloud"] { border-color: #d9edff; box-shadow: 0 0 0 2px #d9edff, 0 0 18px #b9ddff; }
.nav-user-avatar[data-frame="flame"], .user-modal-avatar[data-frame="flame"], .mobile-user-card img[data-frame="flame"] { border-color: #ff755c; box-shadow: 0 0 0 2px #ff755c, 0 0 20px #ff4e35; }
.nav-user-avatar[data-frame="aurora"], .user-modal-avatar[data-frame="aurora"], .mobile-user-card img[data-frame="aurora"] { border-color: #7bffd8; box-shadow: 0 0 0 2px #7bffd8, 0 0 22px #349cff; }
.nav-user-avatar[data-frame="royal"], .user-modal-avatar[data-frame="royal"], .mobile-user-card img[data-frame="royal"] { border-color: #e7c86a; box-shadow: 0 0 0 2px #e7c86a, 0 0 22px #8b5cff; }

#avatarFrameOptions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}

.frame-group {
    width: 100%;
}

.frame-group-title {
    margin: 2px 0 4px;
    color: rgba(255, 255, 255, .55);
    font-size: 10px;
    letter-spacing: .08em;
    text-align: center;
}

.frame-group-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
}

.frame-swatch {
    border-radius: 50% !important;
    overflow: hidden;
}

.avatar-frame-option {
    border-radius: 999px !important;
}

.avatar-frame,
.avatar-preview,
.avatar-preview img,
.avatar-crop-ring {
    border-radius: 50% !important;
    overflow: hidden;
}

.profile-mobile-frame-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-mobile-frame-list .frame-group-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.profile-mobile-frame-list .frame-group-title {
    text-align: left;
    margin: 0 0 4px;
}

html:not(.dark) body.login-page .frame-group-title {
    color: rgba(42, 70, 90, .55);
}

.frame-save {
    margin-top: 10px;
}

/* 头像框选项统一为圆形预览，不再用长方形按钮 */
#avatarFrameOptions .avatar-frame-option,
.auth-art .avatar-frame-option,
.profile-mobile-frame-list .avatar-frame-option {
    width: 60px;
    min-height: 62px;
    height: auto;
    padding: 0;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    font-size: 10px;
    line-height: 1.2;
}

#avatarFrameOptions .avatar-frame-option .frame-swatch,
.auth-art .avatar-frame-option .frame-swatch,
.profile-mobile-frame-list .avatar-frame-option .frame-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 255, 255, .42);
    box-shadow: 0 0 10px rgba(0, 0, 0, .14);
}

#avatarFrameOptions .avatar-frame-option.is-active .frame-swatch,
.auth-art .avatar-frame-option.is-active .frame-swatch,
.profile-mobile-frame-list .avatar-frame-option.is-active .frame-swatch {
    border-color: var(--theme-color);
    box-shadow: 0 0 0 2px rgba(132, 199, 254, .55), 0 0 14px rgba(132, 199, 254, .45);
}

#avatarFrameOptions .avatar-frame-option.is-locked,
.auth-art .avatar-frame-option.is-locked,
.profile-mobile-frame-list .avatar-frame-option.is-locked {
    opacity: .42;
}

html:not(.dark) body.login-page .avatar-frame-option .frame-swatch {
    border-color: rgba(42, 90, 120, .25);
}

html:not(.dark) body.login-page .avatar-frame-option {
    color: #31556e;
}

body:not(.profile-page) #avatarFrameOptions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
}

/* 导航栏头像框：框住整颗头像，不只改图片边框 */
.nav-user-chip[data-frame="ring"] { border: 2px solid rgba(214,240,255,.9); box-shadow: 0 0 14px rgba(142,209,255,.5); }
.nav-user-chip[data-frame="spark"] { border: 2px solid #b689ff; box-shadow: 0 0 14px rgba(247,178,217,.6); }
.nav-user-chip[data-frame="gold"] { border: 2px solid #ffd76a; box-shadow: 0 0 16px rgba(255,179,0,.7); }
.nav-user-chip[data-frame="sakura"] { border: 2px solid #ffa9c9; box-shadow: 0 0 16px rgba(255,143,190,.65); }
.nav-user-chip[data-frame="ocean"] { border: 2px solid #63d5ff; box-shadow: 0 0 16px rgba(19,143,214,.65); }
.nav-user-chip[data-frame="forest"] { border: 2px solid #74e29b; box-shadow: 0 0 16px rgba(43,168,106,.65); }
.nav-user-chip[data-frame="sunset"] { border: 2px solid #ff9a62; box-shadow: 0 0 16px rgba(168,55,255,.6); }
.nav-user-chip[data-frame="neon"] { border: 2px solid #b689ff; box-shadow: 0 0 18px rgba(105,247,255,.6); }
.nav-user-chip[data-frame="cloud"] { border: 2px solid #e5f5ff; box-shadow: 0 0 16px rgba(185,221,255,.7); }
.nav-user-chip[data-frame="flame"] { border: 2px solid #ff755c; box-shadow: 0 0 18px rgba(255,78,53,.7); }
.nav-user-chip[data-frame="aurora"] { border: 2px solid #7bffd8; box-shadow: 0 0 18px rgba(52,156,255,.65); }
.nav-user-chip[data-frame="royal"] { border: 2px solid #e7c86a; box-shadow: 0 0 18px rgba(139,92,255,.65); }

.nav-user-chip[data-frame]:not([data-frame="none"]) .nav-user-avatar {
    border-color: transparent !important;
    box-shadow: none !important;
}

.frame-save {
    width: 100%;
    max-width: 260px;
    margin: 10px auto 0;
}

.frame-save:disabled {
    opacity: .42;
    cursor: not-allowed;
    box-shadow: none !important;
}

.frame-save-mobile {
    display: none;
}

@media screen and (max-width: 820px) {
    .frame-save-mobile {
        display: flex;
    }
}

.nav-user-chip,
.nav-user-chip.nav-link {
    border-radius: 50% !important;
    overflow: hidden;
    box-sizing: border-box;
}

.nav-user-chip .nav-user-avatar {
    border-radius: 50% !important;
}

.nav-user-chip,
.nav-user-chip .nav-user-avatar {
    clip-path: circle(50% at 50% 50%);
}

/* 消息红点 */
.nav-user-chip { position: relative; }

.nav-user-chip.has-messages::after {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--container-1);
    border-radius: 50%;
    background: #f05252;
}

.user-messages {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 40px;
    margin: 10px 0 0;
    padding: 0 12px;
    border: 1px solid var(--black-a-10);
    border-radius: 9px;
    background: transparent;
    color: var(--txt-b-pure);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.user-message-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #f05252;
    color: #fff;
    font-size: 10px;
    line-height: 1;
}

.user-message-badge[hidden] { display: none !important; }

.user-messages-panel {
    max-height: 240px;
    overflow: auto;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--black-a-10);
    border-radius: 9px;
    background: var(--black-a-5);
}

.user-messages-panel[hidden] { display: none !important; }

.user-message-item {
    padding: 8px 9px;
    border-bottom: 1px solid var(--black-a-10);
}

.user-message-item:last-child { border-bottom: 0; }
.user-message-item.is-unread { border-left: 2px solid #84c7fe; }

.user-message-item p {
    margin: 0 0 3px;
    font-size: 12px;
    line-height: 1.5;
}

.user-message-item time {
    color: var(--black-a-50);
    font-size: 10px;
}

.user-messages-empty {
    margin: 8px;
    color: var(--black-a-50);
    font-size: 12px;
    text-align: center;
}

.mobile-user-card { position: relative; }

.mobile-user-card.has-messages::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 42px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--container-1);
    border-radius: 50%;
    background: #f05252;
}

/* 白天模式下用户消息面板黑字 */
html:not(.dark) .user-modal,
html:not(.dark) .user-messages,
html:not(.dark) .user-message-item p,
html:not(.dark) .user-messages-empty,
html:not(.dark) .user-modal-note {
    color: #1d3a4d;
}

html:not(.dark) .user-message-item time { color: #5f7b8e; }

html.dark .user-modal,
html.dark .user-messages,
html.dark .user-message-item p,
html.dark .user-messages-empty,
html.dark .user-modal-note {
    color: #eaf7ff;
}

html.dark .user-message-item time { color: #9ab2c2; }

/* 红点不能被圆形头像的 overflow/clip-path 裁掉 */
.nav-user-chip.has-messages {
    overflow: visible !important;
    clip-path: none !important;
}

.nav-user-chip.has-messages::after {
    top: 0;
    left: 0;
    z-index: 5;
    width: 10px;
    height: 10px;
    box-sizing: border-box;
}
