.user-profile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 32px;
    position: relative;
    z-index: 30;
}

.user-profile-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.user-profile-trigger:focus-visible {
    outline: 3px solid var(--accent-glow, rgba(64, 81, 181, .18));
    outline-offset: 3px;
    border-radius: 50%;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border: 1px solid var(--sidebar-border, #e5e7eb);
    border-radius: 50%;
    object-fit: cover;
    background: #eef2f7;
}

.user-avatar-fallback {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    background: var(--accent, #4051b5);
    font-size: 13px;
    font-weight: 600;
}

.user-avatar[hidden],
.user-avatar-fallback[hidden],
.user-menu[hidden],
.account-modal[hidden] {
    display: none !important;
}

.user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 20;
    width: 178px;
    padding: 6px;
    border: 1px solid var(--sidebar-border, #e5e7eb);
    border-radius: 12px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 12px 30px rgba(31, 41, 55, .16);
}

.user-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 9px;
    padding: 10px 11px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary, #1f2937);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.user-menu button:hover { background: #f3f5f8; }
.user-menu .logout-action { color: #c24141; }
.menu-msg-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e5484d;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

/* 统一线性图标 */
.menu-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

/* 菜单底部额度行 */
.menu-quota {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    margin-top: 6px;
    padding: 10px 11px;
    border-top: 1px solid var(--sidebar-border, #e5e7eb);
    font-size: 13px;
}

.menu-quota-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text-secondary, #64748b);
}

.menu-quota-value {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    font-variant-numeric: tabular-nums;
}
/* button 自带 display:flex，会盖掉 [hidden] 的默认 display:none，必须单独兜住 */
.user-menu button[hidden] { display: none !important; }

.account-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    /* 居中偏上：先等比居中，再由 account-card 的 translateY 上移一档 */
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .42);
}

.account-card {
    width: min(620px, 100%);
    max-height: min(680px, calc(100vh - 40px));
    /* 居中偏上：相对居中位置再上移约 6% 视口高度 */
    transform: translateY(-6vh);
    overflow: auto;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .2);
}

.account-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #edf0f4;
}

.account-card-header h2 { margin: 0; font-size: 18px; }

.account-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 22px;
    cursor: pointer;
}

.account-close:hover { background: #f3f5f8; }
.account-content { padding: 8px 24px 24px; }

.account-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0 18px;
}

.account-avatar-row .user-avatar,
.account-avatar-row .user-avatar-fallback {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

.account-avatar-row strong { font-size: 15px; }

.account-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 16px;
    padding: 15px 0;
    border-top: 1px solid #edf0f4;
    font-size: 13px;
}

.account-row-label { color: var(--text-secondary, #64748b); }

.account-row-value {
    min-width: 0;
    color: var(--text-primary, #1f2937);
    overflow-wrap: anywhere;
    text-align: right;
}

/* 头像更换：头像右下角小圆钮 */
.account-avatar-wrap {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
}

.account-avatar-edit {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    background: #fff;
    color: var(--accent, #2563eb);
    font: inherit;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .12);
}

.account-avatar-edit:hover { background: #f3f5f8; }
.account-avatar-edit:disabled { opacity: .6; cursor: default; }

/* 昵称编辑 */
.account-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.account-name-wrap strong { font-size: 15px; }

.account-name-edit {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent, #2563eb);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.account-name-edit:hover { text-decoration: underline; }

.account-name-editor {
    display: flex;
    align-items: center;
    gap: 6px;
}

.account-name-editor[hidden] { display: none !important; }

.account-name-input {
    width: 156px;
    padding: 6px 9px;
    border: 1px solid #d7dde6;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    color: var(--text-primary, #1f2937);
    outline: none;
}

.account-name-input:focus { border-color: var(--accent, #2563eb); }

.account-name-btn {
    padding: 6px 11px;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.account-name-btn.save { background: var(--accent, #2563eb); color: #fff; }
.account-name-btn.save:disabled { opacity: .6; cursor: default; }
.account-name-btn.cancel { background: #f1f5f9; color: var(--text-secondary, #64748b); }

/* 轻提示 */
.account-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translate(-50%, -8px);
    z-index: 60;
    max-width: min(420px, calc(100vw - 32px));
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(15, 23, 42, .9);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.account-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
    .account-card-header { padding: 18px; }
    .account-content { padding: 8px 18px 18px; }
    .account-row { grid-template-columns: 82px minmax(0, 1fr); }
    .account-name-input { width: 116px; }
}


